github_status 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/bin/github_status.rb CHANGED
@@ -23,6 +23,11 @@ module StatusParser
23
23
  statuses = GithubStatus::Status.messages
24
24
  StatusPresenter.print(statuses)
25
25
  end
26
+
27
+ opts.on('-c', '--current', 'Show the current status') do
28
+ status = GithubStatus::Status.current
29
+ StatusPresenter.print([status])
30
+ end
26
31
  end
27
32
 
28
33
  parser.parse!
@@ -13,6 +13,13 @@ module GithubStatus
13
13
  @created_on = DateTime.parse(options[:created_on])
14
14
  end
15
15
 
16
+ def self.current
17
+ response = GithubStatus::API.current_status
18
+ response[:created_on] = response[:last_updated]
19
+ response[:body] = ''
20
+ new(response)
21
+ end
22
+
16
23
  def self.last_message
17
24
  new(GithubStatus::API.last_message)
18
25
  end
@@ -1,5 +1,5 @@
1
1
  module GithubStatus
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
 
4
4
  AUTHORS = [
5
5
  "Murray Summers"
data/spec/api_spec.rb CHANGED
@@ -40,6 +40,40 @@ describe GithubStatus::API do
40
40
  end
41
41
  end
42
42
 
43
+ describe "#current_status" do
44
+ before do
45
+ @expected_response = {
46
+ status: "good",
47
+ last_updated: Time.now.to_s
48
+ }
49
+
50
+ @stub_request = stub_request(:get, "https://status.github.com/api/status.json")
51
+ @stub_request.to_return(body: JSON.generate(@expected_response))
52
+
53
+ @actual_response = GithubStatus::API.current_status
54
+ end
55
+
56
+ describe "request" do
57
+ it "should have been requested" do
58
+ @stub_request.should have_been_requested
59
+ end
60
+
61
+ it "should have requested status.json" do
62
+ @stub_request.should have_requested(:get, "https://status.github.com/api/status.json")
63
+ end
64
+ end
65
+
66
+ describe "response" do
67
+ it "should have responded with a status" do
68
+ @actual_response[:status].should == @expected_response[:status]
69
+ end
70
+
71
+ it "should have responded with a last updated date" do
72
+ @actual_response[:last_updated].should == @expected_response[:last_updated]
73
+ end
74
+ end
75
+ end
76
+
43
77
  describe "#last_message" do
44
78
  before do
45
79
  @expected_response = {
data/spec/status_spec.rb CHANGED
@@ -107,6 +107,29 @@ describe GithubStatus::Status do
107
107
  end
108
108
  end
109
109
 
110
+ describe "#current" do
111
+ before do
112
+ @options = {
113
+ status: "major",
114
+ last_updated: DateTime.now.to_s
115
+ }
116
+ GithubStatus::API.stub(:current_status) { @options }
117
+ @status_item = GithubStatus::Status.current
118
+ end
119
+
120
+ it 'should initialise the status' do
121
+ @status_item.status.should == @options[:status]
122
+ end
123
+
124
+ it 'should initialise an empty message' do
125
+ @status_item.message.should == ''
126
+ end
127
+
128
+ it 'should initialise the created on from the last updated' do
129
+ @status_item.created_on.to_s.should == @options[:last_updated]
130
+ end
131
+ end
132
+
110
133
  describe "#last_message" do
111
134
  before do
112
135
  @options = {
data/spec/version_spec.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "#{GithubStatus::Status} version information" do
4
- it "should be version 0.0.2" do
5
- GithubStatus::VERSION.should == "0.0.2"
4
+ it "should be version 0.0.3" do
5
+ GithubStatus::VERSION.should == "0.0.3"
6
6
  end
7
7
 
8
8
  it "should have authors" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github_status
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-03 00:00:00.000000000 Z
12
+ date: 2013-09-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json