Class: Heroploy::Tasks::DeployTaskLib

Inherits:
Rake::TaskLib
  • Object
show all
Includes:
Commands::Git, Rake::DSL
Defined in:
lib/heroploy/tasks/deploy_task_lib.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Commands::Git

#current_branch, #git_clone, #git_fetch, #git_push_tag, #git_push_to_master, #git_remote_behind?, #git_remote_exists?, #git_remote_has_branch?, #git_staged?, #git_tag

Constructor Details

#initialize(deployment_config) ⇒ DeployTaskLib

Returns a new instance of DeployTaskLib.



15
16
17
18
# File 'lib/heroploy/tasks/deploy_task_lib.rb', line 15

def initialize(deployment_config)
  @deployment_config = deployment_config
  define
end

Instance Attribute Details

#deployment_configObject

Returns the value of attribute deployment_config.



13
14
15
# File 'lib/heroploy/tasks/deploy_task_lib.rb', line 13

def deployment_config
  @deployment_config
end

Instance Method Details

#defineObject



20
21
22
23
24
# File 'lib/heroploy/tasks/deploy_task_lib.rb', line 20

def define
  define_fetch_task
  define_load_configs_task
  define_env_tasks
end

#define_env_tasksObject



49
50
51
52
53
# File 'lib/heroploy/tasks/deploy_task_lib.rb', line 49

def define_env_tasks
  deployment_config.environments.each do |env|
    EnvTaskLib.new(deployment_config, env)
  end
end

#define_fetch_taskObject



26
27
28
29
30
31
# File 'lib/heroploy/tasks/deploy_task_lib.rb', line 26

def define_fetch_task
  desc 'do a git fetch'
  task :fetch do
    git_fetch
  end
end

#define_load_configs_taskObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/heroploy/tasks/deploy_task_lib.rb', line 33

def define_load_configs_task
  desc 'load remote configs'
  task :load_remote_configs do
    unless deployment_config.remote_configs.nil?
      deployment_config.remote_configs.each do |remote_config|
        git_clone(remote_config.repository, remote_config.name) do
          remote_config.files.each do |filename|
            config_file = File.join(Dir.pwd, remote_config.name, filename)
            deployment_config.merge_config(Heroploy::Config::DeploymentConfig.load(config_file))
          end
        end
      end
    end
  end
end