Class: AutoTagger::CapistranoHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/auto_tagger/capistrano_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(variables) ⇒ CapistranoHelper

Returns a new instance of CapistranoHelper.



7
8
9
# File 'lib/auto_tagger/capistrano_helper.rb', line 7

def initialize(variables)
  @variables = variables
end

Instance Method Details

#auto_taggerObject



11
12
13
# File 'lib/auto_tagger/capistrano_helper.rb', line 11

def auto_tagger
  @auto_tagger ||= AutoTagger::Base.new(auto_tagger_options)
end

#auto_tagger_optionsObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/auto_tagger/capistrano_helper.rb', line 29

def auto_tagger_options
  options = {}
  options[:stage] = variables[:auto_tagger_stage] || variables[:stage]
  options[:stages] = stages

  if variables[:working_directory]
    AutoTagger::Deprecator.warn(":working_directory is deprecated.  Please use :auto_tagger_working_directory.")
    options[:path] = variables[:working_directory]
  else
    options[:path] = variables[:auto_tagger_working_directory]
  end

  if ! variables[:auto_tagger_dry_run].nil?
    options[:dry_run] = variables[:auto_tagger_dry_run]
  else
    options[:dry_run] = variables[:dry_run]
  end

  [
    :date_separator, :push_refs, :fetch_refs, :remote, :ref_path, :offline,
    :verbose, :refs_to_keep, :executable, :opts_file
  ].each do |key|
    options[key] = variables[:"auto_tagger_#{key}"]
  end

  options
end

#refObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/auto_tagger/capistrano_helper.rb', line 15

def ref
  if variables.has_key?(:head)
    variables[:branch]
  elsif variables.has_key?(:tag)
    variables[:tag]
  elsif variables.has_key?(:ref)
    variables[:ref]
  elsif auto_tagger.last_ref_from_previous_stage
    auto_tagger.last_ref_from_previous_stage.sha
  else
    variables[:branch]
  end
end

#stagesObject



57
58
59
60
61
62
63
64
65
# File 'lib/auto_tagger/capistrano_helper.rb', line 57

def stages
  if variables[:autotagger_stages]
    AutoTagger::Deprecator.warn(":autotagger_stages is deprecated.  Please use :auto_tagger_stages.")
    stages = variables[:autotagger_stages]
  else
    stages = variables[:auto_tagger_stages] || variables[:stages] || []
  end
  stages.map { |stage| stage.to_s }
end