hpfeeds 0.1.6 → 0.1.7

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: dc12c81b25dbb4039affdce014d7c4af220aca81
4
- data.tar.gz: ce85a6e663faa4eba9eaf47565797da3695da8d0
3
+ metadata.gz: a4b13652c42715d1615773a7ba11efc138b1db62
4
+ data.tar.gz: eb42bc92b8126e3233570207b65358624b75b6f7
5
5
  SHA512:
6
- metadata.gz: 0142b027a55252e987cadb998dbdcf567f886f07cf6bb19b7397f2f3e9808347b2ed92021875bea66110664edc497f015277380c26cdda4040b687abaa8735d0
7
- data.tar.gz: 3c8e557fc15854b90ab97dc32229bf5ef584ea413f238c28d170a27d6db058d107dc2723a3751aeb8925234872c103cd9387cce627d2fa32c64a50764c8b69ce
6
+ metadata.gz: c913b2ac6cd2c27550ca5e46d507d9aee14599b9c93eac30ebadc4809c5c39aa1c9a5899f98b5d51908e549f6181ae85963d6b4e1bcf740505a9e43f219576ae
7
+ data.tar.gz: a7bed4d118ad9bcc03e0d56602d003ea36f877cb47dee06639e43f601280e0228de7b9e387d2b36834fb063a7b0960156620f9e8c8a489fe49d5388048126414
@@ -1,31 +1,38 @@
1
+ #### 0.1.7
2
+ - Fix `reconnect: false` options
3
+
4
+ #### 0.1.6
5
+ - minor changes:
6
+ - minor fixes in README
7
+
1
8
  #### 0.1.5
2
9
  - major changes:
3
- - fixed bug in socket data receiving (feed split in different TCP packets)
10
+ - fixed bug in socket data receiving (feed split in different TCP packets)
4
11
 
5
12
  #### 0.1.4
6
13
  - major changes:
7
- - fixed bug in socket data receiving
14
+ - fixed bug in socket data receiving
8
15
 
9
16
  #### 0.1.3
10
17
  - major changes:
11
- - fixed bug in large feeds receiving
12
- - added automatic subscription on reconnection
13
- - fixed debug messages
18
+ - fixed bug in large feeds receiving
19
+ - added automatic subscription on reconnection
20
+ - fixed debug messages
14
21
 
15
22
  - minor changes:
16
- - housekeeping
23
+ - housekeeping
17
24
 
18
25
  #### 0.1.2
19
26
  - major changes:
20
- - added log_to and log_level options to HPFeeds::Client constructor
27
+ - added log_to and log_level options to HPFeeds::Client constructor
21
28
 
22
29
  #### 0.1.1
23
30
  - major changes:
24
- - separate handlers for messages from different chanels
25
- - better error messages handling
31
+ - separate handlers for messages from different chanels
32
+ - better error messages handling
26
33
 
27
34
  - minor changes:
28
- - documentation, indentation
35
+ - documentation, indentation
29
36
 
30
37
  #### 0.1.0
31
38
  First release
data/README.md CHANGED
@@ -26,7 +26,7 @@ require "hpfeeds"
26
26
  def on_data(name, chan, payload)
27
27
  puts "[%s] %s: %s" % [ chan, name, payload ]
28
28
  # just an example here...
29
- @hp.publish('channel', 'message')
29
+ @hp.publish('message', 'channel')
30
30
  end
31
31
 
32
32
  def on_error(data)
@@ -12,20 +12,20 @@ module HPFeeds
12
12
 
13
13
  class Client
14
14
  def initialize(options)
15
- @host = options[:host]
16
- @port = options[:port] || 10000
17
- @ident = options[:ident]
18
- @secret = options[:secret]
15
+ @host = options.fetch(:host)
16
+ @port = options.fetch(:port, 10000)
17
+ @ident = options.fetch(:ident)
18
+ @secret = options.fetch(:secret)
19
19
 
20
- @timeout = options[:timeout] || 3
21
- @reconnect = options[:reconnect] || true
22
- @sleepwait = options[:sleepwait] || 20
20
+ @timeout = options.fetch(:timeout, 30)
21
+ @reconnect = options.fetch(:reconnect, true)
22
+ @sleepwait = options.fetch(:sleepwait, 20)
23
23
 
24
24
  @connected = false
25
25
  @stopped = false
26
26
 
27
- log_to = options[:log_to] || STDOUT
28
- log_level = options[:log_level] || :info
27
+ log_to = options.fetch(:log_to, STDOUT)
28
+ log_level = options.fetch(:log_level, :info)
29
29
  @logger = Logger.new(log_to)
30
30
  @logger.level = get_log_level(log_level)
31
31
 
@@ -45,7 +45,8 @@ module HPFeeds
45
45
  end
46
46
  break
47
47
  rescue => e
48
- @logger.warn("#{e.class} caugthed while connecting: #{e}. Reconnecting in #{@sleepwait} seconds...")
48
+ @logger.warn("#{e.class} caught while connecting: #{e}. Reconnecting in #{@sleepwait} seconds...")
49
+ raise(e) unless @reconnect
49
50
  sleep(@sleepwait)
50
51
  end
51
52
  end
@@ -118,14 +119,14 @@ module HPFeeds
118
119
  begin
119
120
  while !@stopped
120
121
  while @connected
121
- header = receive_data(HEADERSIZE)
122
+ header = receive_data(HEADERSIZE, @timeout)
122
123
  if header.empty?
123
124
  @connected = false
124
125
  break
125
126
  end
126
127
  opcode, len = @decoder.parse_header(header)
127
128
  @logger.debug("received header, opcode = #{opcode}, len = #{len}")
128
- data = receive_data(len - HEADERSIZE)
129
+ data = receive_data(len - HEADERSIZE, @timeout)
129
130
  if opcode == OP_ERROR
130
131
  unless error_callback.nil?
131
132
  error_callback.call(data)
@@ -145,11 +146,16 @@ module HPFeeds
145
146
  @logger.debug("Lost connection, trying to connect again...")
146
147
  tryconnect
147
148
  end
149
+ rescue Timeout => e
150
+ @logger.warn("#{e.class} caught while connecting: #{e}. Reconnecting in #{@sleepwait} seconds...")
151
+ raise(e) unless @reconnect
152
+ sleep(@sleepwait)
153
+ tryconnect
148
154
  rescue ErrorMessage => e
149
- @logger.warn("#{e.class} caugthed in main loop: #{e}")
155
+ @logger.warn("#{e.class} caught in main loop: #{e}")
150
156
  raise e
151
157
  rescue => e
152
- message = "#{e.class} caugthed in main loop: #{e}\n"
158
+ message = "#{e.class} caught in main loop: #{e}\n"
153
159
  message += e.backtrace.join("\n")
154
160
  @logger.error(message)
155
161
  end
@@ -176,7 +182,7 @@ module HPFeeds
176
182
  if IO.select([@socket], nil, nil, timeout)
177
183
  read_from_socket(max)
178
184
  else
179
- raise Exception.new("Connection receive timeout.")
185
+ raise Timeout.new("Connection receive timeout.")
180
186
  end
181
187
  end
182
188
 
@@ -1,4 +1,5 @@
1
1
  module HPFeeds
2
2
  class Exception < RuntimeError; end
3
3
  class ErrorMessage < RuntimeError; end
4
+ class Timeout < TimeoutError; end
4
5
  end
@@ -1,3 +1,3 @@
1
1
  module HPFeeds
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hpfeeds
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francesco Coda Zabetta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-07 00:00:00.000000000 Z
11
+ date: 2017-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: Ruby client for HPFeeds protocol
@@ -45,15 +45,15 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - lib/hpfeeds/version.rb
49
- - lib/hpfeeds/exception.rb
50
- - lib/hpfeeds/decoder.rb
51
- - lib/hpfeeds/client.rb
52
- - lib/hpfeeds.rb
48
+ - CHANGELOG.md
53
49
  - LICENSE.txt
54
- - Rakefile
55
50
  - README.md
56
- - CHANGELOG.md
51
+ - Rakefile
52
+ - lib/hpfeeds.rb
53
+ - lib/hpfeeds/client.rb
54
+ - lib/hpfeeds/decoder.rb
55
+ - lib/hpfeeds/exception.rb
56
+ - lib/hpfeeds/version.rb
57
57
  homepage: https://github.com/vicvega/hpfeeds-ruby
58
58
  licenses:
59
59
  - MIT
@@ -64,17 +64,17 @@ require_paths:
64
64
  - lib
65
65
  required_ruby_version: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - '>='
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - '>='
72
+ - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  requirements: []
76
76
  rubyforge_project:
77
- rubygems_version: 2.0.3
77
+ rubygems_version: 2.6.8
78
78
  signing_key:
79
79
  specification_version: 4
80
80
  summary: Ruby client for HPFeeds protocol