Sha256: 94ff6c1fb409545ac7f7c7358ec5d4afb37bcc97804cc95cda36b7f6406e6b4d
Contents?: true
Size: 979 Bytes
Versions: 2
Compression:
Stored size: 979 Bytes
Contents
module Space class App class Handler ALIASES = { '' => 'scope', '-' => 'unscope', 'r' => 'refresh' } attr_reader :project def initialize(project) @project = project end def run(line) scope, type = parse(line) command = command_for(scope, type) command.run end private def command_for(scope, type) const = const_for(type) args = [project, scope] args << type if const == Command::Execute const.new(*args) end def parse(line) Parser.new(project.names).parse(line) end def const_for(type) Command.const_get(const_name(type)) rescue NameError Command::Execute end def const_name(type) type = (type || '').strip type = ALIASES[type] if ALIASES.key?(type) type.capitalize end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
space-0.0.5 | lib/space/app/handler.rb |
space-0.0.4 | lib/space/app/handler.rb |