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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d98a52be678f8968600b1b243eeed727d78ccbd9
4
- data.tar.gz: f836b379d18eeb345b692dbaa844c2203a66b471
3
+ metadata.gz: c8dc82a17c0d55aa651064d8b7b268499934c902
4
+ data.tar.gz: 1de5304fc6f2c2166240f4084e41dfe212b889a7
5
5
  SHA512:
6
- metadata.gz: aa548f14ad1316d1ce6a4bddc25b6f30322bd628827d0ccf978684c7b3a4c2427479f151dc49b8be36be3da5c92759a84ea4c7a41771f7d18d33533f7a525a63
7
- data.tar.gz: a9c4ae6411752f8e18ba9fda6bea4954e6c59590c229d8dbcb13d59612b80a8697422e2ff434b2ba1ed51c94627ce230811da30154bdaa835491620ade55fbb9
6
+ metadata.gz: 0f4f9d5173b3c28be13276af47df6778fde16e4c4e01e9721265ba68cd18ace359b6ce18f53acba3945918d8cc1362526c06b65901053d44cca8776723cc5ae7
7
+ data.tar.gz: b15c4e452d0ae086ee17ef8d18e8eb11c346efa8ebffb275183d1181f9f54b5ea20c33ff2f660f200a8c608a82114f5f187530afed9e1e6aca43d0092bd1057b
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- inews_client (0.1.1)
4
+ inews_client (0.1.2)
5
5
  libxml-ruby
6
6
  savon (~> 2.3.0)
7
7
  sax-machine
@@ -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 = ENV['interval'].to_i
9
+ interval = options['interval'].to_i
10
10
  interval = 2 unless interval
11
- InewsClient::System.session do |inews|
12
- inews.queue.with_queue(ENV['current_queue']) do |queue|
11
+ InewsClient::System.session(options) do |inews|
12
+ inews.queue.with_queue(options) do |queue|
13
13
  loop do
14
- sleep(ENV['interval'].to_i)
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)
@@ -9,8 +9,8 @@ module InewsClient
9
9
  }
10
10
  end
11
11
 
12
- def get_stories
13
- num_of_stories = ENV['stories_to_get'].to_i
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(queue_full_path, &block)
32
- set_current_queue(queue_full_path)
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
@@ -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' => ENV['username'],
27
- 'types:Password' => ENV['password'],
28
- 'types:Servername' => ENV['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)
@@ -1,3 +1,3 @@
1
1
  module InewsClient
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
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.2
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 00:00:00.000000000 Z
11
+ date: 2014-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: savon