Class: Escobar::Heroku::Build

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

Overview

Class representing a heroku build

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, app_id, id) ⇒ Build

Returns a new instance of Build.



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

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

Instance Attribute Details

#app_idObject (readonly)

Returns the value of attribute app_id.



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

def app_id
  @app_id
end

#clientObject (readonly)

Returns the value of attribute client.



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

def client
  @client
end

#command_idObject

Returns the value of attribute command_id.



7
8
9
# File 'lib/escobar/heroku/build.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/build.rb', line 8

def github_url
  @github_url
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#pipeline_nameObject

Returns the value of attribute pipeline_name.



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

def pipeline_name
  @pipeline_name
end

#shaObject

Returns the value of attribute sha.



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

def sha
  @sha
end

Instance Method Details

#appObject



34
35
36
# File 'lib/escobar/heroku/build.rb', line 34

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

#dashboard_build_output_urlObject



38
39
40
# File 'lib/escobar/heroku/build.rb', line 38

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

#infoObject



18
19
20
# File 'lib/escobar/heroku/build.rb', line 18

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

#release_idObject



30
31
32
# File 'lib/escobar/heroku/build.rb', line 30

def release_id
  info["release"]["id"]
end

#releasing?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/escobar/heroku/build.rb', line 26

def releasing?
  status == "succeeded" && !release_id.nil?
end

#repositoryObject



42
43
44
# File 'lib/escobar/heroku/build.rb', line 42

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

#statusObject



22
23
24
# File 'lib/escobar/heroku/build.rb', line 22

def status
  info["status"]
end

#to_job_jsonObject



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/escobar/heroku/build.rb', line 46

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