netsoul 2.3.5 → 2.3.6

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: 18956ab4765a66c693fc499b6d138470c59ac880
4
- data.tar.gz: 4b2b2b798f9b1dc064fcf13bf3d638d4842f581a
3
+ metadata.gz: b99b928d22287e2b32f8072fdc80c950dd8212f5
4
+ data.tar.gz: e8f00b15db4357d483e8a31d2a23876bd9ae0558
5
5
  SHA512:
6
- metadata.gz: 7ed7f9ab024602be28b0a5ddd898821d6854ae9c43776a70f792cb1171b7a9243f63fcd3a558f79c92cb4963351a08c19cd9fc15cf13fb3729ebd4cab08874e0
7
- data.tar.gz: 79511f1c3e8789e4f8cfde8772a3b7f3b5555f60deca93195d9fffff928152faf6dcbafb0ea713ff14cdf52db00f52649d084f1f5b052690477ba4095e663ba0
6
+ metadata.gz: 1ee9895ef54494577f0245efb436ef9bc430110898f7f6ecf8a3b53ddb3a7063beeb2ee4052234933002602f4c52c7cd2811e02dff20a410d5628520a869c170
7
+ data.tar.gz: 07fc1f812a9c2655ad1fb052da3d27b58bbeb5615b98f0f20d9deb6da9ff4958d4e175dd9ae5b8d2864899971dda484a974773d3d54bfb64b7381722e8258efe
data/bin/netsoul-ruby CHANGED
@@ -2,8 +2,8 @@
2
2
  # encoding: utf-8
3
3
  # frozen_string_literal: true
4
4
 
5
- lib = File.expand_path('../../lib', __FILE__)
6
- $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
5
+ lib = File.join(File.dirname(File.realpath(__FILE__)), '..', 'lib')
6
+ $LOAD_PATH.unshift File.expand_path(lib)
7
7
 
8
8
  require 'netsoul/client'
9
9
 
@@ -37,6 +37,15 @@ if options.empty? || options[:user_opts].size == 0
37
37
  end
38
38
  end
39
39
 
40
+ def trap_interrupt(client)
41
+ Signal.trap('INT'.freeze) do
42
+ exit 42 unless client.started
43
+ begin client.disconnect; end
44
+ puts '!!! [SIGINT] !!!'.freeze
45
+ exit 42
46
+ end
47
+ end
48
+
40
49
  retry_count = 10
41
50
  retry_wait_time = 1.0
42
51
  RETRY_WAIT_FACTOR = 2.0 # Each time retry is called in Exception block, current 'retry_wait_time' is increased with this factor
@@ -44,6 +53,7 @@ begin
44
53
  c = Netsoul::Client.new options[:user_opts]
45
54
  c.connect
46
55
  if c.started
56
+ trap_interrupt c
47
57
  retry_count = 10
48
58
  retry_wait_time = 1.0
49
59
  loop do
@@ -52,10 +62,6 @@ begin
52
62
  sleep 1
53
63
  end
54
64
  end
55
- rescue Interrupt
56
- begin c.disconnect; end
57
- puts '!!! [SIGINT] !!!'.freeze
58
- exit 42
59
65
  rescue => e
60
66
  puts "[ERROR]: #{e}"
61
67
  puts "[RETRY_COUNT]: #{retry_count}"
@@ -68,9 +68,6 @@ module Netsoul
68
68
  s.flush
69
69
  end
70
70
  log :info, "[send] #{str.chomp}"
71
- rescue Errno::EPIPE
72
- disconnect
73
- connect
74
71
  end
75
72
 
76
73
  def get
@@ -83,16 +80,12 @@ module Netsoul
83
80
  else
84
81
  'nothing'.freeze # Send some string and permit IO.select to thrown exception if something goes wrong.
85
82
  end
86
- rescue Errno::EPIPE
87
- disconnect
88
- connect
89
83
  end
90
84
 
91
85
  def close
92
- @started = false
93
86
  @socket.close
94
- rescue
95
- nil
87
+ ensure
88
+ @started = false
96
89
  end
97
90
  end
98
91
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Netsoul
4
- VERSION = '2.3.5'.freeze
4
+ VERSION = '2.3.6'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netsoul
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.5
4
+ version: 2.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Kakesa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-13 00:00:00.000000000 Z
11
+ date: 2016-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler