Class: Reap::Application
- Inherits:
-
Object
show all
- Defined in:
- lib/reap/application.rb
Overview
Application is the commandline interface.
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/reap/application.rb', line 12
def initialize
opts = {}
opts['dryrun'] = options.delete('dryrun')
opts['trace'] = options.delete('trace')
opts['force'] = options.delete('force')
opts['verbose'] = options.delete('verbose')
opts['debug'] = options.delete('debug')
opts
@manager = Project.new(opts)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(cmd, *args) ⇒ Object
57
58
59
60
61
62
|
# File 'lib/reap/application.rb', line 57
def method_missing(cmd, *args)
opts = options.dup
opts['arguments'] = arguments unless arguments.empty?
args << opts
manager.invoke(cmd, *args)
end
|
Instance Attribute Details
#manager ⇒ Object
Returns the value of attribute manager.
10
11
12
|
# File 'lib/reap/application.rb', line 10
def manager
@manager
end
|
Instance Method Details
#arguments ⇒ Object
35
36
37
|
# File 'lib/reap/application.rb', line 35
def arguments
@arguments ||= argv.select{ |e| e !~ /^-/ && e !~ /=/ }
end
|
#argv ⇒ Object
31
32
33
|
# File 'lib/reap/application.rb', line 31
def argv
@argv ||= ARGV.dup
end
|
#options ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/reap/application.rb', line 39
def options
@options ||= (
pms = {}
argv.select{ |e| /[=]/ =~ e }.each do |e|
k,v = e.split('=')
k = k.sub(/^[-]{1,2}/,'')
pms.store(k,v)
end
argv.select{ |e| e =~ /^-/ && e !~ /=/ }.each do |k|
k = k.sub(/^[-]{1,2}/,'')
pms.store(k,true)
end
pms
)
end
|