Class: Mamiya::Steps::Prepare

Inherits:
Abstract
  • Object
show all
Defined in:
lib/mamiya/steps/prepare.rb

Instance Attribute Summary

Attributes inherited from Abstract

#config, #logger, #options

Instance Method Summary collapse

Methods inherited from Abstract

#initialize

Constructor Details

This class inherits a constructor from Mamiya::Steps::Abstract

Instance Method Details

#given_scriptObject

This class see target_dir’s script



33
# File 'lib/mamiya/steps/prepare.rb', line 33

alias given_script script

#run!Object



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

def run!
  @exception = nil
  old_pwd = Dir.pwd
  Dir.chdir(target)

  logger.info "Preparing #{target}..."

  script.before_prepare(labels)[]
  script.prepare(labels)[]

  File.write target.join('.mamiya.prepared'), "#{Time.now.to_i}\n"
rescue Exception => e
  @exception = e
  raise e
ensure
  Dir.chdir old_pwd if old_pwd
  logger.warn "Exception occured, cleaning up..." if @exception

  script.after_prepare(labels)[@exception]

  logger.info "DONE!" unless @exception
end

#scriptObject



35
36
37
38
39
40
41
42
# File 'lib/mamiya/steps/prepare.rb', line 35

def script
  @target_script ||= Mamiya::Script.new.load!(
    target.join('.mamiya.script', target_meta['script'])).tap do |script|
    script.set(:deploy_to, config.deploy_to_for(script.application))
    script.set(:release_path, target)
    script.set(:logger, logger)
  end
end