dash-bees 0.18 → 0.19
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/lib/dash-fu/bee.rb +1 -1
- data/lib/dash-fu/bees/github.rb +4 -3
- data/lib/dash-fu/bees/github.yml +1 -1
- data/lib/dash-fu/bees/github_issues.rb +4 -3
- data/lib/dash-fu/bees/github_issues.yml +1 -1
- data/test/cassettes/github.yml +6 -1
- data/test/github_issues_test.rb +33 -1
- data/test/github_test.rb +13 -4
- metadata +4 -4
data/CHANGELOG
CHANGED
data/lib/dash-fu/bee.rb
CHANGED
data/lib/dash-fu/bees/github.rb
CHANGED
@@ -5,7 +5,7 @@ module DashFu::Bee
|
|
5
5
|
|
6
6
|
def setup(source, params)
|
7
7
|
repo = params["repo"].strip
|
8
|
-
source["source.name"] = "
|
8
|
+
source["source.name"] = "GitHub: #{repo}"
|
9
9
|
source["metric.columns"] = [{ id: "commits", label: "Commits" }, { id: "watchers", label: "Watchers" }, { id: "forks", label: "Forks" }]
|
10
10
|
source["metric.totals"] = true
|
11
11
|
source["repo"] = repo
|
@@ -59,7 +59,8 @@ module DashFu::Bee
|
|
59
59
|
merged.reverse.each do |commits|
|
60
60
|
first = commits.first
|
61
61
|
committer = first["committer"]
|
62
|
-
|
62
|
+
identity = "github.com:#{committer["login"]}" unless committer["login"].blank?
|
63
|
+
person = { fullname: committer["name"], identities: Array.wrap(identity), email: committer["email"] }
|
63
64
|
messages = commits.map { |commit| %{<blockquote><a href="#{commit["url"]}">#{commit["id"][0,7]}</a> #{h commit["message"].strip.split(/[\n\r]/).first[0,50]}</blockquote>} }
|
64
65
|
html = %{pushed to #{h source["branch"]} at <a href="http://github.com/#{source["repo"]}">#{h source["repo"]}</a>:\n#{messages.join("\n")}}
|
65
66
|
callback.activity! uid: first["id"], html: html, url: first["url"], tags: %w{push},
|
@@ -74,7 +75,7 @@ module DashFu::Bee
|
|
74
75
|
when 404, 400
|
75
76
|
callback.error! "Could not find the branch #{source["branch"]}"
|
76
77
|
else
|
77
|
-
callback.error! "
|
78
|
+
callback.error! "GitHub: #{response.code} #{response.message}"
|
78
79
|
end
|
79
80
|
end
|
80
81
|
end
|
data/lib/dash-fu/bees/github.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
en:
|
2
|
-
description: "Tracks
|
2
|
+
description: "Tracks GitHub commits, watchers and forks"
|
3
3
|
inputs: |-
|
4
4
|
<label>User/repository <input type="text" name="source[repo]" size="30"></label>
|
5
5
|
<label>Branch <input type="text" name="source[branch]" size="30" value="master"></label>
|
@@ -19,6 +19,7 @@ module DashFu::Bee
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def update(source, callback)
|
22
|
+
github = { fullname: "GitHub", identities: %w{site:github.com}, photo_url: "http://github.com/images/error/octocat_happy.gif" }
|
22
23
|
session "github.com", 443 do |http|
|
23
24
|
auth = { username: "#{source["username"]}/token", password: source["api_token"] }
|
24
25
|
http.get_json "/api/v2/json/issues/list/#{source["repo"]}/open" do |status, json|
|
@@ -35,7 +36,7 @@ opened <a href="#{url}">issue #{issue["number"]}</a> on #{source["repo"]}:
|
|
35
36
|
<blockquote>#{h issue["title"]}</blockquote>
|
36
37
|
HTML
|
37
38
|
callback.activity! uid: sha, url: url, html: html, tags: %w{issue opened},
|
38
|
-
timestamp: Time.parse(issue["created_at"]).utc
|
39
|
+
person: github, timestamp: Time.parse(issue["created_at"]).utc
|
39
40
|
open_ids << issue["number"]
|
40
41
|
end
|
41
42
|
source["open_ids"] = open_ids.to_a
|
@@ -63,7 +64,7 @@ closed <a href="#{url}">issue #{issue["number"]}</a> on #{source["repo"]}:
|
|
63
64
|
<blockquote>#{h issue["title"]}</blockquote>
|
64
65
|
HTML
|
65
66
|
callback.activity! uid: sha, url: url, html: html, tags: %w{issue closed},
|
66
|
-
timestamp: Time.parse(issue["closed_at"]).utc
|
67
|
+
person: github, timestamp: Time.parse(issue["closed_at"]).utc
|
67
68
|
closed_ids << issue["number"]
|
68
69
|
end
|
69
70
|
source["closed_ids"] = closed_ids.to_a
|
@@ -74,7 +75,7 @@ closed <a href="#{url}">issue #{issue["number"]}</a> on #{source["repo"]}:
|
|
74
75
|
end
|
75
76
|
|
76
77
|
def meta(source)
|
77
|
-
[ { title: "On
|
78
|
+
[ { title: "On GitHub", url: "http://github.com/#{source["repo"]}/issues" } ]
|
78
79
|
end
|
79
80
|
|
80
81
|
protected
|
data/test/cassettes/github.yml
CHANGED
@@ -120,7 +120,12 @@
|
|
120
120
|
"id": "ff156a9fdd2ac534b62b55b8acac2fd092d6543a",
|
121
121
|
"committed_date": "2010-08-06T00:15:01-07:00",
|
122
122
|
"message": "Separate activity",
|
123
|
-
"committer": { "name": "Assaf Arkin", "login": "assaf", "email": "assaf@labnotes.org" } }
|
123
|
+
"committer": { "name": "Assaf Arkin", "login": "assaf", "email": "assaf@labnotes.org" } },
|
124
|
+
{ "url": "http://github.com/assaf/vanity/commit/00154a9fdd2ac534b62b55b8acac2fd092d6543a",
|
125
|
+
"id": "00154a9fdd2ac534b62b55b8acac2fd092d6543a",
|
126
|
+
"committed_date": "2010-08-06T00:15:01-07:00",
|
127
|
+
"message": "No login",
|
128
|
+
"committer": { "name": "Mysterious D", "login": "", "email": "mysterious@example.org" } }
|
124
129
|
]
|
125
130
|
}
|
126
131
|
|
data/test/github_issues_test.rb
CHANGED
@@ -120,6 +120,22 @@ opened <a href="http://github.com/assaf/vanity/issues#issue/21">issue 21</a> on
|
|
120
120
|
should "be valid" do
|
121
121
|
assert subject.valid?
|
122
122
|
end
|
123
|
+
|
124
|
+
context "person" do
|
125
|
+
subject { source.activities.first.person }
|
126
|
+
|
127
|
+
should "be GitHub" do
|
128
|
+
assert_equal "GitHub", subject.fullname
|
129
|
+
end
|
130
|
+
|
131
|
+
should "have site as identity" do
|
132
|
+
assert_contains subject.identities, "site:github.com"
|
133
|
+
end
|
134
|
+
|
135
|
+
should "use octocat as photo" do
|
136
|
+
assert_equal "http://github.com/images/error/octocat_happy.gif", subject.photo_url
|
137
|
+
end
|
138
|
+
end
|
123
139
|
end
|
124
140
|
|
125
141
|
context "activity for closed issue" do
|
@@ -153,6 +169,22 @@ closed <a href="http://github.com/assaf/vanity/issues#issue/18">issue 18</a> on
|
|
153
169
|
should "be valid" do
|
154
170
|
assert subject.valid?
|
155
171
|
end
|
172
|
+
|
173
|
+
context "person" do
|
174
|
+
subject { source.activities.first.person }
|
175
|
+
|
176
|
+
should "be GitHub" do
|
177
|
+
assert_equal "GitHub", subject.fullname
|
178
|
+
end
|
179
|
+
|
180
|
+
should "have site as identity" do
|
181
|
+
assert_contains subject.identities, "site:github.com"
|
182
|
+
end
|
183
|
+
|
184
|
+
should "use octocat as photo" do
|
185
|
+
assert_equal "http://github.com/images/error/octocat_happy.gif", subject.photo_url
|
186
|
+
end
|
187
|
+
end
|
156
188
|
end
|
157
189
|
|
158
190
|
|
@@ -188,7 +220,7 @@ closed <a href="http://github.com/assaf/vanity/issues#issue/18">issue 18</a> on
|
|
188
220
|
subject { source.meta }
|
189
221
|
|
190
222
|
should "link to repository" do
|
191
|
-
assert_contains subject, title: "On
|
223
|
+
assert_contains subject, title: "On GitHub", url: "http://github.com/assaf/vanity/issues"
|
192
224
|
end
|
193
225
|
end
|
194
226
|
end
|
data/test/github_test.rb
CHANGED
@@ -13,7 +13,7 @@ test DashFu::Bee::Github do
|
|
13
13
|
subject { source.metric }
|
14
14
|
|
15
15
|
should "use repository name" do
|
16
|
-
assert_equal "
|
16
|
+
assert_equal "GitHub: assaf/vanity", subject.name
|
17
17
|
end
|
18
18
|
|
19
19
|
should "measure totals" do
|
@@ -142,6 +142,15 @@ test DashFu::Bee::Github do
|
|
142
142
|
should "capture identity" do
|
143
143
|
assert_contains subject.identities, "github.com:assaf"
|
144
144
|
end
|
145
|
+
|
146
|
+
should "not trip on empty login" do
|
147
|
+
commits = interactions.select { |i| i.uri =~ /commits\/list/ }
|
148
|
+
stub_request(:get, commits.first.uri).to_return :body=>commits.last.response.body
|
149
|
+
source.update
|
150
|
+
source.activities.each do |activity|
|
151
|
+
assert activity.person.identities.all? { |id| !id.split(":")[1].blank? }
|
152
|
+
end
|
153
|
+
end
|
145
154
|
end
|
146
155
|
|
147
156
|
context "commit message" do
|
@@ -173,7 +182,7 @@ test DashFu::Bee::Github do
|
|
173
182
|
|
174
183
|
context "sequential commits" do
|
175
184
|
setup do
|
176
|
-
|
185
|
+
source.activities.clear
|
177
186
|
interaction = interactions.select { |i| i.uri =~ /commits\/list/ }.last
|
178
187
|
stub_request(:get, interaction.uri).to_return :body=>interaction.response.body
|
179
188
|
source.update
|
@@ -181,7 +190,7 @@ test DashFu::Bee::Github do
|
|
181
190
|
subject { (Nokogiri::HTML(source.activity.html)/"blockquote") }
|
182
191
|
|
183
192
|
should "show as multiple activities" do
|
184
|
-
assert_equal
|
193
|
+
assert_equal 4, source.activities.count # 4 commits -> 3 activities
|
185
194
|
end
|
186
195
|
|
187
196
|
should "merge related commits into single activity" do
|
@@ -217,7 +226,7 @@ test DashFu::Bee::Github do
|
|
217
226
|
end
|
218
227
|
|
219
228
|
should "capture new number of commits" do
|
220
|
-
assert_equal
|
229
|
+
assert_equal 40, source.metric.values[:commits]
|
221
230
|
end
|
222
231
|
end
|
223
232
|
|
metadata
CHANGED
@@ -4,8 +4,8 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
version: "0.
|
7
|
+
- 19
|
8
|
+
version: "0.19"
|
9
9
|
platform: ruby
|
10
10
|
authors:
|
11
11
|
- Assaf Arkin
|
@@ -13,7 +13,7 @@ autorequire:
|
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
15
|
|
16
|
-
date: 2010-09-
|
16
|
+
date: 2010-09-20 00:00:00 -07:00
|
17
17
|
default_executable:
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
@@ -129,7 +129,7 @@ licenses: []
|
|
129
129
|
post_install_message:
|
130
130
|
rdoc_options:
|
131
131
|
- --title
|
132
|
-
- DashFu::Bee 0.
|
132
|
+
- DashFu::Bee 0.19
|
133
133
|
- --main
|
134
134
|
- README.rdoc
|
135
135
|
- --webcvs
|