Class: Rake::Application

Inherits:
Object
  • Object
show all
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

Instance Method Details

#display_prerequisitesObject



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_commentsObject



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 =~ options.show_task_pattern
  }
  if options.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_handlingObject

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.message
    if options.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