webhook-payload 1.1.0 → 2.0.0
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/lib/webhook/payload.rb +30 -1
- data/lib/webhook/payload/version.rb +1 -1
- data/spec/webhook/payload_spec.rb +118 -7
- data/webhook-payload.gemspec +1 -1
- metadata +11 -11
data/lib/webhook/payload.rb
CHANGED
@@ -30,6 +30,11 @@ module Webhook
|
|
30
30
|
|
31
31
|
attribute :email, String
|
32
32
|
attribute :name, String
|
33
|
+
attribute :username, String
|
34
|
+
end
|
35
|
+
|
36
|
+
class Pusher
|
37
|
+
include User
|
33
38
|
end
|
34
39
|
|
35
40
|
class URI < Virtus::Attribute::Object
|
@@ -44,12 +49,17 @@ module Webhook
|
|
44
49
|
include User
|
45
50
|
end
|
46
51
|
|
52
|
+
class Committer
|
53
|
+
include User
|
54
|
+
end
|
55
|
+
|
47
56
|
class Pathname < Virtus::Attribute::Object
|
48
57
|
primitive String
|
49
58
|
coercion_method :to_pathname
|
50
59
|
end
|
51
60
|
|
52
61
|
attribute :id, String
|
62
|
+
attribute :distinct, Boolean
|
53
63
|
attribute :url, URI
|
54
64
|
attribute :message, String
|
55
65
|
attribute :timestamp, Time
|
@@ -57,6 +67,7 @@ module Webhook
|
|
57
67
|
attribute :modified, Array[Pathname], :default => []
|
58
68
|
attribute :removed, Array[Pathname], :default => []
|
59
69
|
attribute :author, Author
|
70
|
+
attribute :committer, Committer
|
60
71
|
end
|
61
72
|
|
62
73
|
class Repository
|
@@ -66,15 +77,27 @@ module Webhook
|
|
66
77
|
include User
|
67
78
|
end
|
68
79
|
|
80
|
+
attribute :id, Integer
|
69
81
|
attribute :url, URI
|
70
82
|
attribute :name, String
|
71
83
|
attribute :homepage, String
|
72
84
|
attribute :pledgie, String
|
73
85
|
attribute :description, String
|
74
86
|
attribute :watchers, Integer
|
87
|
+
attribute :stargazers, Integer
|
88
|
+
attribute :fork, Boolean
|
75
89
|
attribute :forks, Integer
|
76
90
|
attribute :private, Boolean
|
77
91
|
attribute :owner, Owner
|
92
|
+
attribute :created_at, DateTime
|
93
|
+
attribute :has_downloads, Boolean
|
94
|
+
attribute :has_issues, Boolean
|
95
|
+
attribute :has_wiki, Boolean
|
96
|
+
attribute :language, String
|
97
|
+
attribute :master_branch, String
|
98
|
+
attribute :open_issues, Integer
|
99
|
+
attribute :pushed_at, DateTime
|
100
|
+
attribute :size, Integer
|
78
101
|
end
|
79
102
|
|
80
103
|
attribute :before, String
|
@@ -82,5 +105,11 @@ module Webhook
|
|
82
105
|
attribute :ref, String
|
83
106
|
attribute :repository, Repository
|
84
107
|
attribute :commits, Array[Commit]
|
108
|
+
attribute :compare, URI
|
109
|
+
attribute :created, Boolean
|
110
|
+
attribute :deleted, Boolean
|
111
|
+
attribute :forced, Boolean
|
112
|
+
attribute :head_commit, Commit
|
113
|
+
attribute :pusher, Pusher
|
85
114
|
end
|
86
|
-
end
|
115
|
+
end
|
@@ -19,6 +19,10 @@ describe Webhook::Payload do
|
|
19
19
|
its(:before){should == "5aef35982fb2d34e9d9d4502f6ede1072793222d"}
|
20
20
|
its(:after){should == "de8251ff97ee194a289832576287d6f8ad74e3d0"}
|
21
21
|
its(:ref){should == "refs/heads/master"}
|
22
|
+
its(:compare){should == URI.parse("https://github.com/defunkt/github/compare/5aef35982fb2...de8251ff97ee")}
|
23
|
+
its(:created){should == false}
|
24
|
+
its(:deleted){should == false}
|
25
|
+
its(:forced){should == false}
|
22
26
|
|
23
27
|
it "should have two commits" do
|
24
28
|
subject.commits.size.should == 2
|
@@ -34,14 +38,26 @@ describe Webhook::Payload do
|
|
34
38
|
its(:homepage){should be_nil}
|
35
39
|
its(:description){should == "You're lookin' at it."}
|
36
40
|
its(:watchers){should == 5}
|
41
|
+
its(:stargazers){should == 1}
|
42
|
+
its(:fork){should == true}
|
37
43
|
its(:forks){should == 2}
|
38
44
|
its(:private){should == true}
|
45
|
+
its(:has_downloads){should == true}
|
46
|
+
its(:has_issues){should == true}
|
47
|
+
its(:has_wiki){should == true}
|
48
|
+
its(:language){should == "Ruby"}
|
49
|
+
its(:master_branch){should == "master"}
|
50
|
+
its(:open_issues){should == 12}
|
51
|
+
its(:size){should == 2156}
|
52
|
+
its(:created_at){should == DateTime.new(2012, 3, 28, 23, 36, 8)}
|
53
|
+
its(:pushed_at){should == DateTime.new(2013, 3, 14, 21, 12, 0)}
|
39
54
|
|
40
55
|
describe "#owner" do
|
41
56
|
subject{repository.owner}
|
42
57
|
|
43
58
|
its(:email){should == "chris@ozmm.org"}
|
44
|
-
its(:name){should == "
|
59
|
+
its(:name){should == "Chris Wanstrath"}
|
60
|
+
its(:username){should == "defunkt"}
|
45
61
|
end
|
46
62
|
end
|
47
63
|
|
@@ -50,6 +66,7 @@ describe Webhook::Payload do
|
|
50
66
|
subject{commit}
|
51
67
|
|
52
68
|
its(:id){should == "41a212ee83ca127e3c8cf465891ab7216a705f59"}
|
69
|
+
its(:distinct){should == true}
|
53
70
|
its(:url){should == URI.parse("http://github.com/defunkt/github/commit/41a212ee83ca127e3c8cf465891ab7216a705f59")}
|
54
71
|
its(:message){should == "okay i give in"}
|
55
72
|
its(:timestamp){should == Time.parse("2008-02-15T14:57:17-08:00")}
|
@@ -62,6 +79,50 @@ describe Webhook::Payload do
|
|
62
79
|
|
63
80
|
its(:email){should == "chris@ozmm.org"}
|
64
81
|
its(:name){should == "Chris Wanstrath"}
|
82
|
+
its(:username){should == "defunkt"}
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "#committer" do
|
86
|
+
subject{commit.committer}
|
87
|
+
|
88
|
+
its(:email){should == "chris@ozmm.org"}
|
89
|
+
its(:name){should == "Chris Wanstrath"}
|
90
|
+
its(:username){should == "defunkt"}
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "#pusher" do
|
95
|
+
subject{payload.pusher}
|
96
|
+
|
97
|
+
its(:name){should == "none"}
|
98
|
+
end
|
99
|
+
|
100
|
+
describe "#head_commit" do
|
101
|
+
subject{payload.head_commit}
|
102
|
+
|
103
|
+
its(:id){should == "de8251ff97ee194a289832576287d6f8ad74e3d0"}
|
104
|
+
its(:distinct){should == true}
|
105
|
+
its(:url){should == URI.parse("http://github.com/defunkt/github/commit/de8251ff97ee194a289832576287d6f8ad74e3d0")}
|
106
|
+
its(:message){should == "update pricing a tad"}
|
107
|
+
its(:timestamp){should == Time.parse("2008-02-15T14:36:34-08:00")}
|
108
|
+
its(:added){should == []}
|
109
|
+
its(:removed){should == []}
|
110
|
+
its(:modified){should == []}
|
111
|
+
|
112
|
+
describe "#author" do
|
113
|
+
subject{payload.head_commit.author}
|
114
|
+
|
115
|
+
its(:email){should == "chris@ozmm.org"}
|
116
|
+
its(:name){should == "Chris Wanstrath"}
|
117
|
+
its(:username){should == "defunkt"}
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "#committer" do
|
121
|
+
subject{payload.head_commit.committer}
|
122
|
+
|
123
|
+
its(:email){should == "chris@ozmm.org"}
|
124
|
+
its(:name){should == "Chris Wanstrath"}
|
125
|
+
its(:username){should == "defunkt"}
|
65
126
|
end
|
66
127
|
end
|
67
128
|
|
@@ -73,20 +134,39 @@ describe Webhook::Payload do
|
|
73
134
|
"name" => "github",
|
74
135
|
"description" => "You're lookin' at it.",
|
75
136
|
"watchers" => 5,
|
137
|
+
"stargazers" => 1,
|
138
|
+
"fork" => true,
|
76
139
|
"forks" => 2,
|
77
140
|
"private" => 1,
|
78
141
|
"owner" => {
|
79
142
|
"email" => "chris@ozmm.org",
|
80
|
-
"name" => "
|
81
|
-
|
143
|
+
"name" => "Chris Wanstrath",
|
144
|
+
"username" => "defunkt"
|
145
|
+
},
|
146
|
+
"created_at" => 1332977768,
|
147
|
+
"has_downloads" => true,
|
148
|
+
"has_issues" => true,
|
149
|
+
"has_wiki" => true,
|
150
|
+
"language" => "Ruby",
|
151
|
+
"master_branch" => "master",
|
152
|
+
"open_issues" => 12,
|
153
|
+
"pushed_at" => 1363295520,
|
154
|
+
"size" => 2156
|
82
155
|
},
|
83
156
|
"commits" => [
|
84
157
|
{
|
85
158
|
"id" => "41a212ee83ca127e3c8cf465891ab7216a705f59",
|
159
|
+
"distinct" => true,
|
86
160
|
"url" => "http://github.com/defunkt/github/commit/41a212ee83ca127e3c8cf465891ab7216a705f59",
|
87
161
|
"author" => {
|
88
162
|
"email" => "chris@ozmm.org",
|
89
|
-
"name" => "Chris Wanstrath"
|
163
|
+
"name" => "Chris Wanstrath",
|
164
|
+
"username" => "defunkt"
|
165
|
+
},
|
166
|
+
"committer" => {
|
167
|
+
"email" => "chris@ozmm.org",
|
168
|
+
"name" => "Chris Wanstrath",
|
169
|
+
"username" => "defunkt"
|
90
170
|
},
|
91
171
|
"message" => "okay i give in",
|
92
172
|
"timestamp" => "2008-02-15T14:57:17-08:00",
|
@@ -94,18 +174,49 @@ describe Webhook::Payload do
|
|
94
174
|
},
|
95
175
|
{
|
96
176
|
"id" => "de8251ff97ee194a289832576287d6f8ad74e3d0",
|
177
|
+
"distinct" => true,
|
97
178
|
"url" => "http://github.com/defunkt/github/commit/de8251ff97ee194a289832576287d6f8ad74e3d0",
|
98
179
|
"author" => {
|
99
180
|
"email" => "chris@ozmm.org",
|
100
|
-
"name" => "Chris Wanstrath"
|
181
|
+
"name" => "Chris Wanstrath",
|
182
|
+
"username" => "defunkt"
|
183
|
+
},
|
184
|
+
"committer" => {
|
185
|
+
"email" => "chris@ozmm.org",
|
186
|
+
"name" => "Chris Wanstrath",
|
187
|
+
"username" => "defunkt"
|
101
188
|
},
|
102
189
|
"message" => "update pricing a tad",
|
103
190
|
"timestamp" => "2008-02-15T14:36:34-08:00"
|
104
191
|
}
|
105
192
|
],
|
106
193
|
"after" => "de8251ff97ee194a289832576287d6f8ad74e3d0",
|
107
|
-
"ref" => "refs/heads/master"
|
194
|
+
"ref" => "refs/heads/master",
|
195
|
+
"compare" => "https://github.com/defunkt/github/compare/5aef35982fb2...de8251ff97ee",
|
196
|
+
"created" => false,
|
197
|
+
"deleted" => false,
|
198
|
+
"forced" => false,
|
199
|
+
"head_commit" => {
|
200
|
+
"id" => "de8251ff97ee194a289832576287d6f8ad74e3d0",
|
201
|
+
"distinct" => true,
|
202
|
+
"url" => "http://github.com/defunkt/github/commit/de8251ff97ee194a289832576287d6f8ad74e3d0",
|
203
|
+
"author" => {
|
204
|
+
"email" => "chris@ozmm.org",
|
205
|
+
"name" => "Chris Wanstrath",
|
206
|
+
"username" => "defunkt"
|
207
|
+
},
|
208
|
+
"committer" => {
|
209
|
+
"email" => "chris@ozmm.org",
|
210
|
+
"name" => "Chris Wanstrath",
|
211
|
+
"username" => "defunkt"
|
212
|
+
},
|
213
|
+
"message" => "update pricing a tad",
|
214
|
+
"timestamp" => "2008-02-15T14:36:34-08:00"
|
215
|
+
},
|
216
|
+
"pusher" => {
|
217
|
+
"name" => "none"
|
218
|
+
}
|
108
219
|
}
|
109
220
|
end
|
110
221
|
end
|
111
|
-
end
|
222
|
+
end
|
data/webhook-payload.gemspec
CHANGED
@@ -21,6 +21,6 @@ Gem::Specification.new do |s|
|
|
21
21
|
# specify any dependencies here; for example:
|
22
22
|
s.add_development_dependency "rspec"
|
23
23
|
s.add_development_dependency "rake"
|
24
|
-
s.add_runtime_dependency "virtus"
|
24
|
+
s.add_runtime_dependency "virtus", ">= 0.5.0"
|
25
25
|
s.add_runtime_dependency "multi_json"
|
26
26
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webhook-payload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-07-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70124157666340 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70124157666340
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70124157665880 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,21 +32,21 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70124157665880
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: virtus
|
38
|
-
requirement: &
|
38
|
+
requirement: &70124157665300 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: 0.5.0
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70124157665300
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: multi_json
|
49
|
-
requirement: &
|
49
|
+
requirement: &70124157664840 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70124157664840
|
58
58
|
description: This gem is a convenience wrapper for Github's webhook payload (https://help.github.com/articles/post-receive-hooks)
|
59
59
|
that is triggered from a post receive hook. Feed it a hash of data and it will parse
|
60
60
|
it into an object that you can use. It also provides conversions from basic data
|