Module: CrawlStation::Command
- Extended by:
- ActiveSupport::Autoload, Command
- Included in:
- Command
- Defined in:
- lib/crawl_station.rb,
lib/crawl_station/command.rb,
lib/crawl_station/command/create.rb,
lib/crawl_station/command/generate.rb
Defined Under Namespace
Classes: Create, Generate
Constant Summary
collapse
- ALIASES =
{ 'module' => 'new_module' }
Instance Method Summary
collapse
Instance Method Details
#invoke(command, args) ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'lib/crawl_station/command.rb', line 6
def invoke(command, args)
klass = "CrawlStation::Command::#{command.capitalize}".camelize.constantize
m_name = method_name(command, args)
obj = klass.new
return obj.send(m_name, args) if obj.respond_to?(m_name)
true
rescue Errno::ENOENT, RuntimeError => e
Logger.warn "#{e.message}\n#{e.backtrace[0..10].join("\n")}"
end
|
#method_name(command, args) ⇒ Object
16
17
18
19
20
|
# File 'lib/crawl_station/command.rb', line 16
def method_name(command, args)
return 'create' if command.to_s == 'create'
name = args.shift
ALIASES[name] || name
end
|