galerts 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 754bc4e4b5883644b7a93a63a3372d1086d43741
4
- data.tar.gz: 011be19a0fab9712232f7c8710d65dbbeabc8ef3
3
+ metadata.gz: 9c6fc31d3e2abe58ef6cc1481ec06d1f9f73bd7f
4
+ data.tar.gz: 1fdca1a4dcb02b9c1b250a59e98f2bf1f85eeef5
5
5
  SHA512:
6
- metadata.gz: 4390f68cc9dd7a3da82a00ddaf777aa03425cd4a0f6bf0981d7888d36b4bc797eb6e66e271e4d9a1ae38fa46c7a035d7feec9578a38bed2085fc29ed10b1c1db
7
- data.tar.gz: dfaa9fcfd4a287c46ce6e22956d239b7311f4b9486712f4269a2b48332d42db1dc1d9dac0b633ecbeba202879c9cec38245923accd39d2ee8d46748031b5cb44
6
+ metadata.gz: fc1f5bd2f86a840e6b05818e6e9d95806d2945cfc42fdf3a532afecfb9777598c3d06a5bd34d8516719893f17156b0f5b6b761da1aff10323f4824bc4c616802
7
+ data.tar.gz: 78066106154bf53a736f72dadda90c1b6adae2cc83e56216446aee0192ef4742809c9a8a042f67905248f66815d816991d590998bfdb0aa987d7c1eae9988e2e
@@ -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.invert.has_key?(source)
30
+ raise "Unknown alert source in Array" unless SOURCES_TYPES.has_key?(source)
31
31
  end
32
- elsif !options[:sources].empty?
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
 
@@ -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
@@ -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[1..-4]
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[1..-4]
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[1..-4]
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
@@ -1,3 +1,3 @@
1
1
  module Galerts
2
- VERSION = '1.0.2'.freeze unless defined?(::Galerts::VERSION)
2
+ VERSION = '1.0.3'.freeze unless defined?(::Galerts::VERSION)
3
3
  end
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.2
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-12 00:00:00.000000000 Z
11
+ date: 2014-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize