Sha256: a18b6c627e006e2c8bde10bd3db74e330fd5a57c022db8ca1cbaf4e7cba3778b
Contents?: true
Size: 962 Bytes
Versions: 3
Compression:
Stored size: 962 Bytes
Contents
require 'scaffolder' module Scaffolder::ToolIndex require 'scaffolder/tool' def get_tool(name) tools[normalise(name)] end def tool_exists?(name) ! get_tool(name).nil? end def [](type) if tool_exists?(type) get_tool(type) else Scaffolder::Tool::Help end end def determine_tool(settings) type = settings.rest.shift tool_class = self[type] settings[:unknown_tool] = type unless (tool_exists?(type) or type.nil?) [tool_class,settings] end private def tool_classes Scaffolder::Tool.constants.inject(Array.new) do |array,constant| clss = Scaffolder::Tool.const_get(constant) array << clss if clss.superclass == Scaffolder::Tool array end end def tools tool_classes.inject(Hash.new) do |hash,clss| hash[clss.to_s.split('::').last.downcase.to_sym] = clss hash end end def normalise(name) name.to_s.downcase.to_sym if name end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
scaffolder-tools-0.1.2 | lib/scaffolder/tool_index.rb |
scaffolder-tools-0.1.1 | lib/scaffolder/tool_index.rb |
scaffolder-tools-0.1.0 | lib/scaffolder/tool_index.rb |