Class: Statistrano::Deployment::Strategy::Branches::Release

Inherits:
Object
  • Object
show all
Defined in:
lib/statistrano/deployment/strategy/branches/release.rb

Overview

Manages the state of a single release for the manifest

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, config, options = {}) ⇒ Release

init a release

Parameters:

  • name (String)

    name of the release

  • config (Obj)

    the config object

  • options (Hash) (defaults to: {})

    :time, :commit, & :link || :repo_url



17
18
19
20
21
# File 'lib/statistrano/deployment/strategy/branches/release.rb', line 17

def initialize name, config, options={}
  @name    = name
  @config  = config
  @options = Util.symbolize_hash_keys options
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



11
12
13
# File 'lib/statistrano/deployment/strategy/branches/release.rb', line 11

def config
  @config
end

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/statistrano/deployment/strategy/branches/release.rb', line 11

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



11
12
13
# File 'lib/statistrano/deployment/strategy/branches/release.rb', line 11

def options
  @options
end

Instance Method Details

#commitObject



27
28
29
# File 'lib/statistrano/deployment/strategy/branches/release.rb', line 27

def commit
  @_commit ||= options.fetch(:commit) { Asgit.current_commit }
end

#hrefObject



35
36
37
# File 'lib/statistrano/deployment/strategy/branches/release.rb', line 35

def href
  "http://#{name}.#{config.base_domain}"
end


31
32
33
# File 'lib/statistrano/deployment/strategy/branches/release.rb', line 31

def link
  @_link ||= options.fetch(:link) { (options[:repo_url]) ? "#{options[:repo_url]}/tree/#{commit}" : nil }
end

#timeObject



23
24
25
# File 'lib/statistrano/deployment/strategy/branches/release.rb', line 23

def time
  @_time ||= options.fetch(:time) { Time.now.to_i }
end

#to_hashObject

def get_binding

binding

end



52
53
54
55
56
57
58
59
60
61
# File 'lib/statistrano/deployment/strategy/branches/release.rb', line 52

def to_hash
  hash = {
    name: name,
    time: time,
    commit: commit
  }
  hash.merge({ link: link }) if link

  return hash
end

#to_jsonString

convert the release to a json object

Returns:

  • (String)


65
66
67
# File 'lib/statistrano/deployment/strategy/branches/release.rb', line 65

def to_json
  return to_hash.to_json
end