Class: Reap::Application
- Inherits:
-
Object
- Object
- Reap::Application
- Defined in:
- lib/reap/application.rb
Overview
Application is the commandline interface.
Instance Attribute Summary collapse
-
#manager ⇒ Object
readonly
Returns the value of attribute manager.
Instance Method Summary collapse
- #arguments ⇒ Object
- #argv ⇒ Object
-
#initialize ⇒ Application
constructor
A new instance of Application.
- #method_missing(cmd, *args) ⇒ Object
- #options ⇒ Object
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
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 #vector = ArgVector.new #arguments = vector.arguments #options = vector.options opts = {} opts['dryrun'] = .delete('dryrun') opts['trace'] = .delete('trace') opts['force'] = .delete('force') opts['verbose'] = .delete('verbose') opts['debug'] = .delete('debug') opts @manager = Project.new(opts) #@arguments = arguments #@options = options 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 = .dup opts['arguments'] = arguments unless arguments.empty? args << opts manager.invoke(cmd, *args) end |
Instance Attribute Details
#manager ⇒ Object (readonly)
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 ||= ( 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 |