Class: Escobar::Heroku::Release

Inherits:
Object
  • Object
show all
Defined in:
lib/escobar/heroku/release.rb

Overview

Class representing a heroku release

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, app_id, build_id, id) ⇒ Release

Returns a new instance of Release.



12
13
14
15
16
17
# File 'lib/escobar/heroku/release.rb', line 12

def initialize(client, app_id, build_id, id)
  @id       = id
  @app_id   = app_id
  @build_id = build_id
  @client   = client
end

Instance Attribute Details

#app_idObject (readonly)

Returns the value of attribute app_id.



5
6
7
# File 'lib/escobar/heroku/release.rb', line 5

def app_id
  @app_id
end

#app_nameObject (readonly)

Returns the value of attribute app_name.



5
6
7
# File 'lib/escobar/heroku/release.rb', line 5

def app_name
  @app_name
end

#build_idObject (readonly)

Returns the value of attribute build_id.



5
6
7
# File 'lib/escobar/heroku/release.rb', line 5

def build_id
  @build_id
end

#clientObject (readonly)

Returns the value of attribute client.



5
6
7
# File 'lib/escobar/heroku/release.rb', line 5

def client
  @client
end

#command_idObject

Returns the value of attribute command_id.



7
8
9
# File 'lib/escobar/heroku/release.rb', line 7

def command_id
  @command_id
end

#github_urlObject

Returns the value of attribute github_url.



8
9
10
# File 'lib/escobar/heroku/release.rb', line 8

def github_url
  @github_url
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/escobar/heroku/release.rb', line 5

def id
  @id
end

#pipeline_nameObject

Returns the value of attribute pipeline_name.



9
10
11
# File 'lib/escobar/heroku/release.rb', line 9

def pipeline_name
  @pipeline_name
end

#shaObject

Returns the value of attribute sha.



10
11
12
# File 'lib/escobar/heroku/release.rb', line 10

def sha
  @sha
end

Instance Method Details

#appObject



23
24
25
# File 'lib/escobar/heroku/release.rb', line 23

def app
  @app ||= Escobar::Heroku::App.new(client, app_id)
end

#buildObject



27
28
29
# File 'lib/escobar/heroku/release.rb', line 27

def build
  @build ||= Escobar::Heroku::Build.new(client, app.id, build_id)
end

#dashboard_release_output_urlObject



39
40
41
# File 'lib/escobar/heroku/release.rb', line 39

def dashboard_release_output_url
  "https://dashboard.heroku.com/apps/#{app.name}/activity/releases/#{id}"
end

#infoObject



19
20
21
# File 'lib/escobar/heroku/release.rb', line 19

def info
  @info ||= client.heroku.get("/apps/#{app_id}/releases/#{id}")
end

#refObject



35
36
37
# File 'lib/escobar/heroku/release.rb', line 35

def ref
  slug && slug.ref
end

#repositoryObject



43
44
45
# File 'lib/escobar/heroku/release.rb', line 43

def repository
  github_url && github_url.match(Escobar::GitHub::REPOSITORY_REGEX)[1]
end

#slugObject



31
32
33
# File 'lib/escobar/heroku/release.rb', line 31

def slug
  @slug ||= Escobar::Heroku::Slug.new(client, app.id, info["slug"]["id"])
end

#statusObject



47
48
49
# File 'lib/escobar/heroku/release.rb', line 47

def status
  info["status"]
end

#to_job_jsonObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/escobar/heroku/release.rb', line 51

def to_job_json
  {
    sha: sha,
    name: pipeline_name,
    repo: repository,
    app_id: app_id,
    app_name: app.name,
    build_id: build_id,
    release_id: id,
    command_id: command_id,
    target_url: dashboard_release_output_url,
    deployment_url: github_url
  }
end