Class: Deployer::MuleDeployer

Inherits:
BaseDeployer show all
Defined in:
lib/deployer/mule_deployer.rb

Instance Attribute Summary collapse

Attributes inherited from BaseDeployer

#options, #stage, #stage_path

Instance Method Summary collapse

Constructor Details

#initialize(adapter_names, options) ⇒ MuleDeployer

Returns a new instance of MuleDeployer.



4
5
6
7
# File 'lib/deployer/mule_deployer.rb', line 4

def initialize(adapter_names, options)
  super(options)
  @adapter_names = adapter_names
end

Instance Attribute Details

#adapter_namesObject (readonly)

Returns the value of attribute adapter_names.



2
3
4
# File 'lib/deployer/mule_deployer.rb', line 2

def adapter_names
  @adapter_names
end

Instance Method Details

#adapter_cached_copy(adapter_name) ⇒ Object



9
10
11
# File 'lib/deployer/mule_deployer.rb', line 9

def adapter_cached_copy(adapter_name)
  cached_copy_dir('mule', "#{adapter_name}.zip")
end

#config_source_dir(adapter_name) ⇒ Object



13
14
15
# File 'lib/deployer/mule_deployer.rb', line 13

def config_source_dir(adapter_name)
  super('mule', adapter_name)
end

#deploy!Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/deployer/mule_deployer.rb', line 17

def deploy!
  puts "deploying to #{stage.name} via #{deploy_via}".light_blue.on_blue

  Deployer::Executor.new(stage, verbose: verbose?) do |executor|
    create_base_dirs(executor)

    # update
    update_cached_copy(executor)

    adapter_names_to_deploy = resolve_adapter_names(executor, options)

    adapter_names_to_deploy.each do |adapter_name|
      puts
      puts "Deploying #{adapter_name}".light_blue.on_blue
      log_deployment(executor, "Deploying #{adapter_name} via #{deploy_via} from #{cached_copy_dir}")
      # make a copy of the zip files to merge them with config
      cached_copy_source = adapter_cached_copy(adapter_name)
      configuration_target = File.join(base_dir, 'mule', "#{adapter_name}.zip")
      executor.execute("cp #{cached_copy_source} #{configuration_target}")

      # copy config
      config_source = config_source_dir(adapter_name)
      executor.execute("if [[ -d #{config_source} ]] ; then cd #{config_source} ; zip -r #{configuration_target} . ; fi")

      # deploy
      executor.execute("cp #{configuration_target} $MULE_HOME/apps")
    end
  end
end