galerts 1.0.7 → 1.0.8

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: 6009e0cc575e3e29b23c52092d9337e77a582414
4
- data.tar.gz: ecbcc802873932a82f197a078d7c28505ae929e6
3
+ metadata.gz: 1927bb3f13800cfe9ddcaf6c383d889fbbbe1c87
4
+ data.tar.gz: 056d5825cd3e7f496e7a11f0adb85d1b0713257b
5
5
  SHA512:
6
- metadata.gz: 63e25781b9b34015324e1b1f9cd870e0ae90c23a27a4155c4fe13af3d9d20e7c0ee672421d0cdaff7d07d0f52feb415c765739f40ae1b1515547871b5e1ba24b
7
- data.tar.gz: 69d91d46534509f7292bd3b0a965df7ace6109b673d45379940b914f7da45dfe3aa5929169ff3987ead6a622fad51c978f14e409f29748f1ad512c100d4542ae
6
+ metadata.gz: e880895f8a19ed362c90d6bba1d71fde1208ab7b85b11ca51c6863f1d0a6bfbdc9c17ef548eb4e2dd24454074a4f01bb4d49e5288533b56591017a4f987a9497
7
+ data.tar.gz: 045a1ead22b3f32571b63759846b41e506ca345c078a61950e7ba3f258d4e2665d9bd06460b1548f6770d0e2602f84400cb713f3a18bbdee343d69a6d64e0dcc
@@ -1,11 +1,12 @@
1
1
  module Galerts
2
2
  class Alert
3
- attr_accessor :query, :id, :data_id, :domain, :frequency, :sources, :language, :how_many, :region, :delivery, :feed_url
3
+ attr_accessor :query, :id, :data_id, :data_id_2, :domain, :frequency, :sources, :language, :how_many, :region, :delivery, :feed_url
4
4
  def initialize(query, options = {})
5
5
 
6
6
  default_options = {
7
7
  id: 0,
8
8
  data_id: 0,
9
+ data_id_2: 0,
9
10
  domain: DOMAIN,
10
11
  frequency: RT,
11
12
  sources: AUTOMATIC,
@@ -38,6 +39,7 @@ module Galerts
38
39
  @query = query
39
40
  @id = options[:id]
40
41
  @data_id = options[:data_id]
42
+ @data_id_2 = options[:data_id_2]
41
43
  @domain = options[:domain]
42
44
  @frequency = options[:frequency]
43
45
  @sources = options[:sources]
@@ -60,6 +60,7 @@ module Galerts
60
60
  query: alert[2][3][1],
61
61
  feed_url: "#{ALERTS_URL}/feeds/#{alert.last}/#{alert[2][6][0][11]}",
62
62
  data_id: alert[1],
63
+ data_id_2: alert[2][6][0].last,
63
64
  domain: alert[2][3][2],
64
65
  language: alert[2][3][3][1],
65
66
  region: alert[2][3].last == 1 ? alert[2][3][3][2] : ANYWHERE,
@@ -109,12 +110,13 @@ module Galerts
109
110
  # TODO: need more readable
110
111
  if action == 0 # create
111
112
  params = {
112
- 'params' => "[null,[null,null,null,[null,\"#{alert.query}\",\"#{alert.domain}\",[null,\"#{alert.language}\",\"#{region}\"],null,null,null,#{anywhere ? 0 : 1},1],#{sources_text},#{HOW_MANY_TYPES[alert.how_many]},[[null,#{delivery_and_frequency},\"#{alert.language + '-' + region.upcase}\",null,null,null,null,null,'0']]]]"
113
+ # 'params' => "[null,[null,null,null,[null,\"#{alert.query}\",\"#{alert.domain}\",[null,\"#{alert.language}\",\"#{region}\"],null,null,null,#{anywhere ? 0 : 1},1],#{sources_text},#{HOW_MANY_TYPES[alert.how_many]},[[null,#{delivery_and_frequency},\"#{alert.language + '-' + region.upcase}\",null,null,null,null,null,'0']]]]"
114
+ 'params' => "[null,[null,null,null,[null,\"#{alert.query}\",\"#{alert.domain}\",[null,\"#{alert.language}\",\"#{region}\"],null,null,null,#{anywhere ? 0 : 1},1],#{sources_text},#{HOW_MANY_TYPES[alert.how_many]},[[null,#{delivery_and_frequency},\"#{alert.language + '-' + region.upcase}\",null,null,null,null,null,'0',null,null,\"#{alert.data_id_2}\"]]]]"
113
115
  }
114
116
  return URI.encode_www_form(params)
115
117
  elsif action == 1 # edit
116
118
  params = {
117
- 'params' => "[null,\"#{alert.data_id}\",[null,null,null,[null,\"#{alert.query}\",\"#{alert.domain}\",[null,\"#{alert.language}\",\"#{region}\"],null,null,null,#{anywhere ? 0 : 1},1],#{sources_text},#{HOW_MANY_TYPES[alert.how_many]},[[null,#{delivery_and_frequency},\"#{alert.language + '-' + region.upcase}\",null,null,null,null,null,\"#{alert.id}\"]]]]"
119
+ 'params' => "[null,\"#{alert.data_id}\",[null,null,null,[null,\"#{alert.query}\",\"#{alert.domain}\",[null,\"#{alert.language}\",\"#{region}\"],null,null,null,#{anywhere ? 0 : 1},1],#{sources_text},#{HOW_MANY_TYPES[alert.how_many]},[[null,#{delivery_and_frequency},\"#{alert.language + '-' + region.upcase}\",null,null,null,null,null,\"#{alert.id}\",null,null,\"#{alert.data_id_2}\"]]]]"
118
120
  }
119
121
  return URI.encode_www_form(params)
120
122
  elsif action == 2 # delete
@@ -129,6 +131,7 @@ module Galerts
129
131
  alert = Alert.new(query, options)
130
132
 
131
133
  x = alerts_page.css('div#gb-main div.main-page script').text.split(',').grep(/AMJH/).first.tr('"/\"','')
134
+ alert.data_id_2 = alerts_page.css('div#gb-main div.main-page script').text.split(',').grep(/AB2X/).first.tr('"/\"','').tr('\]','')
132
135
  response = @agent.post("#{CREATE_ALERT_URL}x=#{x}", build_params(alert, 0), {'Content-Type' => 'application/x-www-form-urlencoded'})
133
136
 
134
137
  if response.body == ALERT_EXIST
@@ -151,7 +154,8 @@ module Galerts
151
154
  end
152
155
 
153
156
  def update(alert)
154
- x = alerts_page.css('div#gb-main div.main-page script').text.split(',').last(12).first.tr('"/\"','')
157
+ x = alerts_page.css('div#gb-main div.main-page script').text.split(',').grep(/AMJH/).first.tr('"/\"','')
158
+ alert.data_id_2 = alerts_page.css('div#gb-main div.main-page script').text.split(',').grep(/AB2X/).first.tr('"/\"','').tr('\]','')
155
159
  response = @agent.post("#{MODIFY_ALERT_URL}x=#{x}", build_params(alert, 1), {'Content-Type' => 'application/x-www-form-urlencoded'})
156
160
 
157
161
  if response.body == ALERT_EXIST
@@ -172,7 +176,8 @@ module Galerts
172
176
  end
173
177
 
174
178
  def delete(alert)
175
- x = alerts_page.css('div#gb-main div.main-page script').text.split(',').last(12).first.tr('"/\"','')
179
+ x = alerts_page.css('div#gb-main div.main-page script').text.split(',').grep(/AMJH/).first.tr('"/\"','')
180
+ alert.data_id_2 = alerts_page.css('div#gb-main div.main-page script').text.split(',').grep(/AB2X/).first.tr('"/\"','').tr('\]','')
176
181
  response = @agent.post("#{DELETE_ALERT_URL}x=#{x}", build_params(alert, 2), {'Content-Type' => 'application/x-www-form-urlencoded'})
177
182
 
178
183
  if response.body == ALERT_NOT_EXIST
@@ -1,3 +1,3 @@
1
1
  module Galerts
2
- VERSION = '1.0.7'.freeze unless defined?(::Galerts::VERSION)
2
+ VERSION = '1.0.8'.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.7
4
+ version: 1.0.8
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: 2015-06-02 00:00:00.000000000 Z
11
+ date: 2015-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize