woot 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/woot.rb +12 -1
- data/test/test_helper.rb +1 -5
- data/woot.gemspec +4 -1
- metadata +11 -1
data/Rakefile
CHANGED
@@ -10,6 +10,7 @@ begin
|
|
10
10
|
gem.email = 'shuber@huberry.com'
|
11
11
|
gem.homepage = 'http://github.com/shuber/woot'
|
12
12
|
gem.authors = ['Sean Huber']
|
13
|
+
gem.add_dependency 'httparty'
|
13
14
|
gem.add_dependency 'scrapi'
|
14
15
|
gem.add_dependency 'tweetstream'
|
15
16
|
gem.add_development_dependency 'shoulda'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/lib/woot.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'httparty'
|
1
2
|
require 'scrapi'
|
2
3
|
require 'tweetstream'
|
3
4
|
|
@@ -5,6 +6,7 @@ Tidy.path = ENV['TIDY_PATH'] if ENV['TIDY_PATH']
|
|
5
6
|
|
6
7
|
class Woot
|
7
8
|
DOMAIN = 'woot.com'
|
9
|
+
SELLOUT_DOMAIN = 'shopping.yahoo.com'
|
8
10
|
WOOT_OFF = 'woot-off'
|
9
11
|
TWITTER_IDS = {
|
10
12
|
'kids' => 66527200,
|
@@ -17,13 +19,22 @@ class Woot
|
|
17
19
|
SUBDOMAINS = TWITTER_IDS.keys - [WOOT_OFF]
|
18
20
|
|
19
21
|
def self.scrape(subdomain = :www)
|
22
|
+
url = "http://#{subdomain}.#{DOMAIN}/"
|
23
|
+
if subdomain.to_s == 'sellout'
|
24
|
+
url = Scraper.define do
|
25
|
+
process_first "div.bd>div.img>a", :url => '@href'
|
26
|
+
result :url
|
27
|
+
end.scrape(HTTParty.get("http://#{SELLOUT_DOMAIN}/").to_s).gsub('&', '&')
|
28
|
+
end
|
29
|
+
response = HTTParty.get(url).to_s
|
30
|
+
|
20
31
|
selectors = self.selectors(subdomain)
|
21
32
|
Scraper.define do
|
22
33
|
result *(selectors.inject([]) do |array, (pattern, results)|
|
23
34
|
process_first pattern, results
|
24
35
|
array += results.keys
|
25
36
|
end)
|
26
|
-
end.scrape(
|
37
|
+
end.scrape(response)
|
27
38
|
end
|
28
39
|
|
29
40
|
def self.selectors(subdomain = :www)
|
data/test/test_helper.rb
CHANGED
@@ -16,12 +16,8 @@ class Test::Unit::TestCase
|
|
16
16
|
@possible_blank_attributes ||= [:purchase_url]
|
17
17
|
end
|
18
18
|
|
19
|
-
def self.subdomains
|
20
|
-
@subdomains ||= [:www, :wine, :shirt, :kids] # TODO: sellout
|
21
|
-
end
|
22
|
-
|
23
19
|
def self.woots
|
24
|
-
@woots ||=
|
20
|
+
@woots ||= Woot::SUBDOMAINS.inject({}) { |hash, subdomain| hash.merge! subdomain => Woot.scrape(subdomain) }
|
25
21
|
end
|
26
22
|
|
27
23
|
end
|
data/woot.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{woot}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Sean Huber"]
|
@@ -43,15 +43,18 @@ Gem::Specification.new do |s|
|
|
43
43
|
s.specification_version = 3
|
44
44
|
|
45
45
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
46
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0"])
|
46
47
|
s.add_runtime_dependency(%q<scrapi>, [">= 0"])
|
47
48
|
s.add_runtime_dependency(%q<tweetstream>, [">= 0"])
|
48
49
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
49
50
|
else
|
51
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
50
52
|
s.add_dependency(%q<scrapi>, [">= 0"])
|
51
53
|
s.add_dependency(%q<tweetstream>, [">= 0"])
|
52
54
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
53
55
|
end
|
54
56
|
else
|
57
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
55
58
|
s.add_dependency(%q<scrapi>, [">= 0"])
|
56
59
|
s.add_dependency(%q<tweetstream>, [">= 0"])
|
57
60
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: woot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Huber
|
@@ -12,6 +12,16 @@ cert_chain: []
|
|
12
12
|
date: 2009-11-02 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: httparty
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
15
25
|
- !ruby/object:Gem::Dependency
|
16
26
|
name: scrapi
|
17
27
|
type: :runtime
|