Class: Shanty::Discoverer

Inherits:
Object
  • Object
show all
Defined in:
lib/shanty/discoverer.rb

Overview

Public: Enables discovery of different types of project utilises inherited class method to find all implementing classes

Direct Known Subclasses

RubygemDiscoverer, ShantyfileDiscoverer

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ Discoverer

Returns a new instance of Discoverer.



15
16
17
# File 'lib/shanty/discoverer.rb', line 15

def initialize(env)
  @env = env
end

Class Attribute Details

.discoverersObject (readonly)

Returns the value of attribute discoverers.



10
11
12
# File 'lib/shanty/discoverer.rb', line 10

def discoverers
  @discoverers
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



13
14
15
# File 'lib/shanty/discoverer.rb', line 13

def env
  @env
end

Class Method Details

.inherited(discoverer) ⇒ Object



19
20
21
22
23
# File 'lib/shanty/discoverer.rb', line 19

def self.inherited(discoverer)
  Util.logger.debug("Detected project discoverer #{discoverer}")
  @discoverers ||= []
  @discoverers << discoverer
end

Instance Method Details

#discover_allObject



25
26
27
28
29
# File 'lib/shanty/discoverer.rb', line 25

def discover_all
  self.class.discoverers.flat_map do |discoverer|
    discoverer.new(env).discover
  end
end