github_status 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -25,7 +25,7 @@ Firstly, the library can be used to wrap the whole of the Github Status API into
25
25
  ```
26
26
  require 'github_status'
27
27
 
28
- Github::Status.last_message
28
+ GithubStatus::Status.last_message
29
29
  => #<GithubStatus::Status @created_on="2013-01-08T23:13:55Z", @message="Error Message ...",@status="minor">
30
30
 
31
31
  GithubStatus::Status.messages
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'github_status'
4
+ require 'optparse'
5
+
6
+ module StatusPresenter
7
+ def self.print(statuses)
8
+ statuses.each { |s| puts "#{s.created_on.strftime('%F %H:%M')} #{s.status.capitalize} \"#{s.message}\"" }
9
+ end
10
+ end
11
+
12
+ module StatusParser
13
+ def self.parse!
14
+ parser = OptionParser.new do |opts|
15
+ opts.banner = "Usage: github_status [options]"
16
+
17
+ opts.on('-l', '--last', 'List the last message') do
18
+ status = GithubStatus::Status.last_message
19
+ StatusPresenter.print([status])
20
+ end
21
+
22
+ opts.on('-m', '--messages', 'List all the messages') do
23
+ statuses = GithubStatus::Status.messages
24
+ StatusPresenter.print(statuses)
25
+ end
26
+ end
27
+
28
+ parser.parse!
29
+ end
30
+ end
31
+
32
+ StatusParser.parse!
@@ -10,7 +10,7 @@ module GithubStatus
10
10
  def initialize(options)
11
11
  @status = options[:status]
12
12
  @message = options[:body]
13
- @created_on = options[:created_on]
13
+ @created_on = DateTime.parse(options[:created_on])
14
14
  end
15
15
 
16
16
  def self.last_message
@@ -1,5 +1,5 @@
1
1
  module GithubStatus
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
 
4
4
  AUTHORS = [
5
5
  "Murray Summers"
data/lib/github_status.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'net/https'
2
2
  require 'uri'
3
3
  require 'json'
4
+ require 'date'
4
5
 
5
6
  module GithubStatus
6
7
  require "github_status/version"
data/spec/status_spec.rb CHANGED
@@ -20,7 +20,7 @@ describe GithubStatus::Status do
20
20
  @options = {
21
21
  status: "good",
22
22
  body: "some status message",
23
- created_on: Time.now
23
+ created_on: DateTime.now.to_s
24
24
  }
25
25
  @status_item = GithubStatus::Status.new(@options)
26
26
  end
@@ -34,7 +34,7 @@ describe GithubStatus::Status do
34
34
  end
35
35
 
36
36
  it 'should initialise the created on' do
37
- @status_item.created_on.should == @options[:created_on]
37
+ @status_item.created_on.to_s.should == @options[:created_on]
38
38
  end
39
39
  end
40
40
 
@@ -43,7 +43,7 @@ describe GithubStatus::Status do
43
43
  @options = {
44
44
  status: "good",
45
45
  body: "some status message",
46
- created_on: Time.now
46
+ created_on: DateTime.now.to_s
47
47
  }
48
48
  @status_item = GithubStatus::Status.new(@options)
49
49
  end
@@ -66,7 +66,7 @@ describe GithubStatus::Status do
66
66
  @options = {
67
67
  status: "major",
68
68
  body: "some status message",
69
- created_on: Time.now
69
+ created_on: DateTime.now.to_s
70
70
  }
71
71
  @status_item = GithubStatus::Status.new(@options)
72
72
  end
@@ -89,7 +89,7 @@ describe GithubStatus::Status do
89
89
  @options = {
90
90
  status: "minor",
91
91
  body: "some status message",
92
- created_on: Time.now
92
+ created_on: DateTime.now.to_s
93
93
  }
94
94
  @status_item = GithubStatus::Status.new(@options)
95
95
  end
@@ -112,7 +112,7 @@ describe GithubStatus::Status do
112
112
  @options = {
113
113
  status: "major",
114
114
  body: "some status message",
115
- created_on: Time.now
115
+ created_on: DateTime.now.to_s
116
116
  }
117
117
  GithubStatus::API.stub(:last_message) { @options }
118
118
  @status_item = GithubStatus::Status.last_message
@@ -127,7 +127,7 @@ describe GithubStatus::Status do
127
127
  end
128
128
 
129
129
  it 'should initialise the created on' do
130
- @status_item.created_on.should == @options[:created_on]
130
+ @status_item.created_on.to_s.should == @options[:created_on]
131
131
  end
132
132
  end
133
133
 
@@ -136,12 +136,12 @@ describe GithubStatus::Status do
136
136
  @status_options_1 = {
137
137
  status: "major",
138
138
  body: "some major status message",
139
- created_on: Time.now
139
+ created_on: DateTime.now.to_s
140
140
  }
141
141
  @status_options_2 = {
142
142
  status: "minor",
143
143
  body: "some minor status message",
144
- created_on: Time.now
144
+ created_on: DateTime.now.to_s
145
145
  }
146
146
  @options = [@status_options_1, @status_options_2]
147
147
  GithubStatus::API.stub(:messages) { @options }
@@ -162,7 +162,7 @@ describe GithubStatus::Status do
162
162
  end
163
163
 
164
164
  it 'should initialise the created on' do
165
- @status_items[0].created_on.should == @status_options_1[:created_on]
165
+ @status_items[0].created_on.to_s.should == @status_options_1[:created_on]
166
166
  end
167
167
  end
168
168
 
@@ -176,7 +176,7 @@ describe GithubStatus::Status do
176
176
  end
177
177
 
178
178
  it 'should initialise the created on' do
179
- @status_items[1].created_on.should == @status_options_2[:created_on]
179
+ @status_items[1].created_on.to_s.should == @status_options_2[:created_on]
180
180
  end
181
181
  end
182
182
  end
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.1" do
5
- GithubStatus::VERSION.should == "0.0.1"
4
+ it "should be version 0.0.2" do
5
+ GithubStatus::VERSION.should == "0.0.2"
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.1
4
+ version: 0.0.2
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-01-26 00:00:00.000000000 Z
12
+ date: 2013-03-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -62,7 +62,8 @@ dependencies:
62
62
  description: Provides a Ruby Library that allows the Github Status API to be queried.
63
63
  email:
64
64
  - murray.sum@gmail.com
65
- executables: []
65
+ executables:
66
+ - github_status.rb
66
67
  extensions: []
67
68
  extra_rdoc_files: []
68
69
  files:
@@ -71,6 +72,7 @@ files:
71
72
  - LICENSE.txt
72
73
  - README.md
73
74
  - Rakefile
75
+ - bin/github_status.rb
74
76
  - github_status.gemspec
75
77
  - lib/github_status.rb
76
78
  - lib/github_status/api.rb