stratify-github 0.1 → 0.1.1
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.
@@ -8,14 +8,14 @@ module Stratify
|
|
8
8
|
|
9
9
|
field :checksum
|
10
10
|
field :url
|
11
|
-
field :
|
11
|
+
field :event_type
|
12
12
|
field :repository
|
13
|
+
field :actor
|
13
14
|
field :action # 'created', 'deleted', etc.
|
14
15
|
field :ref # The human/ref name for a branch, tag, etc.
|
15
16
|
field :ref_type # 'branch', 'repo', 'tag'...
|
16
17
|
field :thing # The acted-upon item. ('target' is reserved by mongoid.)
|
17
18
|
field :payload # A text snippet of the comment, gists, etc.
|
18
|
-
field :event_type
|
19
19
|
|
20
20
|
natural_key :checksum
|
21
21
|
|
@@ -31,7 +31,7 @@ module Stratify
|
|
31
31
|
send(field) if body.type == Object
|
32
32
|
end.compact.sort.join(' ')
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
def to_html
|
36
36
|
Stratify::GitHub::Presenter.new(self).to_html
|
37
37
|
end
|
@@ -7,8 +7,7 @@ module Stratify
|
|
7
7
|
truncate(text, :length => length)
|
8
8
|
end
|
9
9
|
|
10
|
-
|
11
|
-
class CommitCommentEvent
|
10
|
+
class CommitCommentEvent
|
12
11
|
def self.make(activity, api_hash)
|
13
12
|
activity.repository = api_hash['url'].split('/')[0..4].join('/')
|
14
13
|
activity
|
@@ -17,16 +16,16 @@ module Stratify
|
|
17
16
|
"#{activity.actor} commented on a commit to #{activity.repository}"
|
18
17
|
end
|
19
18
|
end
|
20
|
-
|
21
|
-
class CreateEvent
|
19
|
+
|
20
|
+
class CreateEvent
|
22
21
|
def self.make(activity, api_hash)
|
23
22
|
activity.ref = api_hash['payload']['ref']
|
24
23
|
activity.ref_type = api_hash['payload']['ref_type']
|
25
|
-
# This is
|
24
|
+
# This is a bummer. There's no omni-present repo element.
|
26
25
|
if activity.ref_type == 'repository'
|
27
26
|
activity.repository = api_hash['url']
|
28
27
|
else
|
29
|
-
activity.repository = api_hash['url'].split('/')[0
|
28
|
+
activity.repository = api_hash['url'].split('/')[0..4].join('/')
|
30
29
|
end
|
31
30
|
activity
|
32
31
|
end
|
@@ -41,11 +40,12 @@ module Stratify
|
|
41
40
|
def self.make(activity, api_hash)
|
42
41
|
activity.ref = api_hash['payload']['ref']
|
43
42
|
activity.ref_type = api_hash['payload']['ref_type']
|
44
|
-
activity.repository = api_hash['repository']['url']
|
43
|
+
activity.repository = api_hash['repository']['url'] rescue nil
|
45
44
|
activity
|
46
45
|
end
|
47
46
|
def self.text(activity)
|
48
|
-
|
47
|
+
repo = activity.repository ? "from #{activity.repository}" : ""
|
48
|
+
"#{activity.actor} deleted #{activity.ref_type} #{activity.ref} #{repo}"
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -58,8 +58,8 @@ module Stratify
|
|
58
58
|
# "A download occurred!"
|
59
59
|
# end
|
60
60
|
# end
|
61
|
-
|
62
|
-
class FollowEvent
|
61
|
+
|
62
|
+
class FollowEvent
|
63
63
|
def self.make(activity, api_hash)
|
64
64
|
activity.thing = api_hash['payload']['target']['login']
|
65
65
|
activity
|
@@ -80,7 +80,7 @@ module Stratify
|
|
80
80
|
end
|
81
81
|
|
82
82
|
# Unused? Unseen in the wild.
|
83
|
-
# class ForkApplyEvent
|
83
|
+
# class ForkApplyEvent
|
84
84
|
# def self.make(activity, api_hash)
|
85
85
|
# activity.thing = api_hash['head']
|
86
86
|
# activity
|
@@ -90,7 +90,7 @@ module Stratify
|
|
90
90
|
# end
|
91
91
|
# end
|
92
92
|
|
93
|
-
class GistEvent
|
93
|
+
class GistEvent
|
94
94
|
def self.make(activity, api_hash)
|
95
95
|
activity.action = api_hash['payload']['action']
|
96
96
|
activity.payload = api_hash['payload']['desc']
|
@@ -101,20 +101,21 @@ module Stratify
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
-
class GollumEvent
|
104
|
+
class GollumEvent
|
105
105
|
def self.make(activity, api_hash)
|
106
106
|
# TODO Handle more than one page per event, assuming that happens.
|
107
107
|
activity.action = api_hash['payload']['pages'][0]['action']
|
108
|
-
activity.repository = api_hash['repository']['url']
|
108
|
+
activity.repository = api_hash['repository']['url'] rescue nil
|
109
109
|
activity.thing = api_hash['payload']['pages'][0]['page_name']
|
110
110
|
activity
|
111
111
|
end
|
112
112
|
def self.text(activity)
|
113
|
-
|
113
|
+
repo = activity.repository ? "on #{activity.repository}" : ""
|
114
|
+
"#{activity.actor} #{activity.action} wiki page #{activity.thing} #{repo}"
|
114
115
|
end
|
115
116
|
end
|
116
117
|
|
117
|
-
class IssueCommentEvent
|
118
|
+
class IssueCommentEvent
|
118
119
|
def self.make(activity, api_hash)
|
119
120
|
activity.repository = api_hash['repository']['url']
|
120
121
|
activity
|
@@ -124,7 +125,7 @@ module Stratify
|
|
124
125
|
end
|
125
126
|
end
|
126
127
|
|
127
|
-
class IssuesEvent
|
128
|
+
class IssuesEvent
|
128
129
|
def self.make(activity, api_hash)
|
129
130
|
activity.action = api_hash['payload']['action']
|
130
131
|
activity.repository = api_hash['url']
|
@@ -135,7 +136,7 @@ module Stratify
|
|
135
136
|
end
|
136
137
|
end
|
137
138
|
|
138
|
-
class MemberEvent
|
139
|
+
class MemberEvent
|
139
140
|
def self.make(activity, api_hash)
|
140
141
|
activity.action = api_hash['payload']['action']
|
141
142
|
activity.repository = api_hash['url']
|
@@ -196,8 +197,8 @@ module Stratify
|
|
196
197
|
end
|
197
198
|
end
|
198
199
|
|
199
|
-
#
|
200
|
-
# class TeamAddEvent
|
200
|
+
# Unused? Unseen in the wild.
|
201
|
+
# class TeamAddEvent
|
201
202
|
# def self.make(activity, api_hash)
|
202
203
|
# activity.ref = api_hash['ref']
|
203
204
|
# activity.thing = api_hash['repository']['url']
|
@@ -208,7 +209,7 @@ module Stratify
|
|
208
209
|
# end
|
209
210
|
# end
|
210
211
|
|
211
|
-
class WatchEvent
|
212
|
+
class WatchEvent
|
212
213
|
def self.make(activity, api_hash)
|
213
214
|
activity
|
214
215
|
end
|
@@ -9,7 +9,7 @@ end
|
|
9
9
|
|
10
10
|
describe Stratify::GitHub::Activity do
|
11
11
|
|
12
|
-
context '
|
12
|
+
context 'model hygiene' do
|
13
13
|
it 'checksums properly' do
|
14
14
|
fields = {
|
15
15
|
'action' => nil,
|
@@ -24,13 +24,13 @@ describe Stratify::GitHub::Activity do
|
|
24
24
|
|
25
25
|
context 'translation' do
|
26
26
|
it 'raises an error when the API passes an unknown event type' do
|
27
|
-
fields = {'type' => '
|
27
|
+
fields = {'type' => 'BendGirderEvent'}
|
28
28
|
lambda {Stratify::GitHub::Activity.from_api_hash(fields)}.should raise_error(GitHubApiError)
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'produces correct fields for a branch CreateEvent' do
|
32
32
|
data = DM({'type' => 'CreateEvent',
|
33
|
-
'url' => 'https://github.com/daemianmack/
|
33
|
+
'url' => 'https://github.com/daemianmack/clj-cronviz/compare/new',
|
34
34
|
'payload' => {
|
35
35
|
'ref' => 'new',
|
36
36
|
'ref_type' => 'branch'}})
|
@@ -38,12 +38,12 @@ describe Stratify::GitHub::Activity do
|
|
38
38
|
event.event_type.should == 'CreateEvent'
|
39
39
|
event.ref.should == 'new'
|
40
40
|
event.ref_type.should == 'branch'
|
41
|
-
event.repository.should == 'https://github.com/daemianmack/
|
41
|
+
event.repository.should == 'https://github.com/daemianmack/clj-cronviz'
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'produces correct fields for a repo CreateEvent' do
|
45
45
|
data = DM({'type' => 'CreateEvent',
|
46
|
-
'url' => 'https://github.com/daemianmack/
|
46
|
+
'url' => 'https://github.com/daemianmack/clj-cronviz',
|
47
47
|
'payload' => {
|
48
48
|
'ref' => nil,
|
49
49
|
'ref_type' => 'repository'}})
|
@@ -51,15 +51,15 @@ describe Stratify::GitHub::Activity do
|
|
51
51
|
event.event_type.should == 'CreateEvent'
|
52
52
|
event.ref.should == nil
|
53
53
|
event.ref_type.should == 'repository'
|
54
|
-
event.repository.should == 'https://github.com/daemianmack/
|
54
|
+
event.repository.should == 'https://github.com/daemianmack/clj-cronviz'
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'produces correct fields for a CommitCommentEvent' do
|
58
58
|
data = DM({'type' => 'CommitCommentEvent',
|
59
|
-
'url' => 'https://github.com/daemianmack/
|
59
|
+
'url' => 'https://github.com/daemianmack/clj-cronviz/compare/master'})
|
60
60
|
event = Stratify::GitHub::Activity.from_api_hash(data)
|
61
61
|
event.event_type.should == 'CommitCommentEvent'
|
62
|
-
event.repository.should == 'https://github.com/daemianmack/
|
62
|
+
event.repository.should == 'https://github.com/daemianmack/clj-cronviz'
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'produces correct fields for a DeleteEvent' do
|
@@ -68,12 +68,24 @@ describe Stratify::GitHub::Activity do
|
|
68
68
|
'ref' => 'expendable',
|
69
69
|
'ref_type' => 'branch'},
|
70
70
|
'repository' => {
|
71
|
-
'url' => 'https://github.com/daemianmack/
|
71
|
+
'url' => 'https://github.com/daemianmack/clj-cronviz'}})
|
72
72
|
event = Stratify::GitHub::Activity.from_api_hash(data)
|
73
73
|
event.event_type.should == 'DeleteEvent'
|
74
74
|
event.ref.should == 'expendable'
|
75
75
|
event.ref_type.should == 'branch'
|
76
|
-
event.repository.should == 'https://github.com/daemianmack/
|
76
|
+
event.repository.should == 'https://github.com/daemianmack/clj-cronviz'
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'produces correct fields for a DeleteEvent without a repository' do
|
80
|
+
data = DM({'type' => 'DeleteEvent',
|
81
|
+
'payload' => {
|
82
|
+
'ref' => 'expendable',
|
83
|
+
'ref_type' => 'branch'}})
|
84
|
+
event = Stratify::GitHub::Activity.from_api_hash(data)
|
85
|
+
event.event_type.should == 'DeleteEvent'
|
86
|
+
event.ref.should == 'expendable'
|
87
|
+
event.ref_type.should == 'branch'
|
88
|
+
event.repository.should be_nil
|
77
89
|
end
|
78
90
|
|
79
91
|
it 'produces correct fields for a FollowEvent' do
|
@@ -113,32 +125,45 @@ describe Stratify::GitHub::Activity do
|
|
113
125
|
'action' => 'created',
|
114
126
|
'page_name' => 'Contributing'}]},
|
115
127
|
'repository' => {
|
116
|
-
'url' => 'https://github.com/daemianmack/cronviz'}})
|
128
|
+
'url' => 'https://github.com/daemianmack/clj-cronviz'}})
|
129
|
+
event = Stratify::GitHub::Activity.from_api_hash(data)
|
130
|
+
event.action.should == 'created'
|
131
|
+
event.event_type.should == 'GollumEvent'
|
132
|
+
event.repository.should == 'https://github.com/daemianmack/clj-cronviz'
|
133
|
+
event.thing.should == 'Contributing'
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'produces correct fields for a GollumEvent without a repository' do
|
137
|
+
data = DM({'type' => 'GollumEvent',
|
138
|
+
'payload' => {
|
139
|
+
'pages' => [{
|
140
|
+
'action' => 'created',
|
141
|
+
'page_name' => 'Contributing'}]}})
|
117
142
|
event = Stratify::GitHub::Activity.from_api_hash(data)
|
118
143
|
event.action.should == 'created'
|
119
144
|
event.event_type.should == 'GollumEvent'
|
120
|
-
event.repository.should
|
145
|
+
event.repository.should be_nil
|
121
146
|
event.thing.should == 'Contributing'
|
122
147
|
end
|
123
148
|
|
124
|
-
it 'produces correct fields for
|
149
|
+
it 'produces correct fields for an IssueCommentEvent' do
|
125
150
|
data = DM({'type' => 'IssueCommentEvent',
|
126
151
|
'repository' => {
|
127
|
-
'url' => 'https://github.com/daemianmack/cronviz'}})
|
152
|
+
'url' => 'https://github.com/daemianmack/clj-cronviz'}})
|
128
153
|
event = Stratify::GitHub::Activity.from_api_hash(data)
|
129
154
|
event.event_type.should == 'IssueCommentEvent'
|
130
|
-
event.repository.should == 'https://github.com/daemianmack/cronviz'
|
155
|
+
event.repository.should == 'https://github.com/daemianmack/clj-cronviz'
|
131
156
|
end
|
132
157
|
|
133
|
-
it 'produces correct fields for
|
158
|
+
it 'produces correct fields for an IssuesEvent' do
|
134
159
|
data = DM({'type' => 'IssuesEvent',
|
135
160
|
'payload' => {
|
136
161
|
'action' => 'created'},
|
137
|
-
'url' => 'https://github.com/daemianmack/cronviz'})
|
162
|
+
'url' => 'https://github.com/daemianmack/clj-cronviz'})
|
138
163
|
event = Stratify::GitHub::Activity.from_api_hash(data)
|
139
164
|
event.action.should == 'created'
|
140
165
|
event.event_type.should == 'IssuesEvent'
|
141
|
-
event.repository.should == 'https://github.com/daemianmack/cronviz'
|
166
|
+
event.repository.should == 'https://github.com/daemianmack/clj-cronviz'
|
142
167
|
end
|
143
168
|
|
144
169
|
it 'produces correct fields for a MemberEvent' do
|
@@ -147,22 +172,22 @@ describe Stratify::GitHub::Activity do
|
|
147
172
|
'action' => 'added',
|
148
173
|
'member' => {
|
149
174
|
'login' => 'bender'}},
|
150
|
-
'url' => 'https://github.com/daemianmack/cronviz'})
|
175
|
+
'url' => 'https://github.com/daemianmack/clj-cronviz'})
|
151
176
|
event = Stratify::GitHub::Activity.from_api_hash(data)
|
152
177
|
event.action.should == 'added'
|
153
178
|
event.event_type.should == 'MemberEvent'
|
154
|
-
event.repository.should == 'https://github.com/daemianmack/cronviz'
|
179
|
+
event.repository.should == 'https://github.com/daemianmack/clj-cronviz'
|
155
180
|
event.thing.should == 'bender'
|
156
181
|
end
|
157
182
|
|
158
183
|
it 'produces correct fields for a PublicEvent' do
|
159
184
|
data = DM({'type' => 'PublicEvent',
|
160
185
|
'repository' => {
|
161
|
-
'url' => 'https://github.com/daemianmack/cronviz'}})
|
186
|
+
'url' => 'https://github.com/daemianmack/clj-cronviz'}})
|
162
187
|
event = Stratify::GitHub::Activity.from_api_hash(data)
|
163
188
|
event.action.should == 'publicized'
|
164
189
|
event.event_type.should == 'PublicEvent'
|
165
|
-
event.repository.should == 'https://github.com/daemianmack/cronviz'
|
190
|
+
event.repository.should == 'https://github.com/daemianmack/clj-cronviz'
|
166
191
|
end
|
167
192
|
|
168
193
|
it 'produces correct fields for a PullRequestEvent' do
|
@@ -171,11 +196,11 @@ describe Stratify::GitHub::Activity do
|
|
171
196
|
'pull_request' => {
|
172
197
|
'title' => 'Allow time to flow in reverse'}},
|
173
198
|
'repository' => {
|
174
|
-
'url' => 'https://github.com/daemianmack/cronviz'}})
|
199
|
+
'url' => 'https://github.com/daemianmack/clj-cronviz'}})
|
175
200
|
event = Stratify::GitHub::Activity.from_api_hash(data)
|
176
201
|
event.event_type.should == 'PullRequestEvent'
|
177
202
|
event.payload.should == 'Allow time to flow in reverse'
|
178
|
-
event.repository.should == 'https://github.com/daemianmack/cronviz'
|
203
|
+
event.repository.should == 'https://github.com/daemianmack/clj-cronviz'
|
179
204
|
end
|
180
205
|
|
181
206
|
it 'produces correct fields for a PullRequestReviewCommentEvent' do
|
@@ -184,11 +209,11 @@ describe Stratify::GitHub::Activity do
|
|
184
209
|
'comment' => {
|
185
210
|
'body' => 'Please remove all semicolons from this JavaScript.'}},
|
186
211
|
'repository' => {
|
187
|
-
'url' => 'https://github.com/daemianmack/cronviz'}})
|
212
|
+
'url' => 'https://github.com/daemianmack/clj-cronviz'}})
|
188
213
|
event = Stratify::GitHub::Activity.from_api_hash(data)
|
189
214
|
event.event_type.should == 'PullRequestReviewCommentEvent'
|
190
215
|
event.payload.should == 'Please remove all semicolons from this JavaScript.'
|
191
|
-
event.repository.should == 'https://github.com/daemianmack/cronviz'
|
216
|
+
event.repository.should == 'https://github.com/daemianmack/clj-cronviz'
|
192
217
|
end
|
193
218
|
|
194
219
|
it 'produces correct fields for a PushEvent' do
|
@@ -197,12 +222,12 @@ describe Stratify::GitHub::Activity do
|
|
197
222
|
'ref' => 'refs/head/master',
|
198
223
|
'shas' => [[nil, nil, 'Fix all the things']]},
|
199
224
|
'repository' => {
|
200
|
-
'url' => 'https://github.com/daemianmack/cronviz'}})
|
225
|
+
'url' => 'https://github.com/daemianmack/clj-cronviz'}})
|
201
226
|
event = Stratify::GitHub::Activity.from_api_hash(data)
|
202
227
|
event.action.should == 'pushed'
|
203
228
|
event.event_type.should == 'PushEvent'
|
204
229
|
event.ref.should == 'refs/head/master'
|
205
|
-
event.repository.should == 'https://github.com/daemianmack/cronviz'
|
230
|
+
event.repository.should == 'https://github.com/daemianmack/clj-cronviz'
|
206
231
|
event.payload.should == 'Fix all the things'
|
207
232
|
end
|
208
233
|
|
@@ -8,9 +8,9 @@ describe 'stratify-github' do
|
|
8
8
|
collector.run
|
9
9
|
|
10
10
|
Stratify::GitHub::Activity.where(
|
11
|
-
:actor
|
11
|
+
:actor => 'daemianmack',
|
12
12
|
:event_type => 'ForkEvent',
|
13
|
-
:url
|
13
|
+
:url => 'https://github.com/daemianmack/stratify'
|
14
14
|
).should exist
|
15
15
|
end
|
16
16
|
end
|
@@ -4,11 +4,11 @@ describe Stratify::GitHub::Presenter do
|
|
4
4
|
describe '#to_html' do
|
5
5
|
it 'wraps a GitHub repo URL with a link' do
|
6
6
|
data = {
|
7
|
-
'type'
|
8
|
-
'url'
|
7
|
+
'type' => 'WatchEvent',
|
8
|
+
'url' => 'https://github.com/daemianmack/clj-cronviz'}
|
9
9
|
activity = Stratify::GitHub::Activity.from_api_hash(data)
|
10
10
|
presenter = Stratify::GitHub::Presenter.new(activity)
|
11
|
-
presenter.to_html.should match '<a href="https://github.com/daemianmack/cronviz">https://github.com/daemianmack/cronviz</a>'
|
11
|
+
presenter.to_html.should match '<a href="https://github.com/daemianmack/clj-cronviz">https://github.com/daemianmack/clj-cronviz</a>'
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stratify-github
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.1.1
|
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: 2012-08-
|
12
|
+
date: 2012-08-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|