woot 0.0.0 → 0.0.1
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.
- data/README.rdoc +13 -6
 - data/Rakefile +1 -0
 - data/VERSION +1 -1
 - data/lib/woot.rb +26 -1
 - data/test/test_helper.rb +1 -0
 - data/woot.gemspec +58 -0
 - metadata +13 -2
 
    
        data/README.rdoc
    CHANGED
    
    | 
         @@ -11,12 +11,21 @@ Scapes woot.com sites with ruby 
     | 
|
| 
       11 
11 
     | 
    
         
             
            Simply call <tt>Woot.scrape</tt> and optionally specify the woot subdomain (e.g. www, shirt, kids, wine, etc).
         
     | 
| 
       12 
12 
     | 
    
         
             
            Defaults to www.
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
               
     | 
| 
       15 
     | 
    
         
            -
              puts  
     | 
| 
       16 
     | 
    
         
            -
              puts  
     | 
| 
      
 14 
     | 
    
         
            +
              woot = Woot.scrape
         
     | 
| 
      
 15 
     | 
    
         
            +
              puts woot.title
         
     | 
| 
      
 16 
     | 
    
         
            +
              puts woot.price
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
18 
     | 
    
         
             
              data = Woot.scrape(:shirt)
         
     | 
| 
       19 
     | 
    
         
            -
              puts  
     | 
| 
      
 19 
     | 
    
         
            +
              puts woot.title
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            You can also receive live Woot updates using "Twitter's Streaming API"[http://apiwiki.twitter.com/Streaming-API-Documentation].
         
     | 
| 
      
 22 
     | 
    
         
            +
            Simply call <tt>Woot.stream</tt> with your Twitter username, password, and a block.
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              Woot.stream('your-twitter-username', 'your-twitter-password') do |woot|
         
     | 
| 
      
 25 
     | 
    
         
            +
                puts "#{woot.subdomain}: #{woot.title}"
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            Call <tt>Woot.stop</tt> to stop streaming.
         
     | 
| 
       20 
29 
     | 
    
         | 
| 
       21 
30 
     | 
    
         
             
            == Note on Patches/Pull Requests
         
     | 
| 
       22 
31 
     | 
    
         | 
| 
         @@ -32,8 +41,6 @@ Defaults to www. 
     | 
|
| 
       32 
41 
     | 
    
         
             
            == Todo
         
     | 
| 
       33 
42 
     | 
    
         | 
| 
       34 
43 
     | 
    
         
             
            * sellout.woot.com support
         
     | 
| 
       35 
     | 
    
         
            -
            * woot-off quantities
         
     | 
| 
       36 
     | 
    
         
            -
            * build gem
         
     | 
| 
       37 
44 
     | 
    
         | 
| 
       38 
45 
     | 
    
         
             
            == Copyright
         
     | 
| 
       39 
46 
     | 
    
         | 
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -11,6 +11,7 @@ begin 
     | 
|
| 
       11 
11 
     | 
    
         
             
                gem.homepage = 'http://github.com/shuber/woot'
         
     | 
| 
       12 
12 
     | 
    
         
             
                gem.authors = ['Sean Huber']
         
     | 
| 
       13 
13 
     | 
    
         
             
                gem.add_dependency 'scrapi'
         
     | 
| 
      
 14 
     | 
    
         
            +
                gem.add_dependency 'tweetstream'
         
     | 
| 
       14 
15 
     | 
    
         
             
                gem.add_development_dependency 'shoulda'
         
     | 
| 
       15 
16 
     | 
    
         
             
                # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
         
     | 
| 
       16 
17 
     | 
    
         
             
              end
         
     | 
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            0.0. 
     | 
| 
      
 1 
     | 
    
         
            +
            0.0.1
         
     | 
    
        data/lib/woot.rb
    CHANGED
    
    | 
         @@ -1,11 +1,21 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class Woot
         
     | 
| 
       2 
2 
     | 
    
         
             
              DOMAIN = 'woot.com'
         
     | 
| 
      
 3 
     | 
    
         
            +
              WOOT_OFF = 'woot-off'
         
     | 
| 
      
 4 
     | 
    
         
            +
              TWITTER_IDS = {
         
     | 
| 
      
 5 
     | 
    
         
            +
                'kids'    => 66527200,
         
     | 
| 
      
 6 
     | 
    
         
            +
                'shirt'   => 7696162,
         
     | 
| 
      
 7 
     | 
    
         
            +
                'sellout' => 15458304,
         
     | 
| 
      
 8 
     | 
    
         
            +
                'wine'    => 1647621,
         
     | 
| 
      
 9 
     | 
    
         
            +
                'www'     => 734493,
         
     | 
| 
      
 10 
     | 
    
         
            +
                WOOT_OFF  => 20557892
         
     | 
| 
      
 11 
     | 
    
         
            +
              }
         
     | 
| 
      
 12 
     | 
    
         
            +
              SUBDOMAINS = TWITTER_IDS.keys - [WOOT_OFF]
         
     | 
| 
       3 
13 
     | 
    
         | 
| 
       4 
14 
     | 
    
         
             
              def self.scrape(subdomain = :www)
         
     | 
| 
       5 
15 
     | 
    
         
             
                selectors = self.selectors(subdomain)
         
     | 
| 
       6 
16 
     | 
    
         
             
                Scraper.define do
         
     | 
| 
       7 
17 
     | 
    
         
             
                  result *(selectors.inject([]) do |array, (pattern, results)|
         
     | 
| 
       8 
     | 
    
         
            -
                     
     | 
| 
      
 18 
     | 
    
         
            +
                    process_first pattern, results
         
     | 
| 
       9 
19 
     | 
    
         
             
                    array += results.keys
         
     | 
| 
       10 
20 
     | 
    
         
             
                  end)
         
     | 
| 
       11 
21 
     | 
    
         
             
                end.scrape(URI.parse("http://#{subdomain}.#{DOMAIN}/"))
         
     | 
| 
         @@ -13,6 +23,7 @@ class Woot 
     | 
|
| 
       13 
23 
     | 
    
         | 
| 
       14 
24 
     | 
    
         
             
              def self.selectors(subdomain = :www)
         
     | 
| 
       15 
25 
     | 
    
         
             
                @selectors = {
         
     | 
| 
      
 26 
     | 
    
         
            +
                  '*'                         => { :subdomain => proc { |element| subdomain.to_s } },
         
     | 
| 
       16 
27 
     | 
    
         
             
                  'h2.fn'                     => { :title => :text },
         
     | 
| 
       17 
28 
     | 
    
         
             
                  'span.amount'               => { :price => :text },
         
     | 
| 
       18 
29 
     | 
    
         
             
                  'ul#shippingOptions'        => { :shipping => :text },
         
     | 
| 
         @@ -30,4 +41,18 @@ class Woot 
     | 
|
| 
       30 
41 
     | 
    
         
             
                   end }
         
     | 
| 
       31 
42 
     | 
    
         
             
                }
         
     | 
| 
       32 
43 
     | 
    
         
             
              end
         
     | 
| 
      
 44 
     | 
    
         
            +
              
         
     | 
| 
      
 45 
     | 
    
         
            +
              def self.stream(twitter_username, twitter_password)
         
     | 
| 
      
 46 
     | 
    
         
            +
                TweetStream::Client.new(twitter_username, twitter_password).follow(*TWITTER_IDS.values) do |status|
         
     | 
| 
      
 47 
     | 
    
         
            +
                  subdomain = TWITTER_IDS.index(status.user.id)
         
     | 
| 
      
 48 
     | 
    
         
            +
                  unless subdomain.nil?
         
     | 
| 
      
 49 
     | 
    
         
            +
                    subdomain = status.text.match(/https?:\/\/([^\.]+)\.#{DOMAIN}/).captures.first if subdomain == WOOT_OFF
         
     | 
| 
      
 50 
     | 
    
         
            +
                    yield Woot.scrape(subdomain)
         
     | 
| 
      
 51 
     | 
    
         
            +
                  end
         
     | 
| 
      
 52 
     | 
    
         
            +
                end
         
     | 
| 
      
 53 
     | 
    
         
            +
              end
         
     | 
| 
      
 54 
     | 
    
         
            +
              
         
     | 
| 
      
 55 
     | 
    
         
            +
              def self.stop
         
     | 
| 
      
 56 
     | 
    
         
            +
                TweetStream::Client.stop
         
     | 
| 
      
 57 
     | 
    
         
            +
              end
         
     | 
| 
       33 
58 
     | 
    
         
             
            end
         
     | 
    
        data/test/test_helper.rb
    CHANGED
    
    
    
        data/woot.gemspec
    ADDED
    
    | 
         @@ -0,0 +1,58 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Generated by jeweler
         
     | 
| 
      
 2 
     | 
    
         
            +
            # DO NOT EDIT THIS FILE
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
         
     | 
| 
      
 4 
     | 
    
         
            +
            # -*- encoding: utf-8 -*-
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Gem::Specification.new do |s|
         
     | 
| 
      
 7 
     | 
    
         
            +
              s.name = %q{woot}
         
     | 
| 
      
 8 
     | 
    
         
            +
              s.version = "0.0.1"
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         
     | 
| 
      
 11 
     | 
    
         
            +
              s.authors = ["Sean Huber"]
         
     | 
| 
      
 12 
     | 
    
         
            +
              s.date = %q{2009-11-02}
         
     | 
| 
      
 13 
     | 
    
         
            +
              s.description = %q{Scapes woot.com sites}
         
     | 
| 
      
 14 
     | 
    
         
            +
              s.email = %q{shuber@huberry.com}
         
     | 
| 
      
 15 
     | 
    
         
            +
              s.extra_rdoc_files = [
         
     | 
| 
      
 16 
     | 
    
         
            +
                "README.rdoc"
         
     | 
| 
      
 17 
     | 
    
         
            +
              ]
         
     | 
| 
      
 18 
     | 
    
         
            +
              s.files = [
         
     | 
| 
      
 19 
     | 
    
         
            +
                ".gitignore",
         
     | 
| 
      
 20 
     | 
    
         
            +
                 "MIT-LICENSE",
         
     | 
| 
      
 21 
     | 
    
         
            +
                 "README.rdoc",
         
     | 
| 
      
 22 
     | 
    
         
            +
                 "Rakefile",
         
     | 
| 
      
 23 
     | 
    
         
            +
                 "VERSION",
         
     | 
| 
      
 24 
     | 
    
         
            +
                 "init.rb",
         
     | 
| 
      
 25 
     | 
    
         
            +
                 "lib/woot.rb",
         
     | 
| 
      
 26 
     | 
    
         
            +
                 "test/test_helper.rb",
         
     | 
| 
      
 27 
     | 
    
         
            +
                 "test/woot_test.rb",
         
     | 
| 
      
 28 
     | 
    
         
            +
                 "woot.gemspec"
         
     | 
| 
      
 29 
     | 
    
         
            +
              ]
         
     | 
| 
      
 30 
     | 
    
         
            +
              s.homepage = %q{http://github.com/shuber/woot}
         
     | 
| 
      
 31 
     | 
    
         
            +
              s.rdoc_options = ["--charset=UTF-8"]
         
     | 
| 
      
 32 
     | 
    
         
            +
              s.require_paths = ["lib"]
         
     | 
| 
      
 33 
     | 
    
         
            +
              s.rubygems_version = %q{1.3.5}
         
     | 
| 
      
 34 
     | 
    
         
            +
              s.summary = %q{Scapes woot.com sites}
         
     | 
| 
      
 35 
     | 
    
         
            +
              s.test_files = [
         
     | 
| 
      
 36 
     | 
    
         
            +
                "test/test_helper.rb",
         
     | 
| 
      
 37 
     | 
    
         
            +
                 "test/woot_test.rb"
         
     | 
| 
      
 38 
     | 
    
         
            +
              ]
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
              if s.respond_to? :specification_version then
         
     | 
| 
      
 41 
     | 
    
         
            +
                current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
         
     | 
| 
      
 42 
     | 
    
         
            +
                s.specification_version = 3
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
         
     | 
| 
      
 45 
     | 
    
         
            +
                  s.add_runtime_dependency(%q<scrapi>, [">= 0"])
         
     | 
| 
      
 46 
     | 
    
         
            +
                  s.add_runtime_dependency(%q<tweetstream>, [">= 0"])
         
     | 
| 
      
 47 
     | 
    
         
            +
                  s.add_development_dependency(%q<shoulda>, [">= 0"])
         
     | 
| 
      
 48 
     | 
    
         
            +
                else
         
     | 
| 
      
 49 
     | 
    
         
            +
                  s.add_dependency(%q<scrapi>, [">= 0"])
         
     | 
| 
      
 50 
     | 
    
         
            +
                  s.add_dependency(%q<tweetstream>, [">= 0"])
         
     | 
| 
      
 51 
     | 
    
         
            +
                  s.add_dependency(%q<shoulda>, [">= 0"])
         
     | 
| 
      
 52 
     | 
    
         
            +
                end
         
     | 
| 
      
 53 
     | 
    
         
            +
              else
         
     | 
| 
      
 54 
     | 
    
         
            +
                s.add_dependency(%q<scrapi>, [">= 0"])
         
     | 
| 
      
 55 
     | 
    
         
            +
                s.add_dependency(%q<tweetstream>, [">= 0"])
         
     | 
| 
      
 56 
     | 
    
         
            +
                s.add_dependency(%q<shoulda>, [">= 0"])
         
     | 
| 
      
 57 
     | 
    
         
            +
              end
         
     | 
| 
      
 58 
     | 
    
         
            +
            end
         
     | 
    
        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.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors: 
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Sean Huber
         
     | 
| 
         @@ -9,7 +9,7 @@ autorequire: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
            date: 2009- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2009-11-02 00:00:00 -08:00
         
     | 
| 
       13 
13 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
         @@ -22,6 +22,16 @@ dependencies: 
     | 
|
| 
       22 
22 
     | 
    
         
             
                  - !ruby/object:Gem::Version 
         
     | 
| 
       23 
23 
     | 
    
         
             
                    version: "0"
         
     | 
| 
       24 
24 
     | 
    
         
             
                version: 
         
     | 
| 
      
 25 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 26 
     | 
    
         
            +
              name: tweetstream
         
     | 
| 
      
 27 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 28 
     | 
    
         
            +
              version_requirement: 
         
     | 
| 
      
 29 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: "0"
         
     | 
| 
      
 34 
     | 
    
         
            +
                version: 
         
     | 
| 
       25 
35 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       26 
36 
     | 
    
         
             
              name: shoulda
         
     | 
| 
       27 
37 
     | 
    
         
             
              type: :development
         
     | 
| 
         @@ -50,6 +60,7 @@ files: 
     | 
|
| 
       50 
60 
     | 
    
         
             
            - lib/woot.rb
         
     | 
| 
       51 
61 
     | 
    
         
             
            - test/test_helper.rb
         
     | 
| 
       52 
62 
     | 
    
         
             
            - test/woot_test.rb
         
     | 
| 
      
 63 
     | 
    
         
            +
            - woot.gemspec
         
     | 
| 
       53 
64 
     | 
    
         
             
            has_rdoc: true
         
     | 
| 
       54 
65 
     | 
    
         
             
            homepage: http://github.com/shuber/woot
         
     | 
| 
       55 
66 
     | 
    
         
             
            licenses: []
         
     |