Class: RSpec::Covers::ProductionInventory
- Inherits:
-
Object
- Object
- RSpec::Covers::ProductionInventory
- Defined in:
- lib/rspec/covers/production_inventory.rb
Instance Method Summary collapse
-
#initialize(config) ⇒ ProductionInventory
constructor
A new instance of ProductionInventory.
- #loaded_methods ⇒ Object
- #methods ⇒ Object
- #methods_by_label(labels) ⇒ Object
- #methods_for_locations(locations) ⇒ Object
- #orphan_methods(declared_regions) ⇒ Object
Constructor Details
#initialize(config) ⇒ ProductionInventory
Returns a new instance of ProductionInventory.
14 15 16 |
# File 'lib/rspec/covers/production_inventory.rb', line 14 def initialize(config) @config = config end |
Instance Method Details
#loaded_methods ⇒ Object
18 19 20 21 22 |
# File 'lib/rspec/covers/production_inventory.rb', line 18 def loaded_methods @loaded_methods ||= ObjectSpace.each_object(Module).flat_map do |mod| method_entries_for(mod) end.uniq(&:label) end |
#methods ⇒ Object
24 25 26 |
# File 'lib/rspec/covers/production_inventory.rb', line 24 def methods @methods ||= (loaded_methods + StaticMethodScanner.new(@config).scan).uniq(&:label) end |
#methods_by_label(labels) ⇒ Object
34 35 36 37 |
# File 'lib/rspec/covers/production_inventory.rb', line 34 def methods_by_label(labels) wanted = labels.to_set methods.select { |entry| wanted.include?(entry.label) } end |
#methods_for_locations(locations) ⇒ Object
28 29 30 31 32 |
# File 'lib/rspec/covers/production_inventory.rb', line 28 def methods_for_locations(locations) locations.flat_map do |location| methods.select { |entry| entry.include?(location) } end.uniq(&:label) end |
#orphan_methods(declared_regions) ⇒ Object
39 40 41 42 |
# File 'lib/rspec/covers/production_inventory.rb', line 39 def orphan_methods(declared_regions) declared_labels = declared_regions.map(&:label).to_set methods.reject { |entry| declared_labels.include?(entry.label) } end |