Class: Capistrano::Application

Inherits:
Rake::Application
  • Object
show all
Defined in:
lib/capistrano/application.rb

Instance Method Summary collapse

Constructor Details

#initializeApplication

Returns a new instance of Application.



3
4
5
6
# File 'lib/capistrano/application.rb', line 3

def initialize
  super
  @rakefiles = %w{capfile Capfile capfile.rb Capfile.rb}
end

Instance Method Details

#display_error_message(ex) ⇒ Object



62
63
64
65
66
67
68
69
# File 'lib/capistrano/application.rb', line 62

def display_error_message(ex)
  unless options.backtrace
    Rake.application.options.suppress_backtrace_pattern = backtrace_pattern if backtrace_pattern
    trace "(Backtrace restricted to imported tasks)"
  end

  super
end

#exit_because_of_exception(ex) ⇒ Object



71
72
73
74
75
76
77
# File 'lib/capistrano/application.rb', line 71

def exit_because_of_exception(ex)
  if respond_to?(:deploying?) && deploying?
    exit_deploy_because_of_exception(ex)
  else
    super
  end
end

#find_rakefile_locationObject

allows the ‘cap install` task to load without a capfile



80
81
82
83
84
85
86
# File 'lib/capistrano/application.rb', line 80

def find_rakefile_location
  if (location = super).nil?
    [capfile, Dir.pwd]
  else
    location
  end
end

#handle_optionsObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/capistrano/application.rb', line 26

def handle_options
  options.rakelib = ["rakelib"]
  options.trace_output = $stderr

  OptionParser.new do |opts|
    opts.banner = "See full documentation at http://capistranorb.com/."
    opts.separator ""
    opts.separator "Install capistrano in a project:"
    opts.separator "    bundle exec cap install [STAGES=qa,staging,production,...]"
    opts.separator ""
    opts.separator "Show available tasks:"
    opts.separator "    bundle exec cap -T"
    opts.separator ""
    opts.separator "Invoke (or simulate invoking) a task:"
    opts.separator "    bundle exec cap [--dry-run] STAGE TASK"
    opts.separator ""
    opts.separator "Advanced options:"

    opts.on_tail("-h", "--help", "-H", "Display this help message.") do
      puts opts
      exit
    end

    standard_rake_options.each { |args| opts.on(*args) }
    opts.environment("RAKEOPT")
  end.parse!
end

#nameObject



8
9
10
# File 'lib/capistrano/application.rb', line 8

def name
  "cap"
end

#runObject



12
13
14
15
# File 'lib/capistrano/application.rb', line 12

def run
  Rake.application = self
  super
end

#sort_options(options) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/capistrano/application.rb', line 17

def sort_options(options)
  not_applicable_to_capistrano = %w(quiet silent verbose)
  options.reject! do |(switch, *)|
    switch =~ /--#{Regexp.union(not_applicable_to_capistrano)}/
  end

  super.push(version, dry_run, roles, hostfilter, print_config_variables)
end

#top_level_tasksObject



54
55
56
57
58
59
60
# File 'lib/capistrano/application.rb', line 54

def top_level_tasks
  if tasks_without_stage_dependency.include?(@top_level_tasks.first)
    @top_level_tasks
  else
    @top_level_tasks.unshift(ensure_stage.to_s)
  end
end