vanity-source 0.11 → 0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +8 -0
- data/Gemfile +2 -0
- data/lib/vanity/sources/backtweets.rb +1 -1
- data/lib/vanity/sources/github.rb +18 -9
- data/test/backtweets_test.rb +1 -1
- data/test/cassettes/github.yml +13 -8
- data/test/github_issues_test.rb +1 -1
- data/test/github_test.rb +55 -12
- data/test/helpers/test.rb +1 -1
- data/test/ruby_gems_test.rb +1 -1
- data/test/setup.rb +9 -4
- data/test/test.log +76 -0
- data/vanity-source.gemspec +2 -1
- metadata +17 -10
data/CHANGELOG
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
2010-08-30 v0.12 Github data source merges related commits
|
2
|
+
|
3
|
+
Github data source merges related commits (same committer/time) into single
|
4
|
+
activity and shows first line of all commit messages.
|
5
|
+
|
6
|
+
Changed to coding/testing with Ruby 1.9.2, since this is the target
|
7
|
+
environment.
|
8
|
+
|
1
9
|
2010-08-30 v0.11 Changes to activity person, AS 3.0 support
|
2
10
|
|
3
11
|
Activity's person name is now fullname, photo is photo_url and url is no
|
data/Gemfile
CHANGED
@@ -37,7 +37,7 @@ module Vanity
|
|
37
37
|
<a href="#{url}">tweeted</a>:
|
38
38
|
<blockquote>#{tweet["tweet_text"]}</blockquote>
|
39
39
|
HTML
|
40
|
-
person = { :fullname=>handle, :identities=>%{twitter.com:#{handle}}, :photo_url=>tweet["tweet_profile_image_url"] }
|
40
|
+
person = { :fullname=>handle, :identities=>%W{twitter.com:#{handle}}, :photo_url=>tweet["tweet_profile_image_url"] }
|
41
41
|
block.call :activity=>{ :uid=>id, :url=>url, :html=>html, :tags=>%w{twitter mention},
|
42
42
|
:timestamp=>Time.parse(tweet["tweet_created_at"]).utc, :person=>person }
|
43
43
|
end
|
@@ -52,15 +52,24 @@ module Vanity
|
|
52
52
|
last_seen_id = context["last_commit"]["id"] if context["last_commit"]
|
53
53
|
if last_seen_id
|
54
54
|
new_ones = commits.take_while { |commit| commit["id"] != last_seen_id }
|
55
|
-
new_ones.
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
55
|
+
merged = new_ones.inject([]) do |all, commit|
|
56
|
+
last = all.last.last unless all.empty?
|
57
|
+
if last && last["committer"]["email"] == commit["committer"]["email"] && last["committed_date"] == commit["committed_date"]
|
58
|
+
all.last << commit
|
59
|
+
else
|
60
|
+
all << [commit]
|
61
|
+
end
|
62
|
+
all
|
63
|
+
end
|
64
|
+
|
65
|
+
merged.reverse.each do |commits|
|
66
|
+
first = commits.first
|
67
|
+
committer = first["committer"]
|
68
|
+
person = { :fullname=>committer["name"], :identities=>%W{github.com:#{committer["name"]}}, :email=>committer["email"] }
|
69
|
+
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>} }
|
70
|
+
html = %{pushed to #{h context["branch"]} at <a href="http://github.com/#{context["repo"]}">#{h context["repo"]}</a>:\n#{messages.join("\n")}}
|
71
|
+
block.call :activity=>{ :uid=>first["id"], :html=>html, :url=>first["url"], :tags=>%w{push},
|
72
|
+
:timestamp=>Time.parse(first["committed_date"]).utc, :person=>person }
|
64
73
|
end
|
65
74
|
block.call :inc=>{ :commits=>new_ones.count }
|
66
75
|
else
|
data/test/backtweets_test.rb
CHANGED
data/test/cassettes/github.yml
CHANGED
@@ -102,20 +102,25 @@
|
|
102
102
|
body: |-
|
103
103
|
{ "commits": [
|
104
104
|
{ "url": "http://github.com/assaf/vanity/commit/dd154a9fdd2ac534b62b55b8acac2fd092d65439",
|
105
|
-
"id": "
|
105
|
+
"id": "cc156a9fdd2ac534b62b55b8acac2fd092d65439",
|
106
106
|
"committed_date": "2010-08-06T00:22:01-07:00",
|
107
|
-
"message": "
|
107
|
+
"message": "Most recent commit",
|
108
108
|
"committer": { "name": "Assaf Arkin", "login": "assaf", "email": "assaf@labnotes.org" } },
|
109
109
|
{ "url": "http://github.com/assaf/vanity/commit/dd154a9fdd2ac534b62b55b8acac2fd092d6543b",
|
110
|
-
"id": "
|
110
|
+
"id": "dd156a9fdd2ac534b62b55b8acac2fd092d6543b",
|
111
111
|
"committed_date": "2010-08-06T00:22:01-07:00",
|
112
|
-
"message": "
|
112
|
+
"message": "Not most recent commit",
|
113
113
|
"committer": { "name": "Assaf Arkin", "login": "assaf", "email": "assaf@labnotes.org" } },
|
114
114
|
{ "url": "http://github.com/assaf/vanity/commit/dd154a9fdd2ac534b62b55b8acac2fd092d6543a",
|
115
|
-
"id": "
|
116
|
-
"committed_date": "2010-08-06T00:
|
117
|
-
"message": "
|
118
|
-
"committer": { "name": "Assaf Arkin", "login": "assaf", "email": "assaf@labnotes.org" } }
|
115
|
+
"id": "ee156a9fdd2ac534b62b55b8acac2fd092d6543a",
|
116
|
+
"committed_date": "2010-08-06T00:22:01-07:00",
|
117
|
+
"message": "Different committer",
|
118
|
+
"committer": { "name": "Assaf Arkin", "login": "assaf", "email": "not.assaf@labnotes.org" } },
|
119
|
+
{ "url": "http://github.com/assaf/vanity/commit/dd154a9fdd2ac534b62b55b8acac2fd092d6543a",
|
120
|
+
"id": "ff156a9fdd2ac534b62b55b8acac2fd092d6543a",
|
121
|
+
"committed_date": "2010-08-06T00:15:01-07:00",
|
122
|
+
"message": "Different push",
|
123
|
+
"committer": { "name": "Assaf Arkin", "login": "assaf", "email": "not.assaf@labnotes.org" } }
|
119
124
|
]
|
120
125
|
}
|
121
126
|
|
data/test/github_issues_test.rb
CHANGED
data/test/github_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative "setup"
|
2
2
|
|
3
3
|
test Vanity::Source::Github do
|
4
4
|
context "setup" do
|
@@ -122,11 +122,7 @@ test Vanity::Source::Github do
|
|
122
122
|
end
|
123
123
|
|
124
124
|
should "capture new number of commits" do
|
125
|
-
assert_equal
|
126
|
-
end
|
127
|
-
|
128
|
-
should "create activity for each commit" do
|
129
|
-
assert_equal 2, activities.count
|
125
|
+
assert_equal 39, totals[:commits]
|
130
126
|
end
|
131
127
|
|
132
128
|
context "activity" do
|
@@ -137,18 +133,15 @@ test Vanity::Source::Github do
|
|
137
133
|
end
|
138
134
|
|
139
135
|
should "capture commit SHA" do
|
140
|
-
assert_equal "
|
136
|
+
assert_equal "cc156a9fdd2ac534b62b55b8acac2fd092d65439", subject.uid
|
141
137
|
end
|
142
138
|
|
143
139
|
should "capture timestamp" do
|
144
140
|
assert_equal Time.parse("2010-08-06T00:22:01-07:00 UTC"), subject.timestamp
|
145
141
|
end
|
146
142
|
|
147
|
-
should "capture
|
148
|
-
|
149
|
-
pushed to master at <a href="http://github.com/assaf/vanity">assaf/vanity</a>:
|
150
|
-
<blockquote><a href="http://github.com/assaf/vanity/commit/dd154a9fdd2ac534b62b55b8acac2fd092d65439">dd154a9</a> Third & last</blockquote>
|
151
|
-
HTML
|
143
|
+
should "capture push" do
|
144
|
+
assert_match %{pushed to master at <a href="http://github.com/assaf/vanity">assaf/vanity</a>:}, subject.html
|
152
145
|
end
|
153
146
|
|
154
147
|
should "tag as push" do
|
@@ -156,6 +149,7 @@ pushed to master at <a href="http://github.com/assaf/vanity">assaf/vanity</a>:
|
|
156
149
|
end
|
157
150
|
|
158
151
|
should "be valid" do
|
152
|
+
subject.validate
|
159
153
|
assert subject.valid?
|
160
154
|
end
|
161
155
|
|
@@ -170,6 +164,55 @@ pushed to master at <a href="http://github.com/assaf/vanity">assaf/vanity</a>:
|
|
170
164
|
assert_equal "assaf@labnotes.org", subject.email
|
171
165
|
end
|
172
166
|
end
|
167
|
+
|
168
|
+
context "commit message" do
|
169
|
+
subject { (Nokogiri::HTML(activity.html)/"blockquote").inner_text.strip }
|
170
|
+
|
171
|
+
should "start with commit SHA" do
|
172
|
+
assert_match /^cc156a9 /, subject
|
173
|
+
end
|
174
|
+
|
175
|
+
should "include first 50 characters of message" do
|
176
|
+
with_message "This is a very long message and we're only going to show the first 50 characters of it."
|
177
|
+
assert_equal 50, subject[/\s(.*)/, 1].length
|
178
|
+
end
|
179
|
+
|
180
|
+
should "use only first line of message" do
|
181
|
+
with_message "This message is made\nof two lines"
|
182
|
+
assert_match "This message is made", subject[/\s(.*)/, 1]
|
183
|
+
end
|
184
|
+
|
185
|
+
def with_message(message)
|
186
|
+
commits = interactions.select { |i| i.uri =~ /commits\/list/ }
|
187
|
+
commit = JSON.parse(commits.first.response.body)["commits"].first
|
188
|
+
commit["message"] = message
|
189
|
+
stub_request(:get, commits.first.uri).to_return :body=>{ :commits=>[commit] }.to_json
|
190
|
+
update_source
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
context "multiple commits" do
|
195
|
+
setup do
|
196
|
+
interaction = interactions.select { |i| i.uri =~ /commits\/list/ }.last
|
197
|
+
stub_request(:get, interaction.uri).to_return :body=>interaction.response.body
|
198
|
+
update_source
|
199
|
+
end
|
200
|
+
subject { (Nokogiri::HTML(activity.html)/"blockquote") }
|
201
|
+
|
202
|
+
should "show as multiple activities" do
|
203
|
+
assert_equal 3, activities.count # 4 commits -> 3 activities
|
204
|
+
end
|
205
|
+
|
206
|
+
should "merge related commits into single activity" do
|
207
|
+
assert_equal 2, subject.length # last one has two commits
|
208
|
+
end
|
209
|
+
|
210
|
+
should "merge related commits in order they were listed" do
|
211
|
+
first, second = subject.map { |bq| bq.inner_text.strip }
|
212
|
+
assert_equal "cc156a9 Most recent commit", first
|
213
|
+
assert_equal "dd156a9 Not most recent commit", second
|
214
|
+
end
|
215
|
+
end
|
173
216
|
end
|
174
217
|
|
175
218
|
end
|
data/test/helpers/test.rb
CHANGED
data/test/ruby_gems_test.rb
CHANGED
data/test/setup.rb
CHANGED
@@ -2,11 +2,16 @@ require "test/unit"
|
|
2
2
|
require "shoulda"
|
3
3
|
require "webmock/test_unit"
|
4
4
|
require "vcr"
|
5
|
+
require "ap"
|
6
|
+
require "logger"
|
5
7
|
|
6
|
-
require "
|
7
|
-
require "
|
8
|
-
|
9
|
-
|
8
|
+
require "nokogiri"
|
9
|
+
require "active_support/all"
|
10
|
+
|
11
|
+
require_relative "helpers/test"
|
12
|
+
require_relative "helpers/person"
|
13
|
+
require_relative "helpers/activity"
|
14
|
+
require_relative "helpers/metric"
|
10
15
|
|
11
16
|
|
12
17
|
require File.dirname(__FILE__) + "/../lib/vanity/source"
|
data/test/test.log
CHANGED
@@ -612,3 +612,79 @@ Backtweets: 200
|
|
612
612
|
Backtweets: 500
|
613
613
|
RubyGems: 200
|
614
614
|
RubyGems: 500
|
615
|
+
Backtweets: 200
|
616
|
+
Backtweets: 500
|
617
|
+
Backtweets: 200
|
618
|
+
Backtweets: 500
|
619
|
+
Backtweets: 200
|
620
|
+
Backtweets: 500
|
621
|
+
Backtweets: 200
|
622
|
+
Backtweets: 500
|
623
|
+
Backtweets: 200
|
624
|
+
Backtweets: 500
|
625
|
+
Backtweets: 200
|
626
|
+
Backtweets: 500
|
627
|
+
Backtweets: 200
|
628
|
+
Backtweets: 500
|
629
|
+
Backtweets: 200
|
630
|
+
Backtweets: 500
|
631
|
+
Backtweets: 500
|
632
|
+
Backtweets: 200
|
633
|
+
Backtweets: 200
|
634
|
+
Backtweets: 500
|
635
|
+
RubyGems: 200
|
636
|
+
RubyGems: 500
|
637
|
+
Backtweets: 500
|
638
|
+
Backtweets: 200
|
639
|
+
Backtweets: 200
|
640
|
+
Backtweets: 500
|
641
|
+
RubyGems: 200
|
642
|
+
RubyGems: 500
|
643
|
+
Backtweets: 500
|
644
|
+
Backtweets: 200
|
645
|
+
Backtweets: 200
|
646
|
+
Backtweets: 500
|
647
|
+
RubyGems: 200
|
648
|
+
RubyGems: 500
|
649
|
+
Backtweets: 500
|
650
|
+
Backtweets: 200
|
651
|
+
Backtweets: 500
|
652
|
+
Backtweets: 200
|
653
|
+
Backtweets: 200
|
654
|
+
Backtweets: 500
|
655
|
+
RubyGems: 200
|
656
|
+
RubyGems: 500
|
657
|
+
Backtweets: 500
|
658
|
+
Backtweets: 200
|
659
|
+
Backtweets: 200
|
660
|
+
Backtweets: 500
|
661
|
+
RubyGems: 200
|
662
|
+
RubyGems: 500
|
663
|
+
Backtweets: 200
|
664
|
+
Backtweets: 500
|
665
|
+
Backtweets: 200
|
666
|
+
Backtweets: 500
|
667
|
+
Backtweets: 200
|
668
|
+
Backtweets: 500
|
669
|
+
Backtweets: 200
|
670
|
+
Backtweets: 500
|
671
|
+
Backtweets: 200
|
672
|
+
Backtweets: 500
|
673
|
+
Backtweets: 200
|
674
|
+
Backtweets: 500
|
675
|
+
Backtweets: 200
|
676
|
+
Backtweets: 500
|
677
|
+
Backtweets: 200
|
678
|
+
Backtweets: 500
|
679
|
+
Backtweets: 500
|
680
|
+
Backtweets: 200
|
681
|
+
Backtweets: 200
|
682
|
+
Backtweets: 500
|
683
|
+
RubyGems: 200
|
684
|
+
RubyGems: 500
|
685
|
+
Backtweets: 500
|
686
|
+
Backtweets: 200
|
687
|
+
Backtweets: 200
|
688
|
+
Backtweets: 500
|
689
|
+
RubyGems: 200
|
690
|
+
RubyGems: 500
|
data/vanity-source.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "vanity-source"
|
3
|
-
spec.version = "0.
|
3
|
+
spec.version = "0.12"
|
4
4
|
spec.author = "Assaf Arkin"
|
5
5
|
spec.email = "assaf@labnotes.org"
|
6
6
|
spec.homepage = "http://vanitydash.com"
|
@@ -17,4 +17,5 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.add_dependency "activesupport"
|
18
18
|
spec.add_dependency "json"
|
19
19
|
spec.add_dependency "rack"
|
20
|
+
spec.add_dependency "i18n"
|
20
21
|
end
|
metadata
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vanity-source
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 29
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
|
-
-
|
9
|
-
version: "0.
|
7
|
+
- 12
|
8
|
+
version: "0.12"
|
10
9
|
platform: ruby
|
11
10
|
authors:
|
12
11
|
- Assaf Arkin
|
@@ -14,7 +13,7 @@ autorequire:
|
|
14
13
|
bindir: bin
|
15
14
|
cert_chain: []
|
16
15
|
|
17
|
-
date: 2010-08-
|
16
|
+
date: 2010-08-31 00:00:00 -07:00
|
18
17
|
default_executable:
|
19
18
|
dependencies:
|
20
19
|
- !ruby/object:Gem::Dependency
|
@@ -25,7 +24,6 @@ dependencies:
|
|
25
24
|
requirements:
|
26
25
|
- - ">="
|
27
26
|
- !ruby/object:Gem::Version
|
28
|
-
hash: 3
|
29
27
|
segments:
|
30
28
|
- 0
|
31
29
|
version: "0"
|
@@ -39,7 +37,6 @@ dependencies:
|
|
39
37
|
requirements:
|
40
38
|
- - ">="
|
41
39
|
- !ruby/object:Gem::Version
|
42
|
-
hash: 3
|
43
40
|
segments:
|
44
41
|
- 0
|
45
42
|
version: "0"
|
@@ -53,12 +50,24 @@ dependencies:
|
|
53
50
|
requirements:
|
54
51
|
- - ">="
|
55
52
|
- !ruby/object:Gem::Version
|
56
|
-
hash: 3
|
57
53
|
segments:
|
58
54
|
- 0
|
59
55
|
version: "0"
|
60
56
|
type: :runtime
|
61
57
|
version_requirements: *id003
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: i18n
|
60
|
+
prerelease: false
|
61
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
version: "0"
|
69
|
+
type: :runtime
|
70
|
+
version_requirements: *id004
|
62
71
|
description:
|
63
72
|
email: assaf@labnotes.org
|
64
73
|
executables: []
|
@@ -106,7 +115,7 @@ licenses: []
|
|
106
115
|
post_install_message:
|
107
116
|
rdoc_options:
|
108
117
|
- --title
|
109
|
-
- Vanity::Source 0.
|
118
|
+
- Vanity::Source 0.12
|
110
119
|
- --main
|
111
120
|
- README.rdoc
|
112
121
|
- --webcvs
|
@@ -118,7 +127,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
118
127
|
requirements:
|
119
128
|
- - ">="
|
120
129
|
- !ruby/object:Gem::Version
|
121
|
-
hash: 57
|
122
130
|
segments:
|
123
131
|
- 1
|
124
132
|
- 8
|
@@ -129,7 +137,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
137
|
requirements:
|
130
138
|
- - ">="
|
131
139
|
- !ruby/object:Gem::Version
|
132
|
-
hash: 3
|
133
140
|
segments:
|
134
141
|
- 0
|
135
142
|
version: "0"
|