Module: Capistrano::CLI::Execute

Defined in:
lib/gap/patch.rb

Instance Method Summary collapse

Instance Method Details

#execute!Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/gap/patch.rb', line 10

def execute!
  config = instantiate_configuration(options)
  config.debug = options[:debug]
  config.dry_run = options[:dry_run]
  config.preserve_roles = options[:preserve_roles]
  config.logger.level = options[:verbose]

  set_pre_vars(config)
  load_recipes(config)

  load_gap_yml(config)
  load_gap_default_recipe(config)

  config.trigger(:load)
  execute_requested_actions(config)
  config.trigger(:exit)

  config
rescue Exception => error
  handle_error(error)
end

#load_gap_default_recipe(config) ⇒ Object



32
33
34
35
# File 'lib/gap/patch.rb', line 32

def load_gap_default_recipe config

  config.load { load File.expand_path './defalut_recipe.rb', File.dirname(__FILE__)}
end

#load_gap_yml(config) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/gap/patch.rb', line 38

def load_gap_yml config
  #コマンドラインオプションにする
  gap_config = YAML.load_file("config/gap.yml")
  config.send(:extend,Gap::Tasks)
  config.send(:extend,Gap::SudoRun)
  config.load do
    config.init_val

    gap_config.each do |env,value|

      variables = value["set"]
      case env
      when "global"
        variables.each { |attr, val| set attr, val} if variables
      when "local"
        task(env) do
          define_bulk_tasks value
          variables.each { |attr, val| set attr, val } if variables
          value.each do |app, commands|
            task(app) do
              commands["task"].each { |name, command|
                task(name) { system("rvm-shell '#{rvm_ruby_string}' -c '#{command}'")}}
            end
          end
        end
      else
        task(env) do
          define_config_tasks value
          define_bulk_tasks value
        end
      end

    end

  end
end