Class: Escobar::Client

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

Overview

Top-level client for heroku

Defined Under Namespace

Modules: Error Classes: HTTPError, TimeoutError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(github_token, heroku_token) ⇒ Client

Returns a new instance of Client.



62
63
64
65
# File 'lib/escobar/client.rb', line 62

def initialize(github_token, heroku_token)
  @github_token = github_token
  @heroku = Escobar::Heroku::Client.new(heroku_token)
end

Instance Attribute Details

#github_tokenObject (readonly)

Returns the value of attribute github_token.



61
62
63
# File 'lib/escobar/client.rb', line 61

def github_token
  @github_token
end

#herokuObject (readonly)

Returns the value of attribute heroku.



61
62
63
# File 'lib/escobar/client.rb', line 61

def heroku
  @heroku
end

Class Method Details

.from_environmentObject



57
58
59
# File 'lib/escobar/client.rb', line 57

def self.from_environment
  new(Escobar.github_api_token, Escobar.heroku_api_token)
end

Instance Method Details

#[](key) ⇒ Object



74
75
76
# File 'lib/escobar/client.rb', line 74

def [](key)
  pipelines.find { |pipeline| pipeline.name == key }
end

#app_namesObject



78
79
80
# File 'lib/escobar/client.rb', line 78

def app_names
  pipelines.map(&:name)
end

#inspectObject

mask password



68
69
70
71
72
# File 'lib/escobar/client.rb', line 68

def inspect
  inspected = super
  inspected = inspected.gsub! @github_token, "*******" if @github_token
  inspected
end

#pipelinesObject



82
83
84
85
86
# File 'lib/escobar/client.rb', line 82

def pipelines
  @pipelines ||= heroku.get("/pipelines").map do |pipe|
    Escobar::Heroku::Pipeline.new(self, pipe["id"], pipe["name"])
  end
end