Class: Blend::Status::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/blend/status/environment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, server, environment) ⇒ Environment

Returns a new instance of Environment.



6
7
8
9
10
# File 'lib/blend/status/environment.rb', line 6

def initialize( project, server, environment )
  @project = project
  @server = server
  @environment = environment
end

Instance Attribute Details

#environmentObject

Returns the value of attribute environment.



4
5
6
# File 'lib/blend/status/environment.rb', line 4

def environment
  @environment
end

#projectObject

Returns the value of attribute project.



4
5
6
# File 'lib/blend/status/environment.rb', line 4

def project
  @project
end

#serverObject

Returns the value of attribute server.



4
5
6
# File 'lib/blend/status/environment.rb', line 4

def server
  @server
end

Instance Method Details

#app_monitoringObject



54
55
56
# File 'lib/blend/status/environment.rb', line 54

def app_monitoring
  client.addons(@server, /(relic)/)
end

#backupsObject



77
78
79
# File 'lib/blend/status/environment.rb', line 77

def backups
  client.backups(@server).collect { |x| x[:plan] }
end

#check(key, method) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/blend/status/environment.rb', line 12

def check key, method
  ret = __send__( method )
  ret = false if ret.nil?
  ret = false if ret == []
  ret = ret.collect do |x|
    if( x.is_a? Hash )
      x[:name] || x['name']
    else
      x
    end
  end.join( "," ) if ret.is_a? Array

  pass = ret

  if( ret.is_a? Integer )
    if( method == :dyno_redundancy)
      pass = ret > 1
      ret = "#{ret} dynos"
    end
  end

  printf "%20s: ", key
  if( pass )
    printf "\u2713 #{ret}\n".encode('utf-8').green
  else
    printf "\u2718 #{ret}\n".encode('utf-8').red
    if( @project.resolve )
      r = "resolve_#{method}".to_sym
      __send__(r) if respond_to? r
    end

  end
end

#clientObject



46
47
48
# File 'lib/blend/status/environment.rb', line 46

def client
  Blend::Client.heroku_client
end

#databaseObject



81
82
83
# File 'lib/blend/status/environment.rb', line 81

def database
  client.databases(@server).collect { |x| x[:plan] }
end

#deployhooksObject



62
63
64
# File 'lib/blend/status/environment.rb', line 62

def deployhooks
  client.addons(@server, /deployhooks/)
end

#domainsObject



93
94
95
# File 'lib/blend/status/environment.rb', line 93

def domains
  client.nonheroku_domains( @server )
end

#dyno_redundancyObject



85
86
87
# File 'lib/blend/status/environment.rb', line 85

def dyno_redundancy
  client.dynos(@server).to_i
end

#exception_handlingObject



58
59
60
# File 'lib/blend/status/environment.rb', line 58

def exception_handling
  client.addons(@server, /(airbrake|exceptional)/)
end

#log_monitoringObject



50
51
52
# File 'lib/blend/status/environment.rb', line 50

def log_monitoring
  client.addons(@server, /(logentries|keen|papertrail|loggly|flydata)/)
end

#resolve_deployhooksObject



66
67
68
69
70
71
# File 'lib/blend/status/environment.rb', line 66

def resolve_deployhooks
  system( "echo heroku addons:add deployhooks:hipchat --auth_token=#{@project.juice_client.hipchat_api} --room=\"#{@project.config['hipchat_room']}\" --app #{@server}")
  system( "heroku addons:add deployhooks:hipchat --auth_token=#{@project.juice_client.hipchat_api} --room=\"#{@project.config['hipchat_room']}\" --app #{@server}" )
  Blend::Client::hipchat_client.post_message @project.config['hipchat_room'], "Heroku app: #{@server} commit hook now added"

end

#sslObject



73
74
75
# File 'lib/blend/status/environment.rb', line 73

def ssl
  client.addons(@server, /ssl/)
end

#stackObject



89
90
91
# File 'lib/blend/status/environment.rb', line 89

def stack
  client.stack( @server ) == 'cedar'
end