galerts 1.0.2 → 1.0.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/galerts/alert.rb +4 -2
 - data/lib/galerts/defaults.rb +8 -6
 - data/lib/galerts/manager.rb +3 -3
 - data/lib/galerts/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 9c6fc31d3e2abe58ef6cc1481ec06d1f9f73bd7f
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 1fdca1a4dcb02b9c1b250a59e98f2bf1f85eeef5
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: fc1f5bd2f86a840e6b05818e6e9d95806d2945cfc42fdf3a532afecfb9777598c3d06a5bd34d8516719893f17156b0f5b6b761da1aff10323f4824bc4c616802
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 78066106154bf53a736f72dadda90c1b6adae2cc83e56216446aee0192ef4742809c9a8a042f67905248f66815d816991d590998bfdb0aa987d7c1eae9988e2e
         
     | 
    
        data/lib/galerts/alert.rb
    CHANGED
    
    | 
         @@ -27,9 +27,11 @@ module Galerts 
     | 
|
| 
       27 
27 
     | 
    
         | 
| 
       28 
28 
     | 
    
         
             
                  if options[:sources].kind_of?(Array)
         
     | 
| 
       29 
29 
     | 
    
         
             
                    options[:sources].collect do |source|
         
     | 
| 
       30 
     | 
    
         
            -
                      raise "Unknown alert source" unless SOURCES_TYPES. 
     | 
| 
      
 30 
     | 
    
         
            +
                      raise "Unknown alert source in Array" unless SOURCES_TYPES.has_key?(source)
         
     | 
| 
       31 
31 
     | 
    
         
             
                    end
         
     | 
| 
       32 
     | 
    
         
            -
                  elsif  
     | 
| 
      
 32 
     | 
    
         
            +
                  elsif options[:sources].nil?
         
     | 
| 
      
 33 
     | 
    
         
            +
                    raise "Nil alert source"
         
     | 
| 
      
 34 
     | 
    
         
            +
                  elsif !SOURCES_TYPES.has_key?(options[:sources])
         
     | 
| 
       33 
35 
     | 
    
         
             
                    raise "Unknown alert source"
         
     | 
| 
       34 
36 
     | 
    
         
             
                  end
         
     | 
| 
       35 
37 
     | 
    
         | 
    
        data/lib/galerts/defaults.rb
    CHANGED
    
    | 
         @@ -1,4 +1,11 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module Galerts
         
     | 
| 
      
 2 
     | 
    
         
            +
              # Default alert value
         
     | 
| 
      
 3 
     | 
    
         
            +
              DOMAIN = 'com'
         
     | 
| 
      
 4 
     | 
    
         
            +
              AUTOMATIC = ''
         
     | 
| 
      
 5 
     | 
    
         
            +
              LANGUAGE = 'en'
         
     | 
| 
      
 6 
     | 
    
         
            +
              REGION = 'US'
         
     | 
| 
      
 7 
     | 
    
         
            +
              ANYWHERE = 'anywhere'
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
       2 
9 
     | 
    
         
             
              # URLs
         
     | 
| 
       3 
10 
     | 
    
         
             
              CREATE_ALERT_URL = 'https://www.google.com/alerts/create?'
         
     | 
| 
       4 
11 
     | 
    
         
             
              DELETE_ALERT_URL = 'https://www.google.com/alerts/delete?'
         
     | 
| 
         @@ -50,6 +57,7 @@ module Galerts 
     | 
|
| 
       50 
57 
     | 
    
         
             
              DISCUSSIONS = 'Discussions'
         
     | 
| 
       51 
58 
     | 
    
         | 
| 
       52 
59 
     | 
    
         
             
              SOURCES_TYPES = {
         
     | 
| 
      
 60 
     | 
    
         
            +
                AUTOMATIC => 0,
         
     | 
| 
       53 
61 
     | 
    
         
             
                BLOGS => 1,
         
     | 
| 
       54 
62 
     | 
    
         
             
                NEWS => 2,
         
     | 
| 
       55 
63 
     | 
    
         
             
                WEB => 3,
         
     | 
| 
         @@ -59,10 +67,4 @@ module Galerts 
     | 
|
| 
       59 
67 
     | 
    
         
             
              }
         
     | 
| 
       60 
68 
     | 
    
         | 
| 
       61 
69 
     | 
    
         | 
| 
       62 
     | 
    
         
            -
              # Default alert value
         
     | 
| 
       63 
     | 
    
         
            -
              DOMAIN = 'com'
         
     | 
| 
       64 
     | 
    
         
            -
              AUTOMATIC = ''
         
     | 
| 
       65 
     | 
    
         
            -
              LANGUAGE = 'en'
         
     | 
| 
       66 
     | 
    
         
            -
              REGION = 'US'
         
     | 
| 
       67 
     | 
    
         
            -
              ANYWHERE = 'anywhere'
         
     | 
| 
       68 
70 
     | 
    
         
             
            end
         
     | 
    
        data/lib/galerts/manager.rb
    CHANGED
    
    | 
         @@ -126,7 +126,7 @@ module Galerts 
     | 
|
| 
       126 
126 
     | 
    
         
             
                def create(query, options = {})
         
     | 
| 
       127 
127 
     | 
    
         
             
                  alert = Alert.new(query, options)
         
     | 
| 
       128 
128 
     | 
    
         | 
| 
       129 
     | 
    
         
            -
                  x = alerts_page.css('div#gb-main div.main-page script').text.split(',').last 
     | 
| 
      
 129 
     | 
    
         
            +
                  x = alerts_page.css('div#gb-main div.main-page script').text.split(',').last(12).first.tr('"/\"','')
         
     | 
| 
       130 
130 
     | 
    
         
             
                  response = @agent.post("#{CREATE_ALERT_URL}x=#{x}", build_params(alert, 0), {'Content-Type' => 'application/x-www-form-urlencoded'})
         
     | 
| 
       131 
131 
     | 
    
         | 
| 
       132 
132 
     | 
    
         
             
                  if response.body == ALERT_EXIST
         
     | 
| 
         @@ -147,7 +147,7 @@ module Galerts 
     | 
|
| 
       147 
147 
     | 
    
         
             
                end
         
     | 
| 
       148 
148 
     | 
    
         | 
| 
       149 
149 
     | 
    
         
             
                def update(alert)
         
     | 
| 
       150 
     | 
    
         
            -
                  x = alerts_page.css('div#gb-main div.main-page script').text.split(',').last 
     | 
| 
      
 150 
     | 
    
         
            +
                  x = alerts_page.css('div#gb-main div.main-page script').text.split(',').last(12).first.tr('"/\"','')
         
     | 
| 
       151 
151 
     | 
    
         
             
                  response = @agent.post("#{MODIFY_ALERT_URL}x=#{x}", build_params(alert, 1), {'Content-Type' => 'application/x-www-form-urlencoded'})
         
     | 
| 
       152 
152 
     | 
    
         | 
| 
       153 
153 
     | 
    
         
             
                  if response.body == ALERT_EXIST
         
     | 
| 
         @@ -168,7 +168,7 @@ module Galerts 
     | 
|
| 
       168 
168 
     | 
    
         
             
                end
         
     | 
| 
       169 
169 
     | 
    
         | 
| 
       170 
170 
     | 
    
         
             
                def delete(alert)
         
     | 
| 
       171 
     | 
    
         
            -
                  x = alerts_page.css('div#gb-main div.main-page script').text.split(',').last 
     | 
| 
      
 171 
     | 
    
         
            +
                  x = alerts_page.css('div#gb-main div.main-page script').text.split(',').last(12).first.tr('"/\"','')
         
     | 
| 
       172 
172 
     | 
    
         
             
                  response = @agent.post("#{DELETE_ALERT_URL}x=#{x}", build_params(alert, 2), {'Content-Type' => 'application/x-www-form-urlencoded'})
         
     | 
| 
       173 
173 
     | 
    
         | 
| 
       174 
174 
     | 
    
         
             
                  if response.body == ALERT_NOT_EXIST
         
     | 
    
        data/lib/galerts/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: galerts
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.0.3
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Emre Can Yılmaz
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2014-10- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-10-20 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: mechanize
         
     |