inews_client 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/Gemfile.lock +1 -1
- data/lib/inews_client.rb +6 -6
- data/lib/inews_client/queue.rb +6 -6
- data/lib/inews_client/system.rb +6 -6
- data/lib/inews_client/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: c8dc82a17c0d55aa651064d8b7b268499934c902
|
4
|
+
data.tar.gz: 1de5304fc6f2c2166240f4084e41dfe212b889a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f4f9d5173b3c28be13276af47df6778fde16e4c4e01e9721265ba68cd18ace359b6ce18f53acba3945918d8cc1362526c06b65901053d44cca8776723cc5ae7
|
7
|
+
data.tar.gz: b15c4e452d0ae086ee17ef8d18e8eb11c346efa8ebffb275183d1181f9f54b5ea20c33ff2f660f200a8c608a82114f5f187530afed9e1e6aca43d0092bd1057b
|
data/Gemfile.lock
CHANGED
data/lib/inews_client.rb
CHANGED
@@ -4,15 +4,15 @@ require 'inews_client/system'
|
|
4
4
|
require 'inews_client/story_entry'
|
5
5
|
|
6
6
|
module InewsClient
|
7
|
-
def self.watch_queue(&block)
|
7
|
+
def self.watch_queue(options, &block)
|
8
8
|
fired_stories = []
|
9
|
-
interval =
|
9
|
+
interval = options['interval'].to_i
|
10
10
|
interval = 2 unless interval
|
11
|
-
InewsClient::System.session do |inews|
|
12
|
-
inews.queue.with_queue(
|
11
|
+
InewsClient::System.session(options) do |inews|
|
12
|
+
inews.queue.with_queue(options) do |queue|
|
13
13
|
loop do
|
14
|
-
sleep(
|
15
|
-
queue.stories.select {|s| s.fired? }.each do |story|
|
14
|
+
sleep(interval)
|
15
|
+
queue.stories(options).select {|s| s.fired? }.each do |story|
|
16
16
|
next if fired_stories.any? { |s| s.id == story.id }
|
17
17
|
fired_stories << story
|
18
18
|
block.call(story)
|
data/lib/inews_client/queue.rb
CHANGED
@@ -9,8 +9,8 @@ module InewsClient
|
|
9
9
|
}
|
10
10
|
end
|
11
11
|
|
12
|
-
def get_stories
|
13
|
-
num_of_stories =
|
12
|
+
def get_stories(options)
|
13
|
+
num_of_stories = options['stories_to_get'].to_i
|
14
14
|
num_of_stories = 50 unless num_of_stories
|
15
15
|
message = {
|
16
16
|
'types:NumberOfStoriesToGet' => "#{num_of_stories}",
|
@@ -28,13 +28,13 @@ module InewsClient
|
|
28
28
|
client.call(:set_current_queue, message: message, cookies: inews.auth_cookies)
|
29
29
|
end
|
30
30
|
|
31
|
-
def with_queue(
|
32
|
-
set_current_queue(
|
31
|
+
def with_queue(options, &block)
|
32
|
+
set_current_queue(options['current_queue'])
|
33
33
|
block.call(inews.queue)
|
34
34
|
end
|
35
35
|
|
36
|
-
def stories
|
37
|
-
get_stories.to_array(:get_stories_response, :stories).map { |story| StoryEntry.parse(story[:story_as_nsml]) }
|
36
|
+
def stories(options)
|
37
|
+
get_stories(options).to_array(:get_stories_response, :stories).map { |story| StoryEntry.parse(story[:story_as_nsml]) }
|
38
38
|
end
|
39
39
|
|
40
40
|
def get_queue_records
|
data/lib/inews_client/system.rb
CHANGED
@@ -21,11 +21,11 @@ module InewsClient
|
|
21
21
|
Savon.client(client_options)
|
22
22
|
end
|
23
23
|
|
24
|
-
def self.connect()
|
24
|
+
def self.connect(options)
|
25
25
|
message = {
|
26
|
-
'types:Username' =>
|
27
|
-
'types:Password' =>
|
28
|
-
'types:Servername' =>
|
26
|
+
'types:Username' => "#{options['username']}",
|
27
|
+
'types:Password' => "#{options['password']}",
|
28
|
+
'types:Servername' => "#{options['servername']}",
|
29
29
|
}
|
30
30
|
client.call(:connect, message: message)
|
31
31
|
end
|
@@ -41,8 +41,8 @@ module InewsClient
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
def self.session(&block)
|
45
|
-
response = connect
|
44
|
+
def self.session(options, &block)
|
45
|
+
response = connect(options)
|
46
46
|
auth_cookies = response.http.cookies
|
47
47
|
if auth_cookies
|
48
48
|
client = InewsClient::System.new(auth_cookies)
|
data/lib/inews_client/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inews_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gilad Barzilay
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: savon
|