Class: GithubStatus::API
- Inherits:
-
Object
- Object
- GithubStatus::API
- Defined in:
- lib/github_status/api.rb
Constant Summary collapse
- API_URL =
"https://status.github.com/api.json"- STATUS_URL =
"https://status.github.com/api/status.json"- LAST_MESSAGE_URL =
"https://status.github.com/api/last-message.json"- MESSAGES_URL =
"https://status.github.com/api/messages.json"
Class Method Summary collapse
- .api ⇒ Object
- .current_status ⇒ Object
- .get(uri) ⇒ Object
- .last_message ⇒ Object
- .messages ⇒ Object
- .prepare_response(response) ⇒ Object
- .prepare_uri(uri) ⇒ Object
Class Method Details
.api ⇒ Object
11 12 13 |
# File 'lib/github_status/api.rb', line 11 def self.api get(API_URL) end |
.current_status ⇒ Object
15 16 17 |
# File 'lib/github_status/api.rb', line 15 def self.current_status get(STATUS_URL) end |
.get(uri) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/github_status/api.rb', line 29 def self.get(uri) uri = prepare_uri(uri) response = Net::HTTP.start(uri.host, use_ssl: true) do |http| request = Net::HTTP::Get.new(uri.request_uri) http.request(request) end prepare_response(response) end |
.last_message ⇒ Object
19 20 21 |
# File 'lib/github_status/api.rb', line 19 def self. get(LAST_MESSAGE_URL) end |
.messages ⇒ Object
23 24 25 |
# File 'lib/github_status/api.rb', line 23 def self. get(MESSAGES_URL) end |
.prepare_response(response) ⇒ Object
44 45 46 |
# File 'lib/github_status/api.rb', line 44 def self.prepare_response(response) JSON.parse(response.body, symbolize_names: true) end |
.prepare_uri(uri) ⇒ Object
40 41 42 |
# File 'lib/github_status/api.rb', line 40 def self.prepare_uri(uri) URI.parse(uri) end |