Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
geemus committed Nov 21, 2011
0 parents commit 9a1aa8e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Heroku status

Displays current status of the Heroku platform.

## Installation

$ heroku plugins:install git://github.com/geemus/heroku-status.git

## Usage

To use simply call:

$ heroku status
2 changes: 2 additions & 0 deletions init.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require 'heroku/command/base'
require 'commands/status'
45 changes: 45 additions & 0 deletions lib/commands/status.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# display status of Heroku
#
class Heroku::Command::Status < Heroku::Command::Base

# status
#
# display current status of Heroku platform
#
def index
uri = URI.parse('https://status.heroku.com/status.json')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(uri.request_uri)

response = http.request(request)
status = json_decode(response.body)

display('')
if status.values.all? {|value| value == 'green'}
display(" All Systems Go: No known issues at this time.")
else
status.each do |key, value|
display(" #{key}: #{value}")
end
uri = URI.parse('https://status.heroku.com/feed')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(uri.request_uri)

response = http.request(request)
entries = REXML::Document.new(response.body).elements.to_a("//entry")
entry = entries.first
display('')
display(' ' + entry.elements['title'].text)
display(' ' + entry.elements['content'].text.gsub(/\n\n/, "\n ").gsub(/<[^>]*>/, ''))
end
display('')

end

end

0 comments on commit 9a1aa8e

Please sign in to comment.