Class: Blend::Status::Environment
- Defined in:
- lib/blend/status/environment.rb
Instance Attribute Summary collapse
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#project ⇒ Object
Returns the value of attribute project.
-
#server ⇒ Object
Returns the value of attribute server.
Instance Method Summary collapse
- #app_monitoring ⇒ Object
- #backups ⇒ Object
- #check(key, method) ⇒ Object
- #client ⇒ Object
- #database ⇒ Object
- #deployhooks ⇒ Object
- #domains ⇒ Object
- #dyno_redundancy ⇒ Object
- #exception_handling ⇒ Object
-
#initialize(project, server, environment) ⇒ Environment
constructor
A new instance of Environment.
- #log_monitoring ⇒ Object
- #resolve_deployhooks ⇒ Object
- #ssl ⇒ Object
- #stack ⇒ Object
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
#environment ⇒ Object
Returns the value of attribute environment.
4 5 6 |
# File 'lib/blend/status/environment.rb', line 4 def environment @environment end |
#project ⇒ Object
Returns the value of attribute project.
4 5 6 |
# File 'lib/blend/status/environment.rb', line 4 def project @project end |
#server ⇒ Object
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_monitoring ⇒ Object
54 55 56 |
# File 'lib/blend/status/environment.rb', line 54 def app_monitoring client.addons(@server, /(relic)/) end |
#backups ⇒ Object
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 |
#client ⇒ Object
46 47 48 |
# File 'lib/blend/status/environment.rb', line 46 def client Blend::Client.heroku_client end |
#database ⇒ Object
81 82 83 |
# File 'lib/blend/status/environment.rb', line 81 def database client.databases(@server).collect { |x| x[:plan] } end |
#deployhooks ⇒ Object
62 63 64 |
# File 'lib/blend/status/environment.rb', line 62 def deployhooks client.addons(@server, /deployhooks/) end |
#domains ⇒ Object
93 94 95 |
# File 'lib/blend/status/environment.rb', line 93 def domains client.nonheroku_domains( @server ) end |
#dyno_redundancy ⇒ Object
85 86 87 |
# File 'lib/blend/status/environment.rb', line 85 def dyno_redundancy client.dynos(@server).to_i end |
#exception_handling ⇒ Object
58 59 60 |
# File 'lib/blend/status/environment.rb', line 58 def exception_handling client.addons(@server, /(airbrake|exceptional)/) end |
#log_monitoring ⇒ Object
50 51 52 |
# File 'lib/blend/status/environment.rb', line 50 def log_monitoring client.addons(@server, /(logentries|keen|papertrail|loggly|flydata)/) end |
#resolve_deployhooks ⇒ Object
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. @project.config['hipchat_room'], "Heroku app: #{@server} commit hook now added" end |
#ssl ⇒ Object
73 74 75 |
# File 'lib/blend/status/environment.rb', line 73 def ssl client.addons(@server, /ssl/) end |
#stack ⇒ Object
89 90 91 |
# File 'lib/blend/status/environment.rb', line 89 def stack client.stack( @server ) == 'cedar' end |