lib/rubigen/lookup.rb
# Lookup knows how to find generators' Specs from a list of Sources.
# Searches the sources, in order, for the first matching name.
Lookup knows how to find generators' Specs from a list of Sources.
Searches the sources, in order, for the first matching name.
Lookup knows how to find generators ' Specs from a list of Sources . Searches the sources in order for the first matching name .
def lookup(generator_name)
        @found ||= {}
        generator_name = generator_name.to_s.downcase
        @found[generator_name] ||= cache.find { |spec| spec.name == generator_name }
        unless @found[generator_name] 
          chars = generator_name.scan(/./).map{|c|"#{c}.*?"}
          rx = /^#{chars}$/
          gns = cache.select {|spec| spec.name =~ rx }
          @found[generator_name] ||= gns.first if gns.length == 1
          raise GeneratorError, "Pattern '#{generator_name}' matches more than one generator: #{gns.map{|sp|sp.name}.join(', ')}" if gns.length > 1
        end
        @found[generator_name] or raise GeneratorError, "Couldn't find '#{generator_name}' generator"
      end
def lookup ( generator_name ) @found ||= { } generator_name = generator_name . to_s . downcase @found [ generator_name ] ||= cache . find { | spec | spec . name == generator_name } unless @found [ generator_name ] chars = generator_name . scan ( / . / ) . map { | c | "#{c}.*?" } rx = / ^ #{ chars } $ / gns = cache . select { | spec | spec . name =~ rx } @found [ generator_name ] ||= gns . first if gns . length == 1 raise GeneratorError , "Pattern '#{generator_name}' matches more than one generator: #{gns.map{|sp|sp.name}.join(', ')}" if gns . length > 1 end @found [ generator_name ] or raise GeneratorError , "Couldn't find '#{generator_name}' generator" end
Lookup knows how to find generators' Specs from a list of Sources.
Lookup knows how to find generators ' Specs from a list of Sources .
generator_name
<not_specific>