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 25 def initialize(rote_lib) # :yield: self if block_given? 26 # init vars 27 @rote_lib = rote_lib 28 @debug = false 29 @tasks = false 30 @trace = false 31 @usage = false 32 @version = false 33 34 @rakefile = "#{rote_lib}/rote/builtin.rf" 35 raise "Missing builtin.rf (expected at '#{@rakefile}')!" unless File.exists?(@rakefile) 36 37 @rakeopts = ENV['RAKE_OPTS'] || '' 38 @rake = ENV['RAKE_CMD'] || (RUBY_PLATFORM =~ /mswin/ ? 'rake.cmd' : 'rake') 39 40 process_args 41 42 yield self if block_given? 43 end
Public Instance Methods
run()
click to toggle source
Run the application with the current options.
# File lib/rote/app.rb 46 def run 47 if @version 48 print "rote, version #{ROTEVERSION}\n" 49 50 elsif @tasks 51 print `#{rake} --rakefile=#{rakefile} --libdir=#{rote_lib} --tasks`.gsub(/^rake /,'rote ') 52 53 elsif @usage 54 show_usage() 55 56 else 57 if @trace 58 rakeopts << ' --trace' 59 elsif @debug 60 rakeopts << '--verbose' 61 end 62 63 exec("#{rake} --rakefile=#{rakefile} --libdir=#{rote_lib} #{rakeopts} #{$*.join(' ')}") 64 end 65 end
Private Instance Methods
process_args()
click to toggle source
Process commandline
# File lib/rote/app.rb 70 def process_args 71 GetoptLong.new( 72 [ "--verbose", "-v", GetoptLong::NO_ARGUMENT ], 73 [ "--tasks", "-T", GetoptLong::NO_ARGUMENT ], 74 [ "--trace", "-t", GetoptLong::NO_ARGUMENT ], 75 [ "--usage", "-u", GetoptLong::NO_ARGUMENT ], 76 [ "--help", "-h", GetoptLong::NO_ARGUMENT ], 77 [ "--version", "-V", GetoptLong::NO_ARGUMENT ] 78 ).each { |opt,arg| 79 @debug = true if opt == '--verbose' 80 @trace = true if opt == '--trace' 81 @tasks = true if opt == '--tasks' 82 @usage = true if opt == '--usage' || opt == '--help' 83 @version = true if opt == '--version' 84 } 85 end
show_usage()
click to toggle source
Display help text
# File lib/rote/app.rb 88 def show_usage 89 print <<-EOM 90 Usage: rote [options] [task1] .. [taskN] 91 92 Where [taskN] is a valid task or target name for the current project. 93 Rote generates targets for each page source, and also defines a number 94 of top-level tasks for various things. Use the '--tasks' option to get 95 a list of valid tasks. 96 97 Recognised options are: 98 99 --tasks -T Display a list of tasks in this project. 100 --verbose -v Enable verbose output. 101 --trace -t Enables trace-level output (debugging). 102 --usage -u Display this help message and quit 103 --help -h Synonym for --usage 104 --version -V Display Rote's version and quit 105 106 In addition to the standard doc_XXX tasks and those provided by any 107 local configuration, the following 'special' tasks are recognised: 108 109 create <project> Create a blank project from the built-in template. 110 111 Note that these 'special' tasks are implemented as part of the command- 112 line wrapper for Rote, and will not be available from custom Rakefiles. 113 114 In non-standard environments, it may be necessary to set the ROTE_LIB 115 variable to point to the location of Rote's libraries. 116 117 EOM 118 end