Class: Muding::Generator::PathSource

Inherits:
Source show all
Defined in:
lib/muding_generator/lookup.rb

Overview

PathSource looks for generators in a filesystem directory.

Instance Attribute Summary collapse

Attributes inherited from Source

#label

Instance Method Summary collapse

Methods inherited from Source

#names

Constructor Details

#initialize(label, path) ⇒ PathSource

Returns a new instance of PathSource.



174
175
176
177
# File 'lib/muding_generator/lookup.rb', line 174

def initialize(label, path)
  super label
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



172
173
174
# File 'lib/muding_generator/lookup.rb', line 172

def path
  @path
end

Instance Method Details

#eachObject

Yield each eligible subdirectory.



180
181
182
183
184
185
186
# File 'lib/muding_generator/lookup.rb', line 180

def each
  Dir["#{path}/[a-z]*"].each do |dir|
    if File.directory?(dir)
      yield Spec.new(File.basename(dir), dir, label)
    end
  end
end