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 CHANGED
@@ -1,3 +1,5 @@
1
+ 2010-09-20 v0.19 Fixed sometimes missing identity for Github
2
+
1
3
  2010-09-16 v0.18 Now bees, have separate update and webhook methods
2
4
 
3
5
  Update method separated from webhook method.
data/lib/dash-fu/bee.rb CHANGED
@@ -10,7 +10,7 @@ module DashFu
10
10
  # The README covers it all.
11
11
  module Bee
12
12
 
13
- VERSION = "0.18"
13
+ VERSION = "0.19"
14
14
 
15
15
  class << self
16
16
  attr_accessor :logger
@@ -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"] = "Github: #{repo}"
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
- person = { fullname: committer["name"], identities: %W{github.com:#{committer["login"]}}, email: committer["email"] }
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! "Github: #{response.code} #{response.message}"
78
+ callback.error! "GitHub: #{response.code} #{response.message}"
78
79
  end
79
80
  end
80
81
  end
@@ -1,5 +1,5 @@
1
1
  en:
2
- description: "Tracks Github commits, watchers and forks"
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 Github", url: "http://github.com/#{source["repo"]}/issues" } ]
78
+ [ { title: "On GitHub", url: "http://github.com/#{source["repo"]}/issues" } ]
78
79
  end
79
80
 
80
81
  protected
@@ -1,5 +1,5 @@
1
1
  en:
2
- description: "Tracks open/closed Github issues"
2
+ description: "Tracks open/closed GitHub issues"
3
3
  inputs: |-
4
4
  <label>User/repository <input type="text" name="source[repo]" size="30"></label>
5
5
  <p>For private repositories:</p>
@@ -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
 
@@ -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 Github", url: "http://github.com/assaf/vanity/issues"
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 "Github: assaf/vanity", subject.name
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
- puts source.activities.clear
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 3, source.activities.count # 4 commits -> 3 activities
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 39, source.metric.values[:commits]
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
- - 18
8
- version: "0.18"
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 00:00:00 -07:00
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.18
132
+ - DashFu::Bee 0.19
133
133
  - --main
134
134
  - README.rdoc
135
135
  - --webcvs