Class: RubiGen::PathSource

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

Overview

PathSource looks for generators in a filesystem directory.

Direct Known Subclasses

PathFilteredSource

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.



216
217
218
219
# File 'lib/rubigen/lookup.rb', line 216

def initialize(label, path)
  super label
  @path = File.expand_path path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



214
215
216
# File 'lib/rubigen/lookup.rb', line 214

def path
  @path
end

Instance Method Details

#==(source) ⇒ Object



230
231
232
# File 'lib/rubigen/lookup.rb', line 230

def ==(source)
  self.class == source.class && path == source.path
end

#eachObject

Yield each eligible subdirectory.



222
223
224
225
226
227
228
# File 'lib/rubigen/lookup.rb', line 222

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