Class: Rote::Application
- Inherits:
-
Object
- Object
- Rote::Application
- Defined in:
- lib/rote/app.rb
Overview
Command-line launcher for Rote.
Instance Attribute Summary collapse
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#rake ⇒ Object
Returns the value of attribute rake.
-
#rakefile ⇒ Object
Returns the value of attribute rakefile.
-
#rakeopts ⇒ Object
Returns the value of attribute rakeopts.
-
#rote_lib ⇒ Object
Returns the value of attribute rote_lib.
-
#tasks ⇒ Object
Returns the value of attribute tasks.
-
#trace ⇒ Object
Returns the value of attribute trace.
-
#usage ⇒ Object
Returns the value of attribute usage.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(rote_lib) {|_self| ... } ⇒ Application
constructor
Create a new Application instance, processing command-line arguments, optionally passing
self
to the supplied block for further configuration. -
#run ⇒ Object
Run the application with the current options.
Constructor Details
#initialize(rote_lib) {|_self| ... } ⇒ Application
Create a new Application instance, processing command-line arguments, optionally passing self
to the supplied block for further configuration.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rote/app.rb', line 25 def initialize(rote_lib) # :yield: self if block_given? # init vars @rote_lib = rote_lib @debug = false @tasks = false @trace = false @usage = false @version = false @rakefile = "#{rote_lib}/rote/builtin.rf" raise "Missing builtin.rf (expected at '#{@rakefile}')!" unless File.exists?(@rakefile) @rakeopts = ENV['RAKE_OPTS'] || '' @rake = ENV['RAKE_CMD'] || (RUBY_PLATFORM =~ /mswin/ ? 'rake.cmd' : 'rake') process_args yield self if block_given? end |
Instance Attribute Details
#debug ⇒ Object
Returns the value of attribute debug.
13 14 15 |
# File 'lib/rote/app.rb', line 13 def debug @debug end |
#rake ⇒ Object
Returns the value of attribute rake.
18 19 20 |
# File 'lib/rote/app.rb', line 18 def rake @rake end |
#rakefile ⇒ Object
Returns the value of attribute rakefile.
19 20 21 |
# File 'lib/rote/app.rb', line 19 def rakefile @rakefile end |
#rakeopts ⇒ Object
Returns the value of attribute rakeopts.
20 21 22 |
# File 'lib/rote/app.rb', line 20 def rakeopts @rakeopts end |
#rote_lib ⇒ Object
Returns the value of attribute rote_lib.
12 13 14 |
# File 'lib/rote/app.rb', line 12 def rote_lib @rote_lib end |
#tasks ⇒ Object
Returns the value of attribute tasks.
14 15 16 |
# File 'lib/rote/app.rb', line 14 def tasks @tasks end |
#trace ⇒ Object
Returns the value of attribute trace.
15 16 17 |
# File 'lib/rote/app.rb', line 15 def trace @trace end |
#usage ⇒ Object
Returns the value of attribute usage.
16 17 18 |
# File 'lib/rote/app.rb', line 16 def usage @usage end |
#version ⇒ Object
Returns the value of attribute version.
17 18 19 |
# File 'lib/rote/app.rb', line 17 def version @version end |
Instance Method Details
#run ⇒ Object
Run the application with the current options.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/rote/app.rb', line 46 def run if @version print "rote, version #{ROTEVERSION}\n" elsif @tasks print `#{rake} --rakefile=#{rakefile} --libdir=#{rote_lib} --tasks`.gsub(/^rake /,'rote ') elsif @usage show_usage() else if @trace rakeopts << ' --trace' elsif @debug rakeopts << '--verbose' end exec("#{rake} --rakefile=#{rakefile} --libdir=#{rote_lib} #{rakeopts} #{$*.join(' ')}") end end |