woot 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/woot.rb +7 -4
- data/test/test_helper.rb +2 -3
- data/woot.gemspec +1 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/lib/woot.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'scrapi'
|
2
|
+
require 'tweetstream'
|
3
|
+
|
1
4
|
class Woot
|
2
5
|
DOMAIN = 'woot.com'
|
3
6
|
WOOT_OFF = 'woot-off'
|
@@ -13,7 +16,7 @@ class Woot
|
|
13
16
|
|
14
17
|
def self.scrape(subdomain = :www)
|
15
18
|
selectors = self.selectors(subdomain)
|
16
|
-
|
19
|
+
Scraper.define do
|
17
20
|
result *(selectors.inject([]) do |array, (pattern, results)|
|
18
21
|
process_first pattern, results
|
19
22
|
array += results.keys
|
@@ -43,14 +46,14 @@ class Woot
|
|
43
46
|
end
|
44
47
|
|
45
48
|
def self.stream(twitter_username, twitter_password)
|
46
|
-
|
49
|
+
TweetStream::Client.new(twitter_username, twitter_password).follow(*TWITTER_IDS.values) do |status|
|
47
50
|
subdomain = TWITTER_IDS.index(status.user.id)
|
48
51
|
subdomain = $1 if subdomain == WOOT_OFF && subdomain =~ /https?:\/\/([^\.]+)\.#{DOMAIN}/
|
49
|
-
yield
|
52
|
+
yield scrape(subdomain) unless subdomain.nil?
|
50
53
|
end
|
51
54
|
end
|
52
55
|
|
53
56
|
def self.stop
|
54
|
-
|
57
|
+
TweetStream::Client.stop
|
55
58
|
end
|
56
59
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'test/unit'
|
3
3
|
require 'shoulda'
|
4
|
-
require 'scrapi'
|
5
|
-
require 'tweetstream'
|
6
|
-
Tidy.path = ENV['TIDY_PATH'] if ENV['TIDY_PATH']
|
7
4
|
|
8
5
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
9
6
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
10
7
|
require 'woot'
|
11
8
|
|
9
|
+
Tidy.path = ENV['TIDY_PATH'] if ENV['TIDY_PATH']
|
10
|
+
|
12
11
|
class Test::Unit::TestCase
|
13
12
|
|
14
13
|
def self.attributes
|
data/woot.gemspec
CHANGED