class Rote::Application

Command-line launcher for Rote.

Attributes

debug[RW]
rake[RW]
rakefile[RW]
rakeopts[RW]
rote_lib[RW]
tasks[RW]
trace[RW]
usage[RW]
version[RW]

Public Class Methods

new(rote_lib) { |self| ... } click to toggle source

Create a new Application instance, processing command-line arguments, optionally passing self to the supplied block for further configuration.

# 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

Public Instance Methods

run() click to toggle source

Run the application with the current options.

# File lib/rote/app.rb, line 46
def run    
  if @version
    print "rote, version #{ROTEVERSION}\n"
   
  elsif @tasks
    print %x#{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