relevance-github_hook 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -1,4 +1,6 @@
1
- v0.0.6. Update for latest Github json spec; maintain backwards compatibility to avoid breaking stuff
1
+ v0.6.2. Capture private flag and parse it to boolean from string
2
+
3
+ v0.6.0. Update for latest Github json spec; maintain backwards compatibility to avoid breaking stuff
2
4
 
3
5
  v0.5.8. Prep for release
4
6
 
data/github_hook.gemspec CHANGED
@@ -1,10 +1,10 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{github_hook}
3
- s.version = "0.6.0"
3
+ s.version = "0.6.2"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new("= 1.2") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Rob Sanheim"]
7
- s.date = %q{2008-08-05}
7
+ s.date = %q{2008-09-02}
8
8
  s.description = %q{Wrapper around the github post receive JSON payload.}
9
9
  s.email = %q{opensource@thinkrelevance.com}
10
10
  s.extra_rdoc_files = ["CHANGELOG", "lib/github_hook.rb", "README.txt"]
data/lib/github_hook.rb CHANGED
@@ -3,17 +3,22 @@ require 'json'
3
3
  require 'ostruct'
4
4
 
5
5
  class GithubHook
6
- VERSION = '0.6.0'
6
+ VERSION = '0.6.2'
7
7
  attr_reader :before, :after, :ref, :repository, :owner, :commits
8
8
 
9
9
  def initialize(json)
10
10
  payload = JSON.parse(json)
11
11
  @before, @after, @ref = payload["before"], payload["after"], payload["ref"]
12
12
  @repository = OpenStruct.new(payload["repository"])
13
+ @repository.private = parse_private_flag(@repository.private)
13
14
  @owner = OpenStruct.new(payload["repository"]["owner"])
14
15
  @commits = create_commits(payload)
15
16
  end
16
17
 
18
+ def parse_private_flag(private_flag)
19
+ private_flag == "true" ? true : false
20
+ end
21
+
17
22
  def create_commits(payload)
18
23
  payload['commits'].map do |hash|
19
24
  commit_ostruct = OpenStruct.new(hash)
@@ -58,7 +58,11 @@ describe GithubHook do
58
58
  commits[0].sha.should == "41a212ee83ca127e3c8cf465891ab7216a705f59"
59
59
  commits[1].sha.should == "de8251ff97ee194a289832576287d6f8ad74e3d0"
60
60
  end
61
-
61
+
62
+ it "is not private if private flag is false" do
63
+ @pc.repository.private.should == false
64
+ end
65
+
62
66
  it "has commit values" do
63
67
  commit = @pc.commits.first
64
68
  commit.url.should == "http://github.com/defunkt/github/commit/41a212ee83ca127e3c8cf465891ab7216a705f59"
@@ -78,5 +82,16 @@ describe GithubHook do
78
82
 
79
83
  end
80
84
 
85
+ describe "private project" do
86
+ before { @pc = GithubHook.new(PrivateProject)}
87
+
88
+ it "is private if private flag is false" do
89
+ @pc.repository.private.should == true
90
+ end
91
+
92
+ end
93
+
94
+
95
+
81
96
  end
82
97
 
data/spec/payload.rb CHANGED
@@ -40,6 +40,7 @@ PayloadAfterJuly30 = <<-EOL
40
40
  "repository": {
41
41
  "url": "http://github.com/defunkt/github",
42
42
  "name": "github",
43
+ "private": "false",
43
44
  "owner": {
44
45
  "email": "chris@ozmm.org",
45
46
  "name": "defunkt"
@@ -71,4 +72,124 @@ PayloadAfterJuly30 = <<-EOL
71
72
  "after": "de8251ff97ee194a289832576287d6f8ad74e3d0",
72
73
  "ref": "refs/heads/master"
73
74
  }
75
+ EOL
76
+
77
+ PrivateProject = <<-EOL
78
+ {
79
+ "before": "5aef35982fb2d34e9d9d4502f6ede1072793222d",
80
+ "repository": {
81
+ "url": "http://github.com/defunkt/github",
82
+ "name": "github",
83
+ "private": "true",
84
+ "owner": {
85
+ "email": "chris@ozmm.org",
86
+ "name": "defunkt"
87
+ }
88
+ },
89
+ "commits": [
90
+ {
91
+ "id": "41a212ee83ca127e3c8cf465891ab7216a705f59",
92
+ "url": "http://github.com/defunkt/github/commit/41a212ee83ca127e3c8cf465891ab7216a705f59",
93
+ "author": {
94
+ "email": "chris@ozmm.org",
95
+ "name": "Chris Wanstrath"
96
+ },
97
+ "message": "okay i give in",
98
+ "timestamp": "2008-02-15T14:57:17-08:00",
99
+ "added": ["filepath.rb"]
100
+ },
101
+ {
102
+ "id": "de8251ff97ee194a289832576287d6f8ad74e3d0",
103
+ "url": "http://github.com/defunkt/github/commit/de8251ff97ee194a289832576287d6f8ad74e3d0",
104
+ "author": {
105
+ "email": "chris@ozmm.org",
106
+ "name": "Chris Wanstrath"
107
+ },
108
+ "message": "update pricing a tad",
109
+ "timestamp": "2008-02-15T14:36:34-08:00"
110
+ }
111
+ ],
112
+ "after": "de8251ff97ee194a289832576287d6f8ad74e3d0",
113
+ "ref": "refs/heads/master"
114
+ }
115
+ EOL
116
+
117
+ FiveRunsPayLoad = <<-EOL
118
+ {
119
+ "repository": {
120
+ "name": "brigit",
121
+ "watchers": 9,
122
+ "private": false,
123
+ "url": "http:\/\/github.com\/fiveruns\/brigit",
124
+ "description": "Git utilities for multiple repositories & submodules",
125
+ "forks": 1,
126
+ "homepage": "http:\/\/fiveruns.org",
127
+ "owner": {
128
+ "name": "fiveruns",
129
+ "email": "dev@fiveruns.com"
130
+ }
131
+ },
132
+ "commits": [
133
+ {
134
+ "added": [
135
+
136
+ ],
137
+ "message": "Note that the echoe gem is required to use the Rakefile.",
138
+ "timestamp": "2008-08-07T02:32:03-07:00",
139
+ "removed": [
140
+
141
+ ],
142
+ "modified": [
143
+ "README.rdoc"
144
+ ],
145
+ "author": {
146
+ "name": "Graeme Mathieson",
147
+ "email": "mathie@woss.name"
148
+ },
149
+ "url": "http:\/\/github.com\/fiveruns\/brigit\/commit\/bb7aebb382539bbd3e7a6118fc37438730c9ade5",
150
+ "id": "bb7aebb382539bbd3e7a6118fc37438730c9ade5"
151
+ },
152
+ {
153
+ "added": [
154
+
155
+ ],
156
+ "message": "Ignore the generated packages.",
157
+ "timestamp": "2008-08-07T02:32:32-07:00",
158
+ "removed": [
159
+
160
+ ],
161
+ "modified": [
162
+ ".gitignore"
163
+ ],
164
+ "author": {
165
+ "name": "Graeme Mathieson",
166
+ "email": "mathie@woss.name"
167
+ },
168
+ "url": "http:\/\/github.com\/fiveruns\/brigit\/commit\/093560ad918d58f3864507f19462fd7c04f34eac",
169
+ "id": "093560ad918d58f3864507f19462fd7c04f34eac"
170
+ },
171
+ {
172
+ "added": [
173
+
174
+ ],
175
+ "message": "Show help if no command line arguments are supplied.",
176
+ "timestamp": "2008-08-07T02:36:32-07:00",
177
+ "removed": [
178
+
179
+ ],
180
+ "modified": [
181
+ "lib\/brigit\/cli.rb"
182
+ ],
183
+ "author": {
184
+ "name": "Graeme Mathieson",
185
+ "email": "mathie@woss.name"
186
+ },
187
+ "url": "http:\/\/github.com\/fiveruns\/brigit\/commit\/38b95d0c48fff2a4c233a834e42724744a42bf0a",
188
+ "id": "38b95d0c48fff2a4c233a834e42724744a42bf0a"
189
+ }
190
+ ],
191
+ "after": "38b95d0c48fff2a4c233a834e42724744a42bf0a",
192
+ "ref": "refs\/heads\/master",
193
+ "before": "42f6a49633a985e5cd6dc2cebec15c3401232929"
194
+ }
74
195
  EOL
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relevance-github_hook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Sanheim
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-08-05 00:00:00 -07:00
12
+ date: 2008-09-02 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency