vanity-source 0.10 → 0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +12 -1
- data/lib/vanity/sources/backtweets.rb +2 -2
- data/lib/vanity/sources/github.rb +2 -3
- data/test/backtweets_test.rb +41 -27
- data/test/github_issues_test.rb +42 -33
- data/test/github_test.rb +50 -36
- data/test/helpers/activity.rb +21 -0
- data/test/helpers/metric.rb +22 -0
- data/test/helpers/person.rb +24 -0
- data/test/{test_helper.rb → helpers/test.rb} +6 -48
- data/test/ruby_gems_test.rb +30 -19
- data/test/setup.rb +27 -0
- data/test/test.log +112 -0
- data/vanity-source.gemspec +4 -4
- metadata +22 -21
data/CHANGELOG
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
2010-08-30 v0.11 Changes to activity person, AS 3.0 support
|
2
|
+
|
3
|
+
Activity's person name is now fullname, photo is photo_url and url is no
|
4
|
+
longer, but we do accept multiple identities of the form domain:id, e.g
|
5
|
+
twitter.com:assaf, linkedin.com:assafarkin.
|
6
|
+
|
7
|
+
Test suite now allows validating metric, activity and person. Call the validate
|
8
|
+
method to run validation and raise exception on error (with a helpful error
|
9
|
+
message). Call valid? if you're only interested in true/false.
|
10
|
+
|
11
|
+
Gem dependencies removed to allow running with ActiveSupport 3.0.
|
12
|
+
|
1
13
|
2010-08-26 v0.10 Tags and better messages
|
2
14
|
|
3
15
|
Activities can now include tags.
|
@@ -11,7 +23,6 @@ Improvement all around to all the HTML messages.
|
|
11
23
|
Attribute :id is now :uid.
|
12
24
|
|
13
25
|
Activity content can be set using either :html or :text attribute.
|
14
|
-
|
15
26
|
2010-08-24 v0.7 Added test suite and resources
|
16
27
|
|
17
28
|
Each source can have an associated resources file (YAML), e.g. ruby_gems.rb
|
@@ -37,9 +37,9 @@ 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
41
|
block.call :activity=>{ :uid=>id, :url=>url, :html=>html, :tags=>%w{twitter mention},
|
41
|
-
:timestamp=>Time.parse(tweet["tweet_created_at"]).utc,
|
42
|
-
:person=>{ :name=>handle, :url=>"http://twitter.com/#{handle}", :photo=>tweet["tweet_profile_image_url"] } }
|
42
|
+
:timestamp=>Time.parse(tweet["tweet_created_at"]).utc, :person=>person }
|
43
43
|
end
|
44
44
|
end
|
45
45
|
if recent = tweets.first
|
@@ -58,10 +58,9 @@ module Vanity
|
|
58
58
|
pushed to #{h context["branch"]} at <a href="http://github.com/#{context["repo"]}">#{h context["repo"]}</a>:
|
59
59
|
<blockquote><a href="#{commit["url"]}">#{commit["id"][0,7]}</a> #{h commit["message"]}</blockquote>
|
60
60
|
HTML
|
61
|
+
person = { :fullname=>committer["name"], :identities=>%{github.com:#{committer["name"]}}, :email=>committer["email"] }
|
61
62
|
block.call :activity=>{ :uid=>commit["id"], :html=>html, :url=>commit["url"], :tags=>"push",
|
62
|
-
:timestamp=>Time.parse(commit["committed_date"]).utc,
|
63
|
-
:person=>{ :name=>committer["name"], :url=>"http://github.com/#{committer["name"]}",
|
64
|
-
:email=>committer["email"] } }
|
63
|
+
:timestamp=>Time.parse(commit["committed_date"]).utc, :person=>person }
|
65
64
|
end
|
66
65
|
block.call :inc=>{ :commits=>new_ones.count }
|
67
66
|
else
|
data/test/backtweets_test.rb
CHANGED
@@ -1,24 +1,28 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/
|
1
|
+
require File.dirname(__FILE__) + "/setup"
|
2
2
|
|
3
3
|
test Vanity::Source::Backtweets do
|
4
4
|
context "setup" do
|
5
5
|
setup { setup_source "url"=>"vanity.labnotes.org" }
|
6
6
|
|
7
|
-
should "use URL" do
|
7
|
+
should "use normalize URL and remove scheme" do
|
8
|
+
setup_source "url"=>"http://Vanity.Labnotes.Org"
|
8
9
|
assert_equal "Tweets for vanity.labnotes.org", metric.name
|
9
10
|
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
end
|
12
|
+
context "metric" do
|
13
|
+
subject { metric }
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
should "use URL" do
|
16
|
+
assert_equal "Tweets for vanity.labnotes.org", subject.name
|
17
|
+
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
should "measure totals" do
|
20
|
+
assert subject.totals
|
21
|
+
end
|
22
|
+
|
23
|
+
should "capture tweets" do
|
24
|
+
assert subject.columns.include?(:id=>"tweets", :label=>"Tweets")
|
25
|
+
end
|
22
26
|
end
|
23
27
|
end
|
24
28
|
|
@@ -30,7 +34,7 @@ test Vanity::Source::Backtweets do
|
|
30
34
|
|
31
35
|
should "create valid metric" do
|
32
36
|
setup_source "url"=>"vanity.labnotes.org"
|
33
|
-
|
37
|
+
assert metric.valid?
|
34
38
|
end
|
35
39
|
end
|
36
40
|
|
@@ -84,41 +88,50 @@ test Vanity::Source::Backtweets do
|
|
84
88
|
end
|
85
89
|
|
86
90
|
context "activity" do
|
91
|
+
subject { activity }
|
87
92
|
|
88
93
|
should "capture tweet identifier" do
|
89
|
-
assert_equal "20959239300",
|
94
|
+
assert_equal "20959239300", subject.uid
|
90
95
|
end
|
91
96
|
|
92
97
|
should "capture tweet text" do
|
93
|
-
assert_equal <<-HTML,
|
98
|
+
assert_equal <<-HTML, subject.html
|
94
99
|
<a href="http://twitter.com/assaf/20959239300">tweeted</a>:
|
95
100
|
<blockquote>Super awesome <a href="http://vanity.labnotes.org/">http://j.mp/aOrUnsz</a></blockquote>
|
96
101
|
HTML
|
97
102
|
end
|
98
103
|
|
99
104
|
should "capture tweet URL" do
|
100
|
-
assert_equal "http://twitter.com/assaf/20959239300",
|
105
|
+
assert_equal "http://twitter.com/assaf/20959239300", subject.url
|
101
106
|
end
|
102
107
|
|
103
108
|
should "capture tweet timestamp" do
|
104
|
-
assert_equal Time.parse("2010-8-22T05:00:04").utc,
|
109
|
+
assert_equal Time.parse("2010-8-22T05:00:04").utc, subject.timestamp
|
105
110
|
end
|
106
111
|
|
107
|
-
should "
|
108
|
-
|
112
|
+
should "tag as tweeter and mention" do
|
113
|
+
assert_contains subject.tags, "twitter"
|
114
|
+
assert_contains subject.tags, "mention"
|
109
115
|
end
|
110
116
|
|
111
|
-
should "
|
112
|
-
|
117
|
+
should "be valid" do
|
118
|
+
assert subject.valid?
|
113
119
|
end
|
114
120
|
|
115
|
-
|
116
|
-
|
117
|
-
end
|
121
|
+
context "author" do
|
122
|
+
subject { activity.person }
|
118
123
|
|
119
|
-
|
120
|
-
|
121
|
-
|
124
|
+
should "capture full name" do
|
125
|
+
assert_equal "assaf", subject.fullname
|
126
|
+
end
|
127
|
+
|
128
|
+
should "capture screen name" do
|
129
|
+
assert_contains subject.identities, "twitter.com:assaf"
|
130
|
+
end
|
131
|
+
|
132
|
+
should "capture photo" do
|
133
|
+
assert_equal "http://twitter.com/account/profile_image/assaf", subject.photo_url
|
134
|
+
end
|
122
135
|
end
|
123
136
|
end
|
124
137
|
|
@@ -129,9 +142,10 @@ test Vanity::Source::Backtweets do
|
|
129
142
|
|
130
143
|
context "meta" do
|
131
144
|
setup { setup_source "url"=>"vanity.labnotes.org" }
|
145
|
+
subject { meta }
|
132
146
|
|
133
147
|
should "link to search results" do
|
134
|
-
assert
|
148
|
+
assert subject.include?(:text=>"Search yourself", :url=>"http://backtweets.com/search?q=vanity.labnotes.org")
|
135
149
|
end
|
136
150
|
end
|
137
151
|
end
|
data/test/github_issues_test.rb
CHANGED
@@ -1,23 +1,27 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/
|
1
|
+
require File.dirname(__FILE__) + "/setup"
|
2
2
|
|
3
3
|
test Vanity::Source::GithubIssues do
|
4
4
|
context "setup" do
|
5
5
|
setup { setup_source "repo"=>"assaf/vanity" }
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
end
|
7
|
+
context "metric" do
|
8
|
+
subject { metric }
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
should "use repository name" do
|
11
|
+
assert_equal "Github Issues for assaf/vanity", subject.name
|
12
|
+
end
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
should "measure totals" do
|
15
|
+
assert subject.totals
|
16
|
+
end
|
17
|
+
|
18
|
+
should "capture open issues" do
|
19
|
+
assert subject.columns.include?(:id=>"open", :label=>"Open issues")
|
20
|
+
end
|
18
21
|
|
19
|
-
|
20
|
-
|
22
|
+
should "capture closed issues" do
|
23
|
+
assert subject.columns.include?(:id=>"closed", :label=>"Closed issues")
|
24
|
+
end
|
21
25
|
end
|
22
26
|
end
|
23
27
|
|
@@ -33,12 +37,12 @@ test Vanity::Source::GithubIssues do
|
|
33
37
|
|
34
38
|
should "allow alphanumeric, minus and underscore" do
|
35
39
|
setup_source "repo"=>"assaf/the-vanity_0"
|
36
|
-
|
40
|
+
assert metric.valid?
|
37
41
|
end
|
38
42
|
|
39
43
|
should "create valid metric" do
|
40
44
|
setup_source "repo"=>"assaf/vanity"
|
41
|
-
|
45
|
+
assert metric.valid?
|
42
46
|
end
|
43
47
|
end
|
44
48
|
|
@@ -112,62 +116,66 @@ test Vanity::Source::GithubIssues do
|
|
112
116
|
end
|
113
117
|
|
114
118
|
context "activity for open issue" do
|
115
|
-
|
116
|
-
@open = activities.first
|
117
|
-
end
|
119
|
+
subject { activities.first }
|
118
120
|
|
119
121
|
should "capture issue URL" do
|
120
|
-
assert_equal "http://github.com/assaf/vanity/issues#issue/22",
|
122
|
+
assert_equal "http://github.com/assaf/vanity/issues#issue/22", subject.url
|
121
123
|
end
|
122
124
|
|
123
125
|
should "use SHA1 for ID" do
|
124
|
-
assert_match /^[0-9a-f]{40}$/,
|
126
|
+
assert_match /^[0-9a-f]{40}$/, subject.uid
|
125
127
|
end
|
126
128
|
|
127
129
|
should "capture issue creation time" do
|
128
|
-
assert_equal Time.parse("2010/03/17 22:32:02 UTC"),
|
130
|
+
assert_equal Time.parse("2010/03/17 22:32:02 UTC"), subject.timestamp
|
129
131
|
end
|
130
132
|
|
131
133
|
should "capture issue title" do
|
132
|
-
assert_equal <<-HTML,
|
134
|
+
assert_equal <<-HTML, subject.html
|
133
135
|
opened <a href="http://github.com/assaf/vanity/issues#issue/22">issue 22</a> on assaf/vanity:
|
134
136
|
<blockquote>Option to use Google Analytics for A/B testing</blockquote>
|
135
137
|
HTML
|
136
138
|
end
|
137
139
|
|
138
140
|
should "tag as issue and open" do
|
139
|
-
assert_contains
|
140
|
-
assert_contains
|
141
|
+
assert_contains subject.tags, "issue"
|
142
|
+
assert_contains subject.tags, "opened"
|
143
|
+
end
|
144
|
+
|
145
|
+
should "be valid" do
|
146
|
+
assert subject.valid?
|
141
147
|
end
|
142
148
|
end
|
143
149
|
|
144
150
|
context "activity for closed issue" do
|
145
|
-
|
146
|
-
@closed = activities.last
|
147
|
-
end
|
151
|
+
subject { activities.last }
|
148
152
|
|
149
153
|
should "capture issue URL" do
|
150
|
-
assert_equal "http://github.com/assaf/vanity/issues#issue/19",
|
154
|
+
assert_equal "http://github.com/assaf/vanity/issues#issue/19", subject.url
|
151
155
|
end
|
152
156
|
|
153
157
|
should "use SHA1 for ID" do
|
154
|
-
assert_match /^[0-9a-f]{40}$/,
|
158
|
+
assert_match /^[0-9a-f]{40}$/, subject.uid
|
155
159
|
end
|
156
160
|
|
157
161
|
should "capture issue closing time" do
|
158
|
-
assert_equal Time.parse("2010/07/03 04:16:42 UTC"),
|
162
|
+
assert_equal Time.parse("2010/07/03 04:16:42 UTC"), subject.timestamp
|
159
163
|
end
|
160
164
|
|
161
165
|
should "capture issue title" do
|
162
|
-
assert_equal <<-HTML,
|
166
|
+
assert_equal <<-HTML, subject.html
|
163
167
|
closed <a href="http://github.com/assaf/vanity/issues#issue/19">issue 19</a> on assaf/vanity:
|
164
168
|
<blockquote>Passwords not supported for the Redis config</blockquote>
|
165
169
|
HTML
|
166
170
|
end
|
167
171
|
|
168
172
|
should "tag as issue and closed" do
|
169
|
-
assert_contains
|
170
|
-
assert_contains
|
173
|
+
assert_contains subject.tags, "issue"
|
174
|
+
assert_contains subject.tags, "closed"
|
175
|
+
end
|
176
|
+
|
177
|
+
should "be valid" do
|
178
|
+
assert subject.valid?
|
171
179
|
end
|
172
180
|
end
|
173
181
|
|
@@ -177,9 +185,10 @@ closed <a href="http://github.com/assaf/vanity/issues#issue/19">issue 19</a> on
|
|
177
185
|
|
178
186
|
context "meta" do
|
179
187
|
setup { setup_source "repo"=>"assaf/vanity" }
|
188
|
+
subject { meta }
|
180
189
|
|
181
190
|
should "link to repository" do
|
182
|
-
assert_contains
|
191
|
+
assert_contains subject, :title=>"On Github", :url=>"http://github.com/assaf/vanity/issues"
|
183
192
|
end
|
184
193
|
end
|
185
194
|
end
|
data/test/github_test.rb
CHANGED
@@ -1,32 +1,36 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/
|
1
|
+
require File.dirname(__FILE__) + "/setup"
|
2
2
|
|
3
3
|
test Vanity::Source::Github do
|
4
4
|
context "setup" do
|
5
5
|
setup { setup_source "repo"=>"assaf/vanity", "branch"=>"master" }
|
6
6
|
|
7
|
-
should "
|
8
|
-
|
7
|
+
should "default branch to master" do
|
8
|
+
setup_source "repo"=>"assaf/vanity", "branch"=>" "
|
9
|
+
assert_equal "master", context["branch"]
|
9
10
|
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
end
|
12
|
+
context "metric" do
|
13
|
+
subject { metric }
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
should "use repository name" do
|
16
|
+
assert_equal "Github: assaf/vanity", subject.name
|
17
|
+
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
should "measure totals" do
|
20
|
+
assert subject.totals
|
21
|
+
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
should "capture commits" do
|
24
|
+
assert subject.columns.include?(:id=>"commits", :label=>"Commits")
|
25
|
+
end
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
should "capture watchers" do
|
28
|
+
assert subject.columns.include?(:id=>"watchers", :label=>"Watchers")
|
29
|
+
end
|
30
|
+
|
31
|
+
should "capture forks" do
|
32
|
+
assert subject.columns.include?(:id=>"forks", :label=>"Forks")
|
33
|
+
end
|
30
34
|
end
|
31
35
|
end
|
32
36
|
|
@@ -42,12 +46,12 @@ test Vanity::Source::Github do
|
|
42
46
|
|
43
47
|
should "allow alphanumeric, minus and underscore" do
|
44
48
|
setup_source "repo"=>"assaf/the-vanity_0", "branch"=>"master"
|
45
|
-
|
49
|
+
assert metric.valid?
|
46
50
|
end
|
47
51
|
|
48
52
|
should "create valid metric" do
|
49
53
|
setup_source "repo"=>"assaf/vanity", "branch"=>"master"
|
50
|
-
|
54
|
+
assert metric.valid?
|
51
55
|
end
|
52
56
|
end
|
53
57
|
|
@@ -126,36 +130,45 @@ test Vanity::Source::Github do
|
|
126
130
|
end
|
127
131
|
|
128
132
|
context "activity" do
|
133
|
+
subject { activity }
|
129
134
|
|
130
135
|
should "capture commit URL" do
|
131
|
-
assert_equal "http://github.com/assaf/vanity/commit/dd154a9fdd2ac534b62b55b8acac2fd092d65439",
|
136
|
+
assert_equal "http://github.com/assaf/vanity/commit/dd154a9fdd2ac534b62b55b8acac2fd092d65439", subject.url
|
132
137
|
end
|
133
138
|
|
134
139
|
should "capture commit SHA" do
|
135
|
-
assert_equal "dd154a9fdd2ac534b62b55b8acac2fd092d65439",
|
140
|
+
assert_equal "dd154a9fdd2ac534b62b55b8acac2fd092d65439", subject.uid
|
136
141
|
end
|
137
142
|
|
138
143
|
should "capture timestamp" do
|
139
|
-
assert_equal Time.parse("2010-08-06T00:22:01-07:00 UTC"),
|
144
|
+
assert_equal Time.parse("2010-08-06T00:22:01-07:00 UTC"), subject.timestamp
|
140
145
|
end
|
141
146
|
|
142
147
|
should "capture commit message and SHA1" do
|
143
|
-
assert_equal <<-HTML,
|
148
|
+
assert_equal <<-HTML, subject.html
|
144
149
|
pushed to master at <a href="http://github.com/assaf/vanity">assaf/vanity</a>:
|
145
150
|
<blockquote><a href="http://github.com/assaf/vanity/commit/dd154a9fdd2ac534b62b55b8acac2fd092d65439">dd154a9</a> Third & last</blockquote>
|
146
151
|
HTML
|
147
152
|
end
|
148
153
|
|
149
|
-
should "
|
150
|
-
|
154
|
+
should "tag as push" do
|
155
|
+
assert_contains subject.tags, "push"
|
151
156
|
end
|
152
|
-
|
153
|
-
should "
|
154
|
-
|
157
|
+
|
158
|
+
should "be valid" do
|
159
|
+
assert subject.valid?
|
155
160
|
end
|
156
161
|
|
157
|
-
|
158
|
-
|
162
|
+
context "person" do
|
163
|
+
subject { activity.person }
|
164
|
+
|
165
|
+
should "capture full name" do
|
166
|
+
assert_equal "Assaf Arkin", subject.fullname
|
167
|
+
end
|
168
|
+
|
169
|
+
should "capture email" do
|
170
|
+
assert_equal "assaf@labnotes.org", subject.email
|
171
|
+
end
|
159
172
|
end
|
160
173
|
end
|
161
174
|
|
@@ -165,25 +178,26 @@ pushed to master at <a href="http://github.com/assaf/vanity">assaf/vanity</a>:
|
|
165
178
|
|
166
179
|
context "meta" do
|
167
180
|
setup { setup_source "repo"=>"assaf/vanity", "branch"=>"master" }
|
181
|
+
subject { meta }
|
168
182
|
|
169
183
|
should "link to repository" do
|
170
|
-
assert_contains
|
184
|
+
assert_contains subject, :title=>"Repository", :text=>"assaf/vanity", :url=>"http://github.com/assaf/vanity"
|
171
185
|
end
|
172
186
|
|
173
187
|
should "include project description" do
|
174
|
-
assert_contains
|
188
|
+
assert_contains subject, :text=>"Experiment Driven Development for Ruby"
|
175
189
|
end
|
176
190
|
|
177
191
|
should "link to project home page" do
|
178
|
-
assert_contains
|
192
|
+
assert_contains subject, :title=>"Home page", :url=>"http://vanity.labnotes.org"
|
179
193
|
end
|
180
194
|
|
181
195
|
should "list branch name" do
|
182
|
-
assert_contains
|
196
|
+
assert_contains subject, :title=>"Branch", :text=>"master"
|
183
197
|
end
|
184
198
|
|
185
199
|
should "show last commit message" do
|
186
|
-
assert_contains
|
200
|
+
assert_contains subject, :title=>"Commit", :text=>"Gemfile changes necessary to pass test suite.",
|
187
201
|
:url=>"http://github.com/assaf/vanity/commit/dd154a9fdd2ac534b62b55b8acac2fd092d6543a"
|
188
202
|
end
|
189
203
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Activity
|
2
|
+
def initialize(args = {})
|
3
|
+
args.each do |name, value|
|
4
|
+
send "#{name}=", value
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_accessor :uid, :html, :text, :url, :timestamp, :tags, :person
|
9
|
+
|
10
|
+
def valid?
|
11
|
+
validate rescue return false
|
12
|
+
return true
|
13
|
+
end
|
14
|
+
|
15
|
+
def validate
|
16
|
+
raise "Must specify html or text" if html.blank? && text.blank?
|
17
|
+
raise "Tags must be alphanumeric, underscores allowed" unless tags.nil? || tags.all? { |tag| tag =~ /^[\w_]+$/ }
|
18
|
+
person.validate if person
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class Metric
|
2
|
+
def initialize(args = {})
|
3
|
+
args.each do |name, value|
|
4
|
+
send "#{name}=", value
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_accessor :name, :columns, :totals
|
9
|
+
|
10
|
+
def valid?
|
11
|
+
validate rescue return false
|
12
|
+
return true
|
13
|
+
end
|
14
|
+
|
15
|
+
def validate
|
16
|
+
fail "Metric name missing or a blank string" if name.blank?
|
17
|
+
fail "Metric must have at least one column" if columns.empty?
|
18
|
+
col_ids = columns.map { |col| col[:id] }
|
19
|
+
fail "All metric columns must have an id" unless col_ids.all? { |col_id| col_id }
|
20
|
+
fail "Metric columns must have unique ids" unless col_ids.uniq == col_ids
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class Person
|
2
|
+
|
3
|
+
def initialize(args = {})
|
4
|
+
args.each do |name, value|
|
5
|
+
send "#{name}=", value
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_accessor :fullname, :email, :identities, :photo_url
|
10
|
+
|
11
|
+
def valid?
|
12
|
+
validate rescue return false
|
13
|
+
return true
|
14
|
+
end
|
15
|
+
|
16
|
+
def validate
|
17
|
+
if photo_url
|
18
|
+
uri = URI.parse(photo_url)
|
19
|
+
fail "Photo URL must be absolute HTTP URL" unless uri.scheme == "http" && uri.absolute?
|
20
|
+
end
|
21
|
+
fail "Identities must be of the form name:value" unless identities.nil? || identities.all? { |id| id =~ /^[\w\.]+:.+$/ }
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -1,15 +1,3 @@
|
|
1
|
-
require "test/unit"
|
2
|
-
require "shoulda"
|
3
|
-
require "webmock/test_unit"
|
4
|
-
require "vcr"
|
5
|
-
|
6
|
-
|
7
|
-
require File.dirname(__FILE__) + "/../lib/vanity/source"
|
8
|
-
Dir[File.dirname(__FILE__) + "/../lib/vanity/sources/*.rb"].each do |file|
|
9
|
-
require file
|
10
|
-
end
|
11
|
-
|
12
|
-
# Use this to define test suite for a source class. Creates a new TestCase
|
13
1
|
# class, includes the modules Vanity::Source::TestHelpers and Webmock, sets the
|
14
2
|
# source class, and other nicities.
|
15
3
|
#
|
@@ -29,29 +17,11 @@ def test(klass, &block)
|
|
29
17
|
end
|
30
18
|
end
|
31
19
|
|
32
|
-
Vanity::Source.logger = Logger.new("test/test.log")
|
33
|
-
Vanity::Source.api_keys = YAML.load_file("test/api_keys.yml")
|
34
|
-
|
35
|
-
|
36
|
-
WebMock.disable_net_connect!
|
37
|
-
VCR.config do |vcr|
|
38
|
-
vcr.cassette_library_dir = File.dirname(__FILE__) + "/cassettes"
|
39
|
-
vcr.http_stubbing_library = :webmock
|
40
|
-
vcr.default_cassette_options = { :record=>ENV["RECORD"] ? :new_episodes : :none }
|
41
|
-
end
|
42
20
|
|
43
21
|
module Vanity
|
44
22
|
module Source
|
45
23
|
module TestHelpers
|
46
|
-
# Represents an activity.
|
47
|
-
Activity = Struct.new(:uid, :html, :text, :url, :timestamp, :tags, :person)
|
48
24
|
|
49
|
-
# Represents person associated with activity.
|
50
|
-
Person = Struct.new(:name, :email, :url, :photo)
|
51
|
-
|
52
|
-
# Represents a metric.
|
53
|
-
Metric = Struct.new(:name, :columns, :totals)
|
54
|
-
|
55
25
|
# Default setup. If you override setup, remember to call super.
|
56
26
|
def setup
|
57
27
|
WebMock.reset_webmock
|
@@ -104,7 +74,8 @@ module Vanity
|
|
104
74
|
# @example
|
105
75
|
# assert_equal "My metric", metric.name
|
106
76
|
def metric
|
107
|
-
|
77
|
+
values = { :name=>context["metric.name"], :columns=>context["metric.columns"], :totals=>!!context["metric.totals"] }
|
78
|
+
Metric.new(values)
|
108
79
|
end
|
109
80
|
|
110
81
|
def collector
|
@@ -117,11 +88,11 @@ module Vanity
|
|
117
88
|
totals[name] += value
|
118
89
|
end
|
119
90
|
elsif args[:activity]
|
120
|
-
values = args[:activity].
|
121
|
-
if person =
|
122
|
-
values
|
91
|
+
values = args[:activity].clone
|
92
|
+
if person = values.delete(:person)
|
93
|
+
values[:person] = Person.new(person)
|
123
94
|
end
|
124
|
-
activities.push Activity.new(
|
95
|
+
activities.push Activity.new(values)
|
125
96
|
end
|
126
97
|
end
|
127
98
|
end
|
@@ -156,19 +127,6 @@ module Vanity
|
|
156
127
|
activities.last
|
157
128
|
end
|
158
129
|
|
159
|
-
# Validates a metric.
|
160
|
-
#
|
161
|
-
# @example
|
162
|
-
# setup_source "gem_name"=>"vanity"
|
163
|
-
# assert_valid metric
|
164
|
-
def assert_valid(metric)
|
165
|
-
assert !metric.name.blank?, "Metric name missing or a blank string"
|
166
|
-
assert metric.columns.length > 0, "Metric must have at least one column"
|
167
|
-
col_ids = metric.columns.map { |col| col[:id] }
|
168
|
-
assert col_ids.all? { |col_id| col_id }, "All metric columns must have an id"
|
169
|
-
assert col_ids.uniq == col_ids, "Metric columns must have unique ids"
|
170
|
-
end
|
171
|
-
|
172
130
|
# Returns the named fixture. Fixture looked up in the file
|
173
131
|
# test/fixtures/<source_id>.rb
|
174
132
|
def fixture(name)
|
data/test/ruby_gems_test.rb
CHANGED
@@ -1,19 +1,23 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/
|
1
|
+
require File.dirname(__FILE__) + "/setup"
|
2
2
|
|
3
3
|
test Vanity::Source::RubyGems do
|
4
4
|
context "setup" do
|
5
5
|
setup { setup_source "gem_name"=>"vanity" }
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
end
|
7
|
+
context "metric" do
|
8
|
+
subject { metric }
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
should "use gem name" do
|
11
|
+
assert_equal "RubyGems: vanity", subject.name
|
12
|
+
end
|
13
|
+
|
14
|
+
should "measure totals" do
|
15
|
+
assert subject.totals
|
16
|
+
end
|
14
17
|
|
15
|
-
|
16
|
-
|
18
|
+
should "capture downloads" do
|
19
|
+
assert subject.columns.include?(:id=>"downloads", :label=>"Downloads")
|
20
|
+
end
|
17
21
|
end
|
18
22
|
end
|
19
23
|
|
@@ -25,7 +29,7 @@ test Vanity::Source::RubyGems do
|
|
25
29
|
|
26
30
|
should "create valid metric" do
|
27
31
|
setup_source "gem_name"=>"vanity"
|
28
|
-
|
32
|
+
assert metric.valid?
|
29
33
|
end
|
30
34
|
end
|
31
35
|
|
@@ -88,22 +92,28 @@ test Vanity::Source::RubyGems do
|
|
88
92
|
end
|
89
93
|
|
90
94
|
context "activity" do
|
95
|
+
subject { activity }
|
96
|
+
|
91
97
|
should "should have unique identifier" do
|
92
|
-
assert_equal "vanity-2.1.0",
|
98
|
+
assert_equal "vanity-2.1.0", subject.uid
|
93
99
|
end
|
94
100
|
|
95
101
|
should "report release number" do
|
96
|
-
assert_equal <<-HTML.strip,
|
102
|
+
assert_equal <<-HTML.strip, subject.html
|
97
103
|
released <a href=\"http://rubygems.org/gems/vanity/versions/2.1.0\">vanity version 2.1.0</a>.
|
98
104
|
HTML
|
99
105
|
end
|
100
106
|
|
101
107
|
should "link to project page" do
|
102
|
-
assert_equal "http://rubygems.org/gems/vanity",
|
108
|
+
assert_equal "http://rubygems.org/gems/vanity", subject.url
|
103
109
|
end
|
104
110
|
|
105
111
|
should "tag as release" do
|
106
|
-
assert_contains
|
112
|
+
assert_contains subject.tags, "release"
|
113
|
+
end
|
114
|
+
|
115
|
+
should "be valid" do
|
116
|
+
assert subject.valid?
|
107
117
|
end
|
108
118
|
end
|
109
119
|
end
|
@@ -112,25 +122,26 @@ released <a href=\"http://rubygems.org/gems/vanity/versions/2.1.0\">vanity versi
|
|
112
122
|
|
113
123
|
context "meta" do
|
114
124
|
setup { setup_source "gem_name"=>"vanity" }
|
125
|
+
subject { meta }
|
115
126
|
|
116
127
|
should "link to project page" do
|
117
|
-
assert_contains
|
128
|
+
assert_contains subject, :title=>"Project", :text=>"vanity", :url=>"http://vanity.labnotes.org"
|
118
129
|
end
|
119
130
|
|
120
131
|
should "include project description" do
|
121
|
-
assert_contains
|
132
|
+
assert_contains subject, :text=>"Mirror, mirror on the wall ..."
|
122
133
|
end
|
123
134
|
|
124
135
|
should "include version number" do
|
125
|
-
assert_contains
|
136
|
+
assert_contains subject, :title=>"Version", :text=>"1.4.0"
|
126
137
|
end
|
127
138
|
|
128
139
|
should "list authors" do
|
129
|
-
assert_contains
|
140
|
+
assert_contains subject, :title=>"Authors", :text=>"Assaf Arkin"
|
130
141
|
end
|
131
142
|
|
132
143
|
should "link to RubyGems page" do
|
133
|
-
assert_contains
|
144
|
+
assert_contains subject, :title=>"Source", :text=>"RubyGems", :url=>"http://rubygems.org/gems/vanity"
|
134
145
|
end
|
135
146
|
end
|
136
147
|
end
|
data/test/setup.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require "shoulda"
|
3
|
+
require "webmock/test_unit"
|
4
|
+
require "vcr"
|
5
|
+
|
6
|
+
require "test/helpers/test"
|
7
|
+
require "test/helpers/person"
|
8
|
+
require "test/helpers/activity"
|
9
|
+
require "test/helpers/metric"
|
10
|
+
|
11
|
+
|
12
|
+
require File.dirname(__FILE__) + "/../lib/vanity/source"
|
13
|
+
Dir[File.dirname(__FILE__) + "/../lib/vanity/sources/*.rb"].each do |file|
|
14
|
+
require file
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
Vanity::Source.logger = Logger.new("test/test.log")
|
19
|
+
Vanity::Source.api_keys = YAML.load_file("test/api_keys.yml")
|
20
|
+
|
21
|
+
|
22
|
+
WebMock.disable_net_connect!
|
23
|
+
VCR.config do |vcr|
|
24
|
+
vcr.cassette_library_dir = File.dirname(__FILE__) + "/cassettes"
|
25
|
+
vcr.http_stubbing_library = :webmock
|
26
|
+
vcr.default_cassette_options = { :record=>ENV["RECORD"] ? :new_episodes : :none }
|
27
|
+
end
|
data/test/test.log
CHANGED
@@ -500,3 +500,115 @@ Backtweets: 200
|
|
500
500
|
Backtweets: 500
|
501
501
|
RubyGems: 200
|
502
502
|
RubyGems: 500
|
503
|
+
Backtweets: 500
|
504
|
+
Backtweets: 200
|
505
|
+
Backtweets: 200
|
506
|
+
Backtweets: 500
|
507
|
+
RubyGems: 200
|
508
|
+
RubyGems: 500
|
509
|
+
Backtweets: 500
|
510
|
+
Backtweets: 200
|
511
|
+
Backtweets: 200
|
512
|
+
Backtweets: 500
|
513
|
+
RubyGems: 200
|
514
|
+
RubyGems: 500
|
515
|
+
Backtweets: 500
|
516
|
+
Backtweets: 200
|
517
|
+
Backtweets: 200
|
518
|
+
Backtweets: 500
|
519
|
+
RubyGems: 200
|
520
|
+
RubyGems: 500
|
521
|
+
Backtweets: 500
|
522
|
+
Backtweets: 200
|
523
|
+
Backtweets: 200
|
524
|
+
Backtweets: 500
|
525
|
+
RubyGems: 200
|
526
|
+
RubyGems: 500
|
527
|
+
Backtweets: 500
|
528
|
+
Backtweets: 200
|
529
|
+
Backtweets: 200
|
530
|
+
Backtweets: 500
|
531
|
+
RubyGems: 200
|
532
|
+
RubyGems: 500
|
533
|
+
Backtweets: 500
|
534
|
+
Backtweets: 200
|
535
|
+
Backtweets: 200
|
536
|
+
Backtweets: 500
|
537
|
+
RubyGems: 200
|
538
|
+
RubyGems: 500
|
539
|
+
Backtweets: 500
|
540
|
+
Backtweets: 200
|
541
|
+
Backtweets: 200
|
542
|
+
Backtweets: 500
|
543
|
+
RubyGems: 200
|
544
|
+
RubyGems: 500
|
545
|
+
Backtweets: 500
|
546
|
+
Backtweets: 200
|
547
|
+
Backtweets: 200
|
548
|
+
Backtweets: 500
|
549
|
+
RubyGems: 200
|
550
|
+
RubyGems: 500
|
551
|
+
Backtweets: 500
|
552
|
+
Backtweets: 200
|
553
|
+
Backtweets: 200
|
554
|
+
Backtweets: 500
|
555
|
+
RubyGems: 200
|
556
|
+
RubyGems: 500
|
557
|
+
Backtweets: 500
|
558
|
+
Backtweets: 200
|
559
|
+
Backtweets: 200
|
560
|
+
Backtweets: 500
|
561
|
+
RubyGems: 200
|
562
|
+
RubyGems: 500
|
563
|
+
Backtweets: 500
|
564
|
+
Backtweets: 200
|
565
|
+
Backtweets: 200
|
566
|
+
Backtweets: 500
|
567
|
+
RubyGems: 200
|
568
|
+
RubyGems: 500
|
569
|
+
Backtweets: 500
|
570
|
+
Backtweets: 200
|
571
|
+
Backtweets: 200
|
572
|
+
Backtweets: 500
|
573
|
+
RubyGems: 200
|
574
|
+
RubyGems: 500
|
575
|
+
Backtweets: 500
|
576
|
+
Backtweets: 200
|
577
|
+
Backtweets: 200
|
578
|
+
Backtweets: 500
|
579
|
+
RubyGems: 200
|
580
|
+
RubyGems: 500
|
581
|
+
Backtweets: 200
|
582
|
+
Backtweets: 500
|
583
|
+
Backtweets: 200
|
584
|
+
Backtweets: 500
|
585
|
+
Backtweets: 200
|
586
|
+
Backtweets: 500
|
587
|
+
Backtweets: 500
|
588
|
+
Backtweets: 200
|
589
|
+
Backtweets: 500
|
590
|
+
Backtweets: 200
|
591
|
+
Backtweets: 500
|
592
|
+
Backtweets: 200
|
593
|
+
Backtweets: 500
|
594
|
+
Backtweets: 200
|
595
|
+
Backtweets: 500
|
596
|
+
Backtweets: 200
|
597
|
+
Backtweets: 500
|
598
|
+
Backtweets: 200
|
599
|
+
Backtweets: 200
|
600
|
+
Backtweets: 500
|
601
|
+
RubyGems: 200
|
602
|
+
RubyGems: 500
|
603
|
+
Backtweets: 500
|
604
|
+
Backtweets: 200
|
605
|
+
Backtweets: 200
|
606
|
+
Backtweets: 500
|
607
|
+
RubyGems: 200
|
608
|
+
RubyGems: 500
|
609
|
+
Backtweets: 500
|
610
|
+
Backtweets: 200
|
611
|
+
Backtweets: 200
|
612
|
+
Backtweets: 500
|
613
|
+
RubyGems: 200
|
614
|
+
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.11"
|
4
4
|
spec.author = "Assaf Arkin"
|
5
5
|
spec.email = "assaf@labnotes.org"
|
6
6
|
spec.homepage = "http://vanitydash.com"
|
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
"--webcvs", "http://github.com/assaf/#{spec.name}"
|
15
15
|
|
16
16
|
spec.required_ruby_version = '>= 1.8.7'
|
17
|
-
spec.add_dependency "activesupport"
|
18
|
-
spec.add_dependency "json"
|
19
|
-
spec.add_dependency "rack"
|
17
|
+
spec.add_dependency "activesupport"
|
18
|
+
spec.add_dependency "json"
|
19
|
+
spec.add_dependency "rack"
|
20
20
|
end
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vanity-source
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: "0.
|
8
|
+
- 11
|
9
|
+
version: "0.11"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Assaf Arkin
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-08-
|
17
|
+
date: 2010-08-30 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -23,13 +23,12 @@ dependencies:
|
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
25
25
|
requirements:
|
26
|
-
- -
|
26
|
+
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
hash:
|
28
|
+
hash: 3
|
29
29
|
segments:
|
30
|
-
-
|
31
|
-
|
32
|
-
version: "2.3"
|
30
|
+
- 0
|
31
|
+
version: "0"
|
33
32
|
type: :runtime
|
34
33
|
version_requirements: *id001
|
35
34
|
- !ruby/object:Gem::Dependency
|
@@ -38,13 +37,12 @@ dependencies:
|
|
38
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
38
|
none: false
|
40
39
|
requirements:
|
41
|
-
- -
|
40
|
+
- - ">="
|
42
41
|
- !ruby/object:Gem::Version
|
43
|
-
hash:
|
42
|
+
hash: 3
|
44
43
|
segments:
|
45
|
-
-
|
46
|
-
|
47
|
-
version: "1.4"
|
44
|
+
- 0
|
45
|
+
version: "0"
|
48
46
|
type: :runtime
|
49
47
|
version_requirements: *id002
|
50
48
|
- !ruby/object:Gem::Dependency
|
@@ -53,13 +51,12 @@ dependencies:
|
|
53
51
|
requirement: &id003 !ruby/object:Gem::Requirement
|
54
52
|
none: false
|
55
53
|
requirements:
|
56
|
-
- -
|
54
|
+
- - ">="
|
57
55
|
- !ruby/object:Gem::Version
|
58
|
-
hash:
|
56
|
+
hash: 3
|
59
57
|
segments:
|
60
|
-
-
|
61
|
-
|
62
|
-
version: "1.2"
|
58
|
+
- 0
|
59
|
+
version: "0"
|
63
60
|
type: :runtime
|
64
61
|
version_requirements: *id003
|
65
62
|
description:
|
@@ -89,9 +86,13 @@ files:
|
|
89
86
|
- test/cassettes/ruby_gems.yml
|
90
87
|
- test/github_issues_test.rb
|
91
88
|
- test/github_test.rb
|
89
|
+
- test/helpers/activity.rb
|
90
|
+
- test/helpers/metric.rb
|
91
|
+
- test/helpers/person.rb
|
92
|
+
- test/helpers/test.rb
|
92
93
|
- test/ruby_gems_test.rb
|
94
|
+
- test/setup.rb
|
93
95
|
- test/test.log
|
94
|
-
- test/test_helper.rb
|
95
96
|
- CHANGELOG
|
96
97
|
- MIT-LICENSE
|
97
98
|
- README.rdoc
|
@@ -105,7 +106,7 @@ licenses: []
|
|
105
106
|
post_install_message:
|
106
107
|
rdoc_options:
|
107
108
|
- --title
|
108
|
-
- Vanity::Source 0.
|
109
|
+
- Vanity::Source 0.11
|
109
110
|
- --main
|
110
111
|
- README.rdoc
|
111
112
|
- --webcvs
|