Class: CapistranoHelper

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(variables) ⇒ CapistranoHelper

Returns a new instance of CapistranoHelper.



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

def initialize(variables)
  @stage_manager = StageManager.new(variables[:autotagger_stages])
  @variables = variables
  @stage = variables[:stage]
  @working_directory = variables[:working_directory] || Dir.pwd
end

Instance Attribute Details

#stageObject (readonly)

Returns the value of attribute stage.



3
4
5
# File 'lib/auto_tagger/capistrano_helper.rb', line 3

def stage
  @stage
end

#variablesObject (readonly)

Returns the value of attribute variables.



3
4
5
# File 'lib/auto_tagger/capistrano_helper.rb', line 3

def variables
  @variables
end

#working_directoryObject (readonly)

Returns the value of attribute working_directory.



3
4
5
# File 'lib/auto_tagger/capistrano_helper.rb', line 3

def working_directory
  @working_directory
end

Instance Method Details

#branchObject



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

def branch
  if variables.has_key?(:head)
    variables[:branch]
  elsif variables.has_key?(:tag)
    variables[:tag]
  elsif stage && (latest = AutoTagger.new(stage, working_directory).latest_tag)
    latest
  else
    variables[:branch]
  end
end

#previous_stageObject



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

def previous_stage
  @stage_manager.previous_stage(stage)
end

#release_tag_entriesObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/auto_tagger/capistrano_helper.rb', line 28

def release_tag_entries
  entries = []
  @stage_manager.stages.each do |stage|
    tagger = AutoTagger.new(stage, working_directory)
    tag = tagger.latest_tag
    commit = tagger.repository.commit_for(tag)
    entries << "#{stage.to_s.ljust(10, " ")} #{tag.to_s.ljust(30, " ")} #{commit.to_s}"
  end
  entries
end