Class: Reap::Application
- Inherits:
-
Object
- Object
- Reap::Application
- Defined in:
- lib/reap/application.rb
Overview
Application
Application is the commandline interface to Project.
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.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/reap/application.rb', line 14 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
59 60 61 62 63 64 |
# File 'lib/reap/application.rb', line 59 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.
12 13 14 |
# File 'lib/reap/application.rb', line 12 def manager @manager end |
Instance Method Details
#arguments ⇒ Object
37 38 39 |
# File 'lib/reap/application.rb', line 37 def arguments @arguments ||= argv.select{ |e| e !~ /^-/ && e !~ /=/ } end |
#argv ⇒ Object
33 34 35 |
# File 'lib/reap/application.rb', line 33 def argv @argv ||= ARGV.dup end |
#options ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/reap/application.rb', line 41 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 |