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
166 167 168 169 170 171 |
# File 'lib/webby/apps/main.rb', line 166 def display_prerequisites tasks.each do |t| puts "#{name} #{t.name}" t.prerequisites.each { |pre| puts " #{pre}" } end end |
#display_tasks_and_comments ⇒ Object
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/webby/apps/main.rb', line 173 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 = 80 - name.size - width - 7 displayable_tasks.each do |t| printf "#{name} %-#{width}s # %s\n", t.name_with_args, truncate(t.comment, max_column) end end end |
#standard_exception_handling ⇒ Object
Provide standard execption handling for the given block.
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/webby/apps/main.rb', line 196 def standard_exception_handling begin yield rescue SystemExit => ex # Exit silently with current status exit(ex.status) rescue SystemExit, GetoptLong::InvalidOption => ex # Exit silently exit(1) rescue Exception => ex # Exit with error message $stderr.puts "webby 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 |