Class: Baptize::Application
- Inherits:
-
Rake::Application
- Object
- Rake::Application
- Baptize::Application
- Defined in:
- lib/baptize/application.rb
Instance Method Summary collapse
- #display_error_message(ex) ⇒ Object
- #handle_options ⇒ Object
-
#initialize ⇒ Application
constructor
A new instance of Application.
- #load_rakefile ⇒ Object
- #name ⇒ Object
- #sort_options(options) ⇒ Object
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
4 5 6 7 8 9 |
# File 'lib/baptize/application.rb', line 4 def initialize super @rakefiles = %w(bapfile Bapfile bapfile.rb Bapfile.rb) Rake.application = self require 'baptize/rake' end |
Instance Method Details
#display_error_message(ex) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/baptize/application.rb', line 66 def (ex) unless .backtrace if (loc = Rake.application.find_rakefile_location) whitelist = (@imported.dup << loc[0]).map{|f| File.absolute_path(f, loc[1])} pattern = %r@^(?!#{whitelist.map{|p| Regexp.quote(p)}.join('|')})@ Rake.application..suppress_backtrace_pattern = pattern end trace "(Backtrace restricted to imported tasks)" end super end |
#handle_options ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/baptize/application.rb', line 40 def .rakelib = ['rakelib'] .trace_output = $stderr OptionParser.new do |opts| opts. = "Baptize prepares your servers" opts.separator "" opts.separator "Show available tasks:" opts.separator " bundle exec baptize -T" opts.separator "" opts.separator "Invoke (or simulate invoking) a task:" opts.separator " bundle exec baptize [--dry-run] TASK" opts.separator "" opts.separator "Advanced options:" opts.on_tail("-h", "--help", "-H", "Display this help message.") do puts opts exit end .each { |args| opts.on(*args) } opts.environment('RAKEOPT') end.parse! end |
#load_rakefile ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/baptize/application.rb', line 15 def load_rakefile super standard_exception_handling do in_namespace :packages do Baptize::Registry.packages.values.each do |package| @last_description = package.description define_task(Rake::Task, package.name.to_s) do puts "Invoke package: #{package.name}" Baptize::Registry.policies.keys.each do |role| on roles(role), in: :parallel do |host| Baptize::Registry.execution_scope.set :current_host, host Baptize::Registry.execution_scope.set :current_ssh_connection, ssh_connection package.execute end end end end end end end |
#name ⇒ Object
11 12 13 |
# File 'lib/baptize/application.rb', line 11 def name "baptize" end |
#sort_options(options) ⇒ Object
36 37 38 |
# File 'lib/baptize/application.rb', line 36 def () super.push(version, dry_run, roles) end |