Class: Ronin::Recon::Workers Private
- Inherits:
-
Object
- Object
- Ronin::Recon::Workers
- Includes:
- Enumerable
- Defined in:
- lib/ronin/recon/workers.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Represents a set of recon worker classes.
Constant Summary collapse
- INTENSITY_LEVELS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Intensity levels sorted by their intensity.
[ :passive, :active, :aggressive ]
Instance Attribute Summary collapse
-
#classes ⇒ Set<Class<Worker>>
readonly
private
The worker classes in the set.
Class Method Summary collapse
-
.[](*worker_ids) ⇒ Workers
private
Alias for Workers.load.
-
.all ⇒ Workers
private
Loads all workers.
-
.category(name) ⇒ Workers
private
Loads all workers under a specific category.
-
.load(worker_ids) ⇒ Workers
private
Loads the worker classes.
Instance Method Summary collapse
-
#+(other) ⇒ Workers
private
Adds another set of workers to the workers.
-
#<<(worker) ⇒ self
private
Adds the worker class to the workers.
-
#==(other) ⇒ Boolean
private
Determines if the workers is equal to another workers.
-
#delete(worker) ⇒ self?
private
Removes a worker class from the workers.
-
#each {|worker| ... } ⇒ Enumerator
private
Enumerates over the worker classes within the set.
-
#initialize(workers = Set.new) ⇒ Workers
constructor
private
Initializes the workers.
-
#intensity(level) ⇒ Workers
private
Filters the workers by their intensity level.
-
#load(worker_id) ⇒ self
private
Loads a worker and adds it to the workers.
-
#load_file(path) ⇒ self
private
Loads a worker from a file and adds it to the workers.
-
#remove(worker_id) ⇒ self?
private
Removes a worker with the ID from the workers.
-
#to_set ⇒ Set<Class<Worker>>
private
Converts the workers into a Set.
Constructor Details
#initialize(workers = Set.new) ⇒ Workers
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes the workers.
47 48 49 |
# File 'lib/ronin/recon/workers.rb', line 47 def initialize(workers=Set.new) @classes = workers.to_set end |
Instance Attribute Details
#classes ⇒ Set<Class<Worker>> (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The worker classes in the set.
39 40 41 |
# File 'lib/ronin/recon/workers.rb', line 39 def classes @classes end |
Class Method Details
.[](*worker_ids) ⇒ Workers
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Alias for load.
77 78 79 |
# File 'lib/ronin/recon/workers.rb', line 77 def self.[](*worker_ids) load(worker_ids) end |
.all ⇒ Workers
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Loads all workers.
86 87 88 |
# File 'lib/ronin/recon/workers.rb', line 86 def self.all load(Recon.list_files) end |
.category(name) ⇒ Workers
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Loads all workers under a specific category.
98 99 100 101 102 103 104 |
# File 'lib/ronin/recon/workers.rb', line 98 def self.category(name) load( Recon.list_files.select { |worker_id| worker_id.start_with?("#{name}/") } ) end |
.load(worker_ids) ⇒ Workers
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Loads the worker classes.
59 60 61 62 63 64 65 66 67 |
# File 'lib/ronin/recon/workers.rb', line 59 def self.load(worker_ids) workers = new worker_ids.each do |worker_id| workers.load(worker_id) end return workers end |
Instance Method Details
#+(other) ⇒ Workers
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Adds another set of workers to the workers.
130 131 132 133 134 |
# File 'lib/ronin/recon/workers.rb', line 130 def +(other) other_workers = other.to_set self.class.new((@classes + other_workers).uniq) end |
#<<(worker) ⇒ self
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Adds the worker class to the workers.
144 145 146 147 |
# File 'lib/ronin/recon/workers.rb', line 144 def <<(worker) @classes << worker return self end |
#==(other) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Determines if the workers is equal to another workers.
244 245 246 247 |
# File 'lib/ronin/recon/workers.rb', line 244 def ==(other) self.class == other.class && @classes == other.classes end |
#delete(worker) ⇒ self?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Removes a worker class from the workers.
184 185 186 187 188 |
# File 'lib/ronin/recon/workers.rb', line 184 def delete(worker) if @classes.delete?(worker) self end end |
#each {|worker| ... } ⇒ Enumerator
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Enumerates over the worker classes within the set.
119 120 121 |
# File 'lib/ronin/recon/workers.rb', line 119 def each(&block) @classes.each(&block) end |
#intensity(level) ⇒ Workers
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Filters the workers by their intensity level.
224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/ronin/recon/workers.rb', line 224 def intensity(level) level_index = INTENSITY_LEVELS.index(level) self.class.new( @classes.select { |worker| if (intensity_index = INTENSITY_LEVELS.index(worker.intensity)) intensity_index <= level_index end } ) end |
#load(worker_id) ⇒ self
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Loads a worker and adds it to the workers.
157 158 159 |
# File 'lib/ronin/recon/workers.rb', line 157 def load(worker_id) self << Recon.load_class(worker_id) end |
#load_file(path) ⇒ self
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Loads a worker from a file and adds it to the workers.
169 170 171 |
# File 'lib/ronin/recon/workers.rb', line 169 def load_file(path) self << Recon.load_class_from_file(path) end |
#remove(worker_id) ⇒ self?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Removes a worker with the ID from the workers.
201 202 203 204 205 |
# File 'lib/ronin/recon/workers.rb', line 201 def remove(worker_id) if @classes.reject! { |worker| worker.id == worker_id } self end end |
#to_set ⇒ Set<Class<Worker>>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts the workers into a Set.
254 255 256 |
# File 'lib/ronin/recon/workers.rb', line 254 def to_set @classes end |