stream_grabber 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,255 @@
1
+ [{
2
+ "place": null,
3
+ "in_reply_to_screen_name": null,
4
+ "retweeted": false,
5
+ "coordinates": null,
6
+ "geo": null,
7
+ "source": "<a href=\"http://mowglii.com/itsy\" rel=\"nofollow\">Itsy!</a>",
8
+ "retweet_count": null,
9
+ "favorited": false,
10
+ "in_reply_to_status_id": null,
11
+ "created_at": "Sun Oct 17 22:14:45 +0000 2010",
12
+ "in_reply_to_user_id": null,
13
+ "user": {
14
+ "listed_count": 9,
15
+ "geo_enabled": false,
16
+ "description": "",
17
+ "profile_sidebar_fill_color": "F6F6F6",
18
+ "verified": false,
19
+ "time_zone": "London",
20
+ "follow_request_sent": false,
21
+ "profile_sidebar_border_color": "EEEEEE",
22
+ "url": "http://eightbitraptor.com",
23
+ "notifications": false,
24
+ "profile_use_background_image": true,
25
+ "followers_count": 109,
26
+ "lang": "en",
27
+ "created_at": "Tue Oct 21 12:02:19 +0000 2008",
28
+ "profile_background_color": "ACDED6",
29
+ "profile_image_url": "http://a1.twimg.com/profile_images/1084328481/57568_normal.jpg",
30
+ "location": "London",
31
+ "show_all_inline_media": false,
32
+ "profile_background_image_url": "http://s.twimg.com/a/1287010001/images/themes/theme18/bg.gif",
33
+ "friends_count": 85,
34
+ "protected": false,
35
+ "statuses_count": 1552,
36
+ "profile_text_color": "333333",
37
+ "screen_name": "eightbitraptor",
38
+ "name": "Matt House",
39
+ "following": false,
40
+ "profile_background_tile": false,
41
+ "favourites_count": 7,
42
+ "id": 16884642,
43
+ "contributors_enabled": false,
44
+ "utc_offset": 0,
45
+ "profile_link_color": "038543"
46
+ },
47
+ "contributors": null,
48
+ "id": 27676602686,
49
+ "truncated": false,
50
+ "text": "it's quarter past 11 at night, and I'm writing tests. They're not even tests for anything important."
51
+ },
52
+ {
53
+ "place": null,
54
+ "in_reply_to_screen_name": "jose_casal",
55
+ "retweeted": false,
56
+ "coordinates": null,
57
+ "geo": null,
58
+ "source": "<a href=\"http://mowglii.com/itsy\" rel=\"nofollow\">Itsy!</a>",
59
+ "retweet_count": null,
60
+ "favorited": false,
61
+ "in_reply_to_status_id": 27350520957,
62
+ "created_at": "Thu Oct 14 15:30:52 +0000 2010",
63
+ "in_reply_to_user_id": 51521147,
64
+ "user": {
65
+ "listed_count": 9,
66
+ "favourites_count": 7,
67
+ "description": "",
68
+ "contributors_enabled": false,
69
+ "profile_sidebar_fill_color": "F6F6F6",
70
+ "geo_enabled": false,
71
+ "time_zone": "London",
72
+ "profile_sidebar_border_color": "EEEEEE",
73
+ "verified": false,
74
+ "url": "http://eightbitraptor.com",
75
+ "follow_request_sent": null,
76
+ "notifications": null,
77
+ "profile_use_background_image": true,
78
+ "lang": "en",
79
+ "created_at": "Tue Oct 21 12:02:19 +0000 2008",
80
+ "profile_background_color": "ACDED6",
81
+ "profile_image_url": "http://a1.twimg.com/profile_images/1084328481/57568_normal.jpg",
82
+ "location": "London",
83
+ "profile_background_image_url": "http://s.twimg.com/a/1287010001/images/themes/theme18/bg.gif",
84
+ "followers_count": 109,
85
+ "protected": false,
86
+ "profile_text_color": "333333",
87
+ "screen_name": "eightbitraptor",
88
+ "name": "Matt House",
89
+ "show_all_inline_media": false,
90
+ "following": null,
91
+ "profile_background_tile": false,
92
+ "friends_count": 85,
93
+ "id": 16884642,
94
+ "statuses_count": 1551,
95
+ "utc_offset": 0,
96
+ "profile_link_color": "038543"
97
+ },
98
+ "contributors": null,
99
+ "id": 27351457752,
100
+ "truncated": false,
101
+ "text": "@jose_casal I'm living in Ashford at the moment but we generally end up in Canterbury at the weekends as Liz's family is there :)"
102
+ },
103
+ {
104
+ "place": null,
105
+ "in_reply_to_screen_name": "jose_casal",
106
+ "retweeted": false,
107
+ "coordinates": null,
108
+ "geo": null,
109
+ "source": "<a href=\"http://mowglii.com/itsy\" rel=\"nofollow\">Itsy!</a>",
110
+ "retweet_count": null,
111
+ "favorited": false,
112
+ "in_reply_to_status_id": 27339658184,
113
+ "created_at": "Thu Oct 14 13:27:01 +0000 2010",
114
+ "in_reply_to_user_id": 51521147,
115
+ "user": {
116
+ "listed_count": 9,
117
+ "favourites_count": 7,
118
+ "description": "",
119
+ "contributors_enabled": false,
120
+ "profile_sidebar_fill_color": "F6F6F6",
121
+ "geo_enabled": false,
122
+ "time_zone": "London",
123
+ "profile_sidebar_border_color": "EEEEEE",
124
+ "verified": false,
125
+ "url": "http://eightbitraptor.com",
126
+ "follow_request_sent": null,
127
+ "notifications": null,
128
+ "profile_use_background_image": true,
129
+ "lang": "en",
130
+ "created_at": "Tue Oct 21 12:02:19 +0000 2008",
131
+ "profile_background_color": "ACDED6",
132
+ "profile_image_url": "http://a1.twimg.com/profile_images/1084328481/57568_normal.jpg",
133
+ "location": "London",
134
+ "profile_background_image_url": "http://s.twimg.com/a/1287010001/images/themes/theme18/bg.gif",
135
+ "followers_count": 109,
136
+ "protected": false,
137
+ "profile_text_color": "333333",
138
+ "screen_name": "eightbitraptor",
139
+ "name": "Matt House",
140
+ "show_all_inline_media": false,
141
+ "following": null,
142
+ "profile_background_tile": false,
143
+ "friends_count": 85,
144
+ "id": 16884642,
145
+ "statuses_count": 1551,
146
+ "utc_offset": 0,
147
+ "profile_link_color": "038543"
148
+ },
149
+ "contributors": null,
150
+ "id": 27340245866,
151
+ "truncated": false,
152
+ "text": "@jose_casal are you in London tomorrow? we should head for a drink"
153
+ },
154
+ {
155
+ "place": null,
156
+ "in_reply_to_screen_name": null,
157
+ "retweeted": false,
158
+ "coordinates": null,
159
+ "geo": null,
160
+ "source": "<a href=\"http://www.tweetdeck.com\" rel=\"nofollow\">TweetDeck</a>",
161
+ "retweet_count": null,
162
+ "favorited": false,
163
+ "in_reply_to_status_id": null,
164
+ "created_at": "Thu Oct 14 08:03:33 +0000 2010",
165
+ "in_reply_to_user_id": null,
166
+ "user": {
167
+ "listed_count": 9,
168
+ "favourites_count": 7,
169
+ "description": "",
170
+ "contributors_enabled": false,
171
+ "profile_sidebar_fill_color": "F6F6F6",
172
+ "geo_enabled": false,
173
+ "time_zone": "London",
174
+ "profile_sidebar_border_color": "EEEEEE",
175
+ "verified": false,
176
+ "url": "http://eightbitraptor.com",
177
+ "follow_request_sent": null,
178
+ "notifications": null,
179
+ "profile_use_background_image": true,
180
+ "lang": "en",
181
+ "created_at": "Tue Oct 21 12:02:19 +0000 2008",
182
+ "profile_background_color": "ACDED6",
183
+ "profile_image_url": "http://a1.twimg.com/profile_images/1084328481/57568_normal.jpg",
184
+ "location": "London",
185
+ "profile_background_image_url": "http://s.twimg.com/a/1287010001/images/themes/theme18/bg.gif",
186
+ "followers_count": 109,
187
+ "protected": false,
188
+ "profile_text_color": "333333",
189
+ "screen_name": "eightbitraptor",
190
+ "name": "Matt House",
191
+ "show_all_inline_media": false,
192
+ "following": null,
193
+ "profile_background_tile": false,
194
+ "friends_count": 85,
195
+ "id": 16884642,
196
+ "statuses_count": 1551,
197
+ "utc_offset": 0,
198
+ "profile_link_color": "038543"
199
+ },
200
+ "contributors": null,
201
+ "id": 27321272610,
202
+ "truncated": false,
203
+ "text": "RT @lushbucket Love how Canadian TV reports the Chilean miner rescue as feat of engineering and American TV calls it a \"miracle\"."
204
+ },
205
+ {
206
+ "place": null,
207
+ "in_reply_to_screen_name": "threedaymonk",
208
+ "retweeted": false,
209
+ "coordinates": null,
210
+ "geo": null,
211
+ "source": "<a href=\"http://mowglii.com/itsy\" rel=\"nofollow\">Itsy!</a>",
212
+ "retweet_count": null,
213
+ "favorited": false,
214
+ "in_reply_to_status_id": 27230834400,
215
+ "created_at": "Wed Oct 13 12:32:00 +0000 2010",
216
+ "in_reply_to_user_id": 6821782,
217
+ "user": {
218
+ "listed_count": 9,
219
+ "favourites_count": 7,
220
+ "description": "",
221
+ "contributors_enabled": false,
222
+ "profile_sidebar_fill_color": "F6F6F6",
223
+ "geo_enabled": false,
224
+ "time_zone": "London",
225
+ "profile_sidebar_border_color": "EEEEEE",
226
+ "verified": false,
227
+ "url": "http://eightbitraptor.com",
228
+ "follow_request_sent": null,
229
+ "notifications": null,
230
+ "profile_use_background_image": true,
231
+ "lang": "en",
232
+ "created_at": "Tue Oct 21 12:02:19 +0000 2008",
233
+ "profile_background_color": "ACDED6",
234
+ "profile_image_url": "http://a1.twimg.com/profile_images/1084328481/57568_normal.jpg",
235
+ "location": "London",
236
+ "profile_background_image_url": "http://s.twimg.com/a/1287010001/images/themes/theme18/bg.gif",
237
+ "followers_count": 109,
238
+ "protected": false,
239
+ "profile_text_color": "333333",
240
+ "screen_name": "eightbitraptor",
241
+ "name": "Matt House",
242
+ "show_all_inline_media": false,
243
+ "following": null,
244
+ "profile_background_tile": false,
245
+ "friends_count": 85,
246
+ "id": 16884642,
247
+ "statuses_count": 1551,
248
+ "utc_offset": 0,
249
+ "profile_link_color": "038543"
250
+ },
251
+ "contributors": null,
252
+ "id": 27236372848,
253
+ "truncated": false,
254
+ "text": "@threedaymonk a MxM custom textmate bundle with whitespace cleanup? it's a very easy command to write."
255
+ }]
@@ -0,0 +1,26 @@
1
+ require File.join(File.dirname(__FILE__), *%w[test_helper])
2
+
3
+ class GithubUnitTests < Test::Unit::TestCase
4
+ context "A new Github Grabber" do
5
+ setup do
6
+ @github = StreamGrabber::Github.new('username')
7
+ end
8
+
9
+ should "return 5 items of recent activity" do
10
+ assert_equal 5, @github.last_five.count
11
+ end
12
+
13
+ should "return the most recent items as a hash" do
14
+ assert_equal Hash, @github.last_five.class
15
+ assert_equal most_recent_timestamps, @github.last_five.sorted
16
+ end
17
+ end
18
+
19
+ def most_recent_timestamps
20
+ [Time.parse("2010-10-17T08:17:17-07:00").to_i,
21
+ Time.parse("2010-10-17T08:15:48-07:00").to_i,
22
+ Time.parse("2010-10-17T08:15:36-07:00").to_i,
23
+ Time.parse("2010-10-14T08:10:06-07:00").to_i,
24
+ Time.parse("2010-10-05T14:48:18-07:00").to_i ]
25
+ end
26
+ end
@@ -0,0 +1,19 @@
1
+ require File.join(File.dirname(__FILE__), *%w[test_helper])
2
+
3
+ class LastFmUnitTests < Test::Unit::TestCase
4
+ context "A new LastFM Grabber" do
5
+ setup do
6
+ @lastfm = StreamGrabber::LastFm.new('username')
7
+ end
8
+
9
+ should "return 5 items of recent activity" do
10
+ assert_equal 5, @lastfm.last_five.count
11
+ end
12
+
13
+ should "return the most recent items as a hash" do
14
+ most_recent_timestamps = [ 1287351412, 1287342471, 1287340078, 1285867525, 1285057821]
15
+ assert_equal Hash, @lastfm.last_five.class
16
+ assert_equal most_recent_timestamps, @lastfm.last_five.sorted
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,39 @@
1
+ require File.join(File.dirname(__FILE__), *%w[test_helper])
2
+
3
+ class StreamGrabberTest < Test::Unit::TestCase
4
+ context "Multiplexing the streams" do
5
+ setup do
6
+ StreamGrabber.stubs(:usernames).returns(usernames)
7
+ @results = StreamGrabber.grab(5)
8
+ end
9
+
10
+ should "show the most recent results" do
11
+ timestamps = @results.first(5).map{ |r| r[0] }
12
+ assert_equal expected_timestamps, timestamps
13
+ end
14
+ end
15
+
16
+ context "Passing in a ridiculously high number" do
17
+ setup do
18
+ StreamGrabber.stubs(:usernames).returns(usernames)
19
+ @results = StreamGrabber.grab(53)
20
+ end
21
+
22
+ should "only show what it can" do
23
+ timestamps = @results.first(5).map{ |r| r[0] }
24
+ assert_equal expected_timestamps, timestamps
25
+ end
26
+ end
27
+
28
+ def expected_timestamps
29
+ [1287353685, 1287351412, 1287342471, 1287340078, 1287328637]
30
+ end
31
+
32
+ def usernames
33
+ {
34
+ :twitter => 'eightbitraptor',
35
+ :lastfm => 'theshadowaspect',
36
+ :github => 'eightbitraptor'
37
+ }
38
+ end
39
+ end
@@ -0,0 +1,32 @@
1
+ require 'fakeweb'
2
+ require 'open-uri'
3
+ require 'shoulda'
4
+ require 'mocha'
5
+
6
+ require File.join(File.dirname(__FILE__), *%w[.. lib stream_grabber])
7
+
8
+ class Hash
9
+ def sorted
10
+ self.keys.sort.reverse
11
+ end
12
+ end
13
+
14
+ def twitter_response
15
+ open_file("twitter.json")
16
+ end
17
+
18
+ def github_response
19
+ open_file("github.atom")
20
+ end
21
+
22
+ def lastfm_response
23
+ open_file("lastfm.xml")
24
+ end
25
+
26
+ def open_file(filename)
27
+ File.read(File.join(File.dirname(__FILE__), "dummy_responses/#{filename}"))
28
+ end
29
+
30
+ FakeWeb.register_uri(:get, %r{http://api\.twitter\.com} , :body => twitter_response)
31
+ FakeWeb.register_uri(:get, %r{http://ws\.audioscrobbler\.com}, :body => lastfm_response)
32
+ FakeWeb.register_uri(:get, %r{https://github\.com/}, :body => github_response)
@@ -0,0 +1,26 @@
1
+ require File.join(File.dirname(__FILE__), *%w[test_helper])
2
+
3
+ class TwitterUnitTests < Test::Unit::TestCase
4
+ context "A new Twitter Grabber" do
5
+ setup do
6
+ @twitter = StreamGrabber::Twitter.new('username')
7
+ end
8
+
9
+ should "return 5 items of recent activity" do
10
+ assert_equal 5, @twitter.last_five.count
11
+ end
12
+
13
+ should "return the most recent items as a hash" do
14
+ assert_equal Hash, @twitter.last_five.class
15
+ assert_equal most_recent_timestamps, @twitter.last_five.sorted
16
+ end
17
+ end
18
+
19
+ def most_recent_timestamps
20
+ [Time.parse("Sun Oct 17 22:14:45 +0000 2010").to_i,
21
+ Time.parse("Thu Oct 14 15:30:52 +0000 2010").to_i,
22
+ Time.parse("Thu Oct 14 13:27:01 +0000 2010").to_i,
23
+ Time.parse("Thu Oct 14 08:03:33 +0000 2010").to_i,
24
+ Time.parse("Wed Oct 13 12:32:00 +0000 2010").to_i ]
25
+ end
26
+ end
metadata ADDED
@@ -0,0 +1,176 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stream_grabber
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Matt House
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-05-22 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: nokogiri
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 7
30
+ segments:
31
+ - 1
32
+ - 4
33
+ - 0
34
+ version: 1.4.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: simple-rss
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 31
46
+ segments:
47
+ - 1
48
+ - 2
49
+ - 0
50
+ version: 1.2.0
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: json
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ hash: 11
62
+ segments:
63
+ - 1
64
+ - 4
65
+ - 6
66
+ version: 1.4.6
67
+ type: :runtime
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: fakeweb
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ hash: 31
78
+ segments:
79
+ - 1
80
+ - 2
81
+ - 0
82
+ version: 1.2.0
83
+ type: :development
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ name: mocha
87
+ prerelease: false
88
+ requirement: &id005 !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ hash: 35
94
+ segments:
95
+ - 0
96
+ - 9
97
+ - 12
98
+ version: 0.9.12
99
+ type: :development
100
+ version_requirements: *id005
101
+ - !ruby/object:Gem::Dependency
102
+ name: shoulda
103
+ prerelease: false
104
+ requirement: &id006 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ hash: 35
110
+ segments:
111
+ - 2
112
+ - 11
113
+ - 0
114
+ version: 2.11.0
115
+ type: :development
116
+ version_requirements: *id006
117
+ description:
118
+ email: matt@eightbitraptor.com
119
+ executables: []
120
+
121
+ extensions: []
122
+
123
+ extra_rdoc_files: []
124
+
125
+ files:
126
+ - README.md
127
+ - Rakefile
128
+ - lib/stream_grabber/github.rb
129
+ - lib/stream_grabber/last_fm.rb
130
+ - lib/stream_grabber/twitter.rb
131
+ - lib/stream_grabber.rb
132
+ - test/dummy_responses/github.atom
133
+ - test/dummy_responses/lastfm.xml
134
+ - test/dummy_responses/twitter.json
135
+ - test/github_test.rb
136
+ - test/lastfm_test.rb
137
+ - test/stream_grabber_test.rb
138
+ - test/test_helper.rb
139
+ - test/twitter_test.rb
140
+ - app/helpers/stream_grabber_helper.rb
141
+ has_rdoc: true
142
+ homepage: http://eightbitraptor.com
143
+ licenses: []
144
+
145
+ post_install_message:
146
+ rdoc_options: []
147
+
148
+ require_paths:
149
+ - lib
150
+ required_ruby_version: !ruby/object:Gem::Requirement
151
+ none: false
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ hash: 3
156
+ segments:
157
+ - 0
158
+ version: "0"
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
160
+ none: false
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ hash: 3
165
+ segments:
166
+ - 0
167
+ version: "0"
168
+ requirements: []
169
+
170
+ rubyforge_project:
171
+ rubygems_version: 1.6.2
172
+ signing_key:
173
+ specification_version: 3
174
+ summary: Yo dawg! I heard you like feeds so I multiplexed them
175
+ test_files: []
176
+