Class: Blend::Client::HerokuClient

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ HerokuClient

Returns a new instance of HerokuClient.



9
10
11
12
# File 'lib/blend/client/heroku_client.rb', line 9

def initialize( client )
  @client = client
  @addons = {}
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



7
8
9
# File 'lib/blend/client/heroku_client.rb', line 7

def client
  @client
end

Instance Method Details

#addon_matches(app, addon_name) ⇒ Object



42
43
44
# File 'lib/blend/client/heroku_client.rb', line 42

def addon_matches( app, addon_name )
  addons(app).select{|x| x[:name] =~ addon_name}
end

#addon_names(app, filter) ⇒ Object



35
36
37
38
39
40
# File 'lib/blend/client/heroku_client.rb', line 35

def addon_names( app, filter )
  addons(app, filter).collect do |addon|
   name,plan = addon['name'].split(/:/)
   {name: name, plan: plan}
  end
end

#addons(app, filter = nil) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/blend/client/heroku_client.rb', line 26

def addons( app, filter=nil )
  @addons[app] ||= client.get_addons(app).body
  if filter.nil?
    @addons[app]
  else
    @addons[app].select{|x| x['name'] =~ filter}
  end
end

#backups(app) ⇒ Object



54
55
56
# File 'lib/blend/client/heroku_client.rb', line 54

def backups( app )
  addon_names(app, /pgbackups/)
end

#databases(app) ⇒ Object



58
59
60
# File 'lib/blend/client/heroku_client.rb', line 58

def databases( app )
  addon_names(app, /postgresq/)
end

#domains(app) ⇒ Object



18
19
20
# File 'lib/blend/client/heroku_client.rb', line 18

def domains( app ) 
  client.get_domains(app).body
end

#dynos(app) ⇒ Object



50
51
52
# File 'lib/blend/client/heroku_client.rb', line 50

def dynos( app )
  info(app)['dynos']
end

#info(app) ⇒ Object



14
15
16
# File 'lib/blend/client/heroku_client.rb', line 14

def info( app )
  client.get_app(app).body
end

#nonheroku_domains(app) ⇒ Object



22
23
24
# File 'lib/blend/client/heroku_client.rb', line 22

def nonheroku_domains( app )
  domains(app).reject{|x| x['base_domain']=="herokuapp.com" || x['domain'] =~ /^www/}.collect{|x| x['domain']}
end

#run_domain_checker(app) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/blend/client/heroku_client.rb', line 62

def run_domain_checker( app )
  results = {}
  nonheroku_domains(app).map{|x| x['domain']}.each do |d|


    DomainChecker.check(d)

    result = {}
    results[d] = result

    # Check registered
    result[:registered] = dc.registered?

    # Check registrar
    result[:registrar] = dc.registrar

    result[:ssl] = dc.ssl
  end

  results

end

#stack(app) ⇒ Object



46
47
48
# File 'lib/blend/client/heroku_client.rb', line 46

def stack(app)
  info(app)['stack']
end