vanity-source 0.9 → 0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/lib/vanity/source.rb +18 -0
- data/lib/vanity/sources/backtweets.rb +6 -1
- data/lib/vanity/sources/github.rb +4 -4
- data/lib/vanity/sources/github_issues.rb +14 -6
- data/lib/vanity/sources/ruby_gems.rb +2 -1
- data/test/backtweets_test.rb +8 -1
- data/test/github_issues_test.rb +18 -2
- data/test/github_test.rb +6 -3
- data/test/ruby_gems_test.rb +8 -2
- data/test/test.log +150 -0
- data/test/test_helper.rb +2 -2
- data/vanity-source.gemspec +1 -1
- metadata +5 -5
data/CHANGELOG
CHANGED
data/lib/vanity/source.rb
CHANGED
@@ -69,6 +69,24 @@ module Vanity
|
|
69
69
|
# be positive or negative. This is a hash where the keys are column ids (or
|
70
70
|
# indexes), the values are integers or floats.
|
71
71
|
# * timestamp -- The Time (if missing, uses the current system time).
|
72
|
+
# * activity -- Activity to show in the stream. See below.
|
73
|
+
#
|
74
|
+
# Activity can specify the following attributes:
|
75
|
+
# * uid -- Unique identifier (within the scope of this source). For example,
|
76
|
+
# if activity is a release, this could be the version number.
|
77
|
+
# * html -- HTML contents of the activity.
|
78
|
+
# * text -- Text contents of the activity (can be used instead of html).
|
79
|
+
# * url -- URL for original resource (e.g. blog post, tweet).
|
80
|
+
# * tags -- Any number of tags for filtering activities like this (e.g.
|
81
|
+
# twitter, mention). Tags are lowercased and can contain alphanumeric,
|
82
|
+
# dashes and underscore.
|
83
|
+
# * person -- Person who performed this activity. A hash with the (all
|
84
|
+
# optional) values :name, :email, :url and :photo.
|
85
|
+
# * timestamp -- Timestamp activity occurred.
|
86
|
+
#
|
87
|
+
# HTML can contain links (HTTP/S and email), images, bold, italics,
|
88
|
+
# paragraphs, block quotes, lists, tables, pre-formatted text, video and a few
|
89
|
+
# other elements. Scripts, objects, styles are obviously not allowed.
|
72
90
|
#
|
73
91
|
# Occasionally, the #meta method is called. This method is used to display
|
74
92
|
# meta-data from the most recent state (i.e. last update). It returns an array
|
@@ -32,7 +32,12 @@ module Vanity
|
|
32
32
|
new_ones = tweets.take_while { |tweet| tweet["tweet_id"] != last_tweet_id }.reverse
|
33
33
|
new_ones.each do |tweet|
|
34
34
|
handle, id = tweet["tweet_from_user"], tweet["tweet_id"]
|
35
|
-
|
35
|
+
url = "http://twitter.com/#{handle}/#{id}"
|
36
|
+
html = <<-HTML
|
37
|
+
<a href="#{url}">tweeted</a>:
|
38
|
+
<blockquote>#{tweet["tweet_text"]}</blockquote>
|
39
|
+
HTML
|
40
|
+
block.call :activity=>{ :uid=>id, :url=>url, :html=>html, :tags=>%w{twitter mention},
|
36
41
|
:timestamp=>Time.parse(tweet["tweet_created_at"]).utc,
|
37
42
|
:person=>{ :name=>handle, :url=>"http://twitter.com/#{handle}", :photo=>tweet["tweet_profile_image_url"] } }
|
38
43
|
end
|
@@ -54,11 +54,11 @@ module Vanity
|
|
54
54
|
new_ones = commits.take_while { |commit| commit["id"] != last_seen_id }
|
55
55
|
new_ones.reverse.each do |commit|
|
56
56
|
committer = commit["committer"]
|
57
|
-
|
58
|
-
|
59
|
-
<
|
57
|
+
html = <<-HTML
|
58
|
+
pushed to #{h context["branch"]} at <a href="http://github.com/#{context["repo"]}">#{h context["repo"]}</a>:
|
59
|
+
<blockquote><a href="#{commit["url"]}">#{commit["id"][0,7]}</a> #{h commit["message"]}</blockquote>
|
60
60
|
HTML
|
61
|
-
block.call :activity=>{ :uid=>commit["id"], :html=>
|
61
|
+
block.call :activity=>{ :uid=>commit["id"], :html=>html, :url=>commit["url"], :tags=>"push",
|
62
62
|
:timestamp=>Time.parse(commit["committed_date"]).utc,
|
63
63
|
:person=>{ :name=>committer["name"], :url=>"http://github.com/#{committer["name"]}",
|
64
64
|
:email=>committer["email"] } }
|
@@ -37,9 +37,13 @@ module Vanity
|
|
37
37
|
if open_ids = context["open-ids"]
|
38
38
|
open.reject { |issue| open_ids.include?(issue["number"]) }.reverse.each do |issue|
|
39
39
|
sha = Digest::SHA1.hexdigest([context["repo"], "open", issue["number"], issue["updated_at"]].join(":"))
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
url = "http://github.com/#{context["repo"]}/issues#issue/#{issue["number"]}"
|
41
|
+
html = <<-HTML
|
42
|
+
opened <a href="#{url}">issue #{issue["number"]}</a> on #{context["repo"]}:
|
43
|
+
<blockquote>#{h issue["title"]}</blockquote>
|
44
|
+
HTML
|
45
|
+
block.call :activity=>{ :uid=>sha, :url=>url, :html=>html, :tags=>%w{issue opened},
|
46
|
+
:timestamp=>Time.parse(issue["created_at"]).utc }
|
43
47
|
end
|
44
48
|
end
|
45
49
|
context["open-ids"] = open.map { |issue| issue["number"] }
|
@@ -54,9 +58,13 @@ module Vanity
|
|
54
58
|
if closed_ids = context["closed-ids"]
|
55
59
|
closed.reject { |issue| closed_ids.include?(issue["number"]) }.reverse.each do |issue|
|
56
60
|
sha = Digest::SHA1.hexdigest([context["repo"], "closed", issue["number"], issue["updated_at"]].join(":"))
|
57
|
-
|
58
|
-
|
59
|
-
|
61
|
+
url = "http://github.com/#{context["repo"]}/issues#issue/#{issue["number"]}"
|
62
|
+
html = <<-HTML
|
63
|
+
closed <a href="#{url}">issue #{issue["number"]}</a> on #{context["repo"]}:
|
64
|
+
<blockquote>#{h issue["title"]}</blockquote>
|
65
|
+
HTML
|
66
|
+
block.call :activity=>{ :uid=>sha, :url=>url, :html=>html, :tags=>%w{issue closed},
|
67
|
+
:timestamp=>Time.parse(issue["closed_at"]).utc }
|
60
68
|
end
|
61
69
|
end
|
62
70
|
context["closed-ids"] = closed.map { |issue| issue["number"] }
|
@@ -33,8 +33,9 @@ module Vanity
|
|
33
33
|
if context["version"]
|
34
34
|
current, latest = Gem::Version.new(context["version"]), Gem::Version.new(json["version"])
|
35
35
|
if latest > current
|
36
|
+
html = "released <a href=\"http://rubygems.org/gems/#{gem_name}/versions/#{latest}\">#{gem_name} version #{latest}</a>."
|
36
37
|
yield :activity=>{ :uid=>"#{gem_name}-#{latest}", :url=>"http://rubygems.org/gems/#{gem_name}",
|
37
|
-
:html=>
|
38
|
+
:html=>html, :tags=>%w{release} }
|
38
39
|
end
|
39
40
|
end
|
40
41
|
context["version"] = json["version"]
|
data/test/backtweets_test.rb
CHANGED
@@ -90,7 +90,10 @@ test Vanity::Source::Backtweets do
|
|
90
90
|
end
|
91
91
|
|
92
92
|
should "capture tweet text" do
|
93
|
-
assert_equal
|
93
|
+
assert_equal <<-HTML, activity.html
|
94
|
+
<a href="http://twitter.com/assaf/20959239300">tweeted</a>:
|
95
|
+
<blockquote>Super awesome <a href="http://vanity.labnotes.org/">http://j.mp/aOrUnsz</a></blockquote>
|
96
|
+
HTML
|
94
97
|
end
|
95
98
|
|
96
99
|
should "capture tweet URL" do
|
@@ -113,6 +116,10 @@ test Vanity::Source::Backtweets do
|
|
113
116
|
assert_equal "http://twitter.com/account/profile_image/assaf", activity.person.photo
|
114
117
|
end
|
115
118
|
|
119
|
+
should "tag as tweeter and mention" do
|
120
|
+
assert_contains activity.tags, "twitter"
|
121
|
+
assert_contains activity.tags, "mention"
|
122
|
+
end
|
116
123
|
end
|
117
124
|
|
118
125
|
end
|
data/test/github_issues_test.rb
CHANGED
@@ -129,7 +129,15 @@ test Vanity::Source::GithubIssues do
|
|
129
129
|
end
|
130
130
|
|
131
131
|
should "capture issue title" do
|
132
|
-
assert_equal
|
132
|
+
assert_equal <<-HTML, @open.html
|
133
|
+
opened <a href="http://github.com/assaf/vanity/issues#issue/22">issue 22</a> on assaf/vanity:
|
134
|
+
<blockquote>Option to use Google Analytics for A/B testing</blockquote>
|
135
|
+
HTML
|
136
|
+
end
|
137
|
+
|
138
|
+
should "tag as issue and open" do
|
139
|
+
assert_contains @open.tags, "issue"
|
140
|
+
assert_contains @open.tags, "opened"
|
133
141
|
end
|
134
142
|
end
|
135
143
|
|
@@ -151,7 +159,15 @@ test Vanity::Source::GithubIssues do
|
|
151
159
|
end
|
152
160
|
|
153
161
|
should "capture issue title" do
|
154
|
-
assert_equal
|
162
|
+
assert_equal <<-HTML, @closed.html
|
163
|
+
closed <a href="http://github.com/assaf/vanity/issues#issue/19">issue 19</a> on assaf/vanity:
|
164
|
+
<blockquote>Passwords not supported for the Redis config</blockquote>
|
165
|
+
HTML
|
166
|
+
end
|
167
|
+
|
168
|
+
should "tag as issue and closed" do
|
169
|
+
assert_contains @closed.tags, "issue"
|
170
|
+
assert_contains @closed.tags, "closed"
|
155
171
|
end
|
156
172
|
end
|
157
173
|
|
data/test/github_test.rb
CHANGED
@@ -139,10 +139,10 @@ test Vanity::Source::Github do
|
|
139
139
|
assert_equal Time.parse("2010-08-06T00:22:01-07:00 UTC"), activity.timestamp
|
140
140
|
end
|
141
141
|
|
142
|
-
should "capture commit message" do
|
142
|
+
should "capture commit message and SHA1" do
|
143
143
|
assert_equal <<-HTML, activity.html
|
144
|
-
|
145
|
-
<
|
144
|
+
pushed to master at <a href="http://github.com/assaf/vanity">assaf/vanity</a>:
|
145
|
+
<blockquote><a href="http://github.com/assaf/vanity/commit/dd154a9fdd2ac534b62b55b8acac2fd092d65439">dd154a9</a> Third & last</blockquote>
|
146
146
|
HTML
|
147
147
|
end
|
148
148
|
|
@@ -154,6 +154,9 @@ test Vanity::Source::Github do
|
|
154
154
|
assert_equal "assaf@labnotes.org", activity.person.email
|
155
155
|
end
|
156
156
|
|
157
|
+
should "tag as push" do
|
158
|
+
assert_contains activity.tags, "push"
|
159
|
+
end
|
157
160
|
end
|
158
161
|
|
159
162
|
end
|
data/test/ruby_gems_test.rb
CHANGED
@@ -92,13 +92,19 @@ test Vanity::Source::RubyGems do
|
|
92
92
|
assert_equal "vanity-2.1.0", activity.uid
|
93
93
|
end
|
94
94
|
|
95
|
-
should "
|
96
|
-
assert_equal
|
95
|
+
should "report release number" do
|
96
|
+
assert_equal <<-HTML.strip, activity.html
|
97
|
+
released <a href=\"http://rubygems.org/gems/vanity/versions/2.1.0\">vanity version 2.1.0</a>.
|
98
|
+
HTML
|
97
99
|
end
|
98
100
|
|
99
101
|
should "link to project page" do
|
100
102
|
assert_equal "http://rubygems.org/gems/vanity", activity.url
|
101
103
|
end
|
104
|
+
|
105
|
+
should "tag as release" do
|
106
|
+
assert_contains activity.tags, "release"
|
107
|
+
end
|
102
108
|
end
|
103
109
|
end
|
104
110
|
end
|
data/test/test.log
CHANGED
@@ -350,3 +350,153 @@ Backtweets: 200
|
|
350
350
|
Backtweets: 500
|
351
351
|
RubyGems: 200
|
352
352
|
RubyGems: 500
|
353
|
+
Backtweets: 500
|
354
|
+
Backtweets: 200
|
355
|
+
Backtweets: 200
|
356
|
+
Backtweets: 500
|
357
|
+
RubyGems: 200
|
358
|
+
RubyGems: 500
|
359
|
+
Backtweets: 500
|
360
|
+
Backtweets: 200
|
361
|
+
Backtweets: 200
|
362
|
+
Backtweets: 500
|
363
|
+
RubyGems: 200
|
364
|
+
RubyGems: 500
|
365
|
+
Backtweets: 500
|
366
|
+
Backtweets: 200
|
367
|
+
Backtweets: 200
|
368
|
+
Backtweets: 500
|
369
|
+
RubyGems: 200
|
370
|
+
RubyGems: 500
|
371
|
+
Backtweets: 500
|
372
|
+
Backtweets: 200
|
373
|
+
Backtweets: 200
|
374
|
+
Backtweets: 500
|
375
|
+
RubyGems: 200
|
376
|
+
RubyGems: 500
|
377
|
+
Backtweets: 500
|
378
|
+
Backtweets: 200
|
379
|
+
Backtweets: 200
|
380
|
+
Backtweets: 500
|
381
|
+
RubyGems: 200
|
382
|
+
RubyGems: 500
|
383
|
+
Backtweets: 500
|
384
|
+
Backtweets: 200
|
385
|
+
Backtweets: 200
|
386
|
+
Backtweets: 500
|
387
|
+
RubyGems: 200
|
388
|
+
RubyGems: 500
|
389
|
+
Backtweets: 500
|
390
|
+
Backtweets: 200
|
391
|
+
Backtweets: 200
|
392
|
+
Backtweets: 500
|
393
|
+
RubyGems: 200
|
394
|
+
RubyGems: 500
|
395
|
+
Backtweets: 500
|
396
|
+
Backtweets: 200
|
397
|
+
Backtweets: 200
|
398
|
+
Backtweets: 500
|
399
|
+
RubyGems: 200
|
400
|
+
RubyGems: 500
|
401
|
+
Backtweets: 500
|
402
|
+
Backtweets: 200
|
403
|
+
Backtweets: 200
|
404
|
+
Backtweets: 500
|
405
|
+
RubyGems: 200
|
406
|
+
RubyGems: 500
|
407
|
+
Backtweets: 500
|
408
|
+
Backtweets: 200
|
409
|
+
Backtweets: 200
|
410
|
+
Backtweets: 500
|
411
|
+
RubyGems: 200
|
412
|
+
RubyGems: 500
|
413
|
+
Backtweets: 500
|
414
|
+
Backtweets: 200
|
415
|
+
Backtweets: 200
|
416
|
+
Backtweets: 500
|
417
|
+
RubyGems: 200
|
418
|
+
RubyGems: 500
|
419
|
+
Backtweets: 500
|
420
|
+
Backtweets: 200
|
421
|
+
Backtweets: 200
|
422
|
+
Backtweets: 500
|
423
|
+
RubyGems: 200
|
424
|
+
RubyGems: 500
|
425
|
+
Backtweets: 500
|
426
|
+
Backtweets: 200
|
427
|
+
Backtweets: 200
|
428
|
+
Backtweets: 500
|
429
|
+
RubyGems: 200
|
430
|
+
RubyGems: 500
|
431
|
+
Backtweets: 500
|
432
|
+
Backtweets: 200
|
433
|
+
Backtweets: 200
|
434
|
+
Backtweets: 500
|
435
|
+
RubyGems: 200
|
436
|
+
RubyGems: 500
|
437
|
+
Backtweets: 500
|
438
|
+
Backtweets: 200
|
439
|
+
Backtweets: 200
|
440
|
+
Backtweets: 500
|
441
|
+
RubyGems: 200
|
442
|
+
RubyGems: 500
|
443
|
+
Backtweets: 500
|
444
|
+
Backtweets: 200
|
445
|
+
Backtweets: 200
|
446
|
+
Backtweets: 500
|
447
|
+
RubyGems: 200
|
448
|
+
RubyGems: 500
|
449
|
+
Backtweets: 500
|
450
|
+
Backtweets: 200
|
451
|
+
Backtweets: 200
|
452
|
+
Backtweets: 500
|
453
|
+
RubyGems: 200
|
454
|
+
RubyGems: 500
|
455
|
+
Backtweets: 500
|
456
|
+
Backtweets: 200
|
457
|
+
Backtweets: 200
|
458
|
+
Backtweets: 500
|
459
|
+
RubyGems: 200
|
460
|
+
RubyGems: 500
|
461
|
+
Backtweets: 500
|
462
|
+
Backtweets: 200
|
463
|
+
Backtweets: 200
|
464
|
+
Backtweets: 500
|
465
|
+
RubyGems: 200
|
466
|
+
RubyGems: 500
|
467
|
+
Backtweets: 500
|
468
|
+
Backtweets: 200
|
469
|
+
Backtweets: 200
|
470
|
+
Backtweets: 500
|
471
|
+
RubyGems: 200
|
472
|
+
RubyGems: 500
|
473
|
+
Backtweets: 500
|
474
|
+
Backtweets: 200
|
475
|
+
Backtweets: 200
|
476
|
+
Backtweets: 500
|
477
|
+
RubyGems: 200
|
478
|
+
RubyGems: 500
|
479
|
+
Backtweets: 500
|
480
|
+
Backtweets: 200
|
481
|
+
Backtweets: 200
|
482
|
+
Backtweets: 500
|
483
|
+
RubyGems: 200
|
484
|
+
RubyGems: 500
|
485
|
+
Backtweets: 500
|
486
|
+
Backtweets: 200
|
487
|
+
Backtweets: 200
|
488
|
+
Backtweets: 500
|
489
|
+
RubyGems: 200
|
490
|
+
RubyGems: 500
|
491
|
+
Backtweets: 500
|
492
|
+
Backtweets: 200
|
493
|
+
Backtweets: 200
|
494
|
+
Backtweets: 500
|
495
|
+
RubyGems: 200
|
496
|
+
RubyGems: 500
|
497
|
+
Backtweets: 500
|
498
|
+
Backtweets: 200
|
499
|
+
Backtweets: 200
|
500
|
+
Backtweets: 500
|
501
|
+
RubyGems: 200
|
502
|
+
RubyGems: 500
|
data/test/test_helper.rb
CHANGED
@@ -44,7 +44,7 @@ module Vanity
|
|
44
44
|
module Source
|
45
45
|
module TestHelpers
|
46
46
|
# Represents an activity.
|
47
|
-
Activity = Struct.new(:uid, :html, :text, :url, :timestamp, :person)
|
47
|
+
Activity = Struct.new(:uid, :html, :text, :url, :timestamp, :tags, :person)
|
48
48
|
|
49
49
|
# Represents person associated with activity.
|
50
50
|
Person = Struct.new(:name, :email, :url, :photo)
|
@@ -117,7 +117,7 @@ module Vanity
|
|
117
117
|
totals[name] += value
|
118
118
|
end
|
119
119
|
elsif args[:activity]
|
120
|
-
values = args[:activity].values_at(:uid, :html, :text, :url, :timestamp)
|
120
|
+
values = args[:activity].values_at(:uid, :html, :text, :url, :timestamp, :tags)
|
121
121
|
if person = args[:activity][:person]
|
122
122
|
values << Person.new(*person.values_at(:name, :email, :url, :photo))
|
123
123
|
end
|
data/vanity-source.gemspec
CHANGED
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: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: "0.
|
8
|
+
- 10
|
9
|
+
version: "0.10"
|
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-26 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -105,7 +105,7 @@ licenses: []
|
|
105
105
|
post_install_message:
|
106
106
|
rdoc_options:
|
107
107
|
- --title
|
108
|
-
- Vanity::Source 0.
|
108
|
+
- Vanity::Source 0.10
|
109
109
|
- --main
|
110
110
|
- README.rdoc
|
111
111
|
- --webcvs
|