Class: Rake::Application
- Inherits:
-
Object
- Object
- Rake::Application
- Defined in:
- lib/webby/apps/main.rb
Overview
:stopdoc: Monkey patches so that rake displays the correct application name in the help messages.
Instance Method Summary collapse
- #display_prerequisites ⇒ Object
- #display_tasks_and_comments ⇒ Object
-
#standard_exception_handling ⇒ Object
Provide standard execption handling for the given block.
Instance Method Details
#display_prerequisites ⇒ Object
178 179 180 181 182 183 |
# File 'lib/webby/apps/main.rb', line 178 def display_prerequisites tasks.each do |t| puts "#{name} #{t.name}" t.prerequisites.each { |pre| puts " #{pre}" } end end |
#display_tasks_and_comments ⇒ Object
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/webby/apps/main.rb', line 185 def display_tasks_and_comments displayable_tasks = tasks.select { |t| t.comment && t.name =~ .show_task_pattern } if .full_description displayable_tasks.each do |t| puts "#{name} #{t.name_with_args}" t.full_comment.split("\n").each do |line| puts " #{line}" end puts end else width = displayable_tasks.collect { |t| t.name_with_args.length }.max || 10 max_column = truncate_output? ? terminal_width - name.size - width - 7 : nil displayable_tasks.each do |t| printf "#{name} %-#{width}s # %s\n", t.name_with_args, max_column ? truncate(t.comment, max_column) : t.comment end end end |
#standard_exception_handling ⇒ Object
Provide standard execption handling for the given block.
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/webby/apps/main.rb', line 208 def standard_exception_handling begin yield rescue SystemExit => ex # Exit silently with current status exit(ex.status) rescue SystemExit, OptionParser::InvalidOption => ex # Exit silently exit(1) rescue Exception => ex # Exit with error message $stderr.puts "#{name} aborted!" $stderr.puts ex. if .trace $stderr.puts ex.backtrace.join("\n") else $stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || "" $stderr.puts "(See full trace by running task with --trace)" end exit(1) end end |