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 +4 -4
- data/lib/galerts/alert.rb +3 -1
- data/lib/galerts/manager.rb +9 -4
- 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: 1927bb3f13800cfe9ddcaf6c383d889fbbbe1c87
|
4
|
+
data.tar.gz: 056d5825cd3e7f496e7a11f0adb85d1b0713257b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e880895f8a19ed362c90d6bba1d71fde1208ab7b85b11ca51c6863f1d0a6bfbdc9c17ef548eb4e2dd24454074a4f01bb4d49e5288533b56591017a4f987a9497
|
7
|
+
data.tar.gz: 045a1ead22b3f32571b63759846b41e506ca345c078a61950e7ba3f258d4e2665d9bd06460b1548f6770d0e2602f84400cb713f3a18bbdee343d69a6d64e0dcc
|
data/lib/galerts/alert.rb
CHANGED
@@ -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]
|
data/lib/galerts/manager.rb
CHANGED
@@ -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(',').
|
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(',').
|
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
|
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.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-
|
11
|
+
date: 2015-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mechanize
|