amazon_wish_miner 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
 - data/lib/amazon_wish_miner/amazon_wish_list.rb +21 -0
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 669b8e1488ff8f0c2aa4317ee5ec5f1182f89555a4b5a8bcb94394791602f257
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 1a0c6949da63815b30c5064de5bae8a8d49b5de45fc803f964b8aabfce6be4ec
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: af9d9b075d042508dab1bde631c36ee48678b0e1caff98541d3fe6302e70260d43bc54e5c590a9a44990bb2d4c97162ee9105a54cee0d44df1af06385fd76766
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 663051c3b889cc1d55b99f97b07fb0ba9b3b4d6b645d74e30ae71f27f84dca765c1e1633af79029f134d08ffca481d01c47ef35c807f216070987642bfddc5dc
         
     | 
| 
         @@ -55,6 +55,27 @@ class AmazonWishList 
     | 
|
| 
       55 
55 
     | 
    
         
             
                start_of_lek.split('" class="lastEvaluatedKey"')[0]
         
     | 
| 
       56 
56 
     | 
    
         
             
              end
         
     | 
| 
       57 
57 
     | 
    
         | 
| 
      
 58 
     | 
    
         
            +
              def self.wishlist_from_url(url)
         
     | 
| 
      
 59 
     | 
    
         
            +
                url = check_for_redirect(url)
         
     | 
| 
      
 60 
     | 
    
         
            +
                id_start = url.split('/wishlist/')[1]
         
     | 
| 
      
 61 
     | 
    
         
            +
                id = id_start.split('/').find { |str| str != 'ls' }
         
     | 
| 
      
 62 
     | 
    
         
            +
                get_wishlist(id)
         
     | 
| 
      
 63 
     | 
    
         
            +
              end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
              def self.check_for_redirect(url)
         
     | 
| 
      
 66 
     | 
    
         
            +
                begin
         
     | 
| 
      
 67 
     | 
    
         
            +
                  response = RestClient::Request.execute(method: :get, url: url, max_redirects: 0)
         
     | 
| 
      
 68 
     | 
    
         
            +
                rescue RestClient::ExceptionWithResponse => err
         
     | 
| 
      
 69 
     | 
    
         
            +
                  if response.code / 100 == 3
         
     | 
| 
      
 70 
     | 
    
         
            +
                    url = err.http_headers[:location]
         
     | 
| 
      
 71 
     | 
    
         
            +
                    retry
         
     | 
| 
      
 72 
     | 
    
         
            +
                  else
         
     | 
| 
      
 73 
     | 
    
         
            +
                    raise err
         
     | 
| 
      
 74 
     | 
    
         
            +
                  end
         
     | 
| 
      
 75 
     | 
    
         
            +
                end
         
     | 
| 
      
 76 
     | 
    
         
            +
                url
         
     | 
| 
      
 77 
     | 
    
         
            +
              end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
       58 
79 
     | 
    
         | 
| 
       59 
80 
     | 
    
         | 
| 
       60 
81 
     | 
    
         
             
            end
         
     |