Class: Rote::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/rote/app.rb

Overview

Command-line launcher for Rote.

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

Yields:

  • (_self)

Yield Parameters:



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

#debugObject

Returns the value of attribute debug.



13
14
15
# File 'lib/rote/app.rb', line 13

def debug
  @debug
end

#rakeObject

Returns the value of attribute rake.



18
19
20
# File 'lib/rote/app.rb', line 18

def rake
  @rake
end

#rakefileObject

Returns the value of attribute rakefile.



19
20
21
# File 'lib/rote/app.rb', line 19

def rakefile
  @rakefile
end

#rakeoptsObject

Returns the value of attribute rakeopts.



20
21
22
# File 'lib/rote/app.rb', line 20

def rakeopts
  @rakeopts
end

#rote_libObject

Returns the value of attribute rote_lib.



12
13
14
# File 'lib/rote/app.rb', line 12

def rote_lib
  @rote_lib
end

#tasksObject

Returns the value of attribute tasks.



14
15
16
# File 'lib/rote/app.rb', line 14

def tasks
  @tasks
end

#traceObject

Returns the value of attribute trace.



15
16
17
# File 'lib/rote/app.rb', line 15

def trace
  @trace
end

#usageObject

Returns the value of attribute usage.



16
17
18
# File 'lib/rote/app.rb', line 16

def usage
  @usage
end

#versionObject

Returns the value of attribute version.



17
18
19
# File 'lib/rote/app.rb', line 17

def version
  @version
end

Instance Method Details

#runObject

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