serfx 0.0.6 → 0.0.7

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: 65e79c908f0cef06b8c9050ab7f89f7bf4d4f94a
4
- data.tar.gz: 4d6092ea8e5062cf892a0c1285525a907983faf4
3
+ metadata.gz: 192f63ff3c81b7514e291a9ddd7e4061c3ec97a3
4
+ data.tar.gz: 9a4dfc3ca65be460ba0097338c1c57f5fce3bd89
5
5
  SHA512:
6
- metadata.gz: f38033a7843071a2066205627f6d10ff1ffb0bd7e4aaff04e37f3303f779e212a6ad272c4432f5ed2068cfd9c96b67100fbe66eb03869198b317de971b37a945
7
- data.tar.gz: 30acdf7bcb5b036b61a09fea09a39789ee5601770081a0688b619009c2cc3efdeace7e27b6292bab17dcbe45440d26c1328db515aff1d539f782ea48f0638235
6
+ metadata.gz: e98cf655dbb65a787eafecdd57c222d1a802bafe5d4aafaf2779283e630b26c629a0c6db88f62e46363fbdceeb01c4759793a2566c1a1725dd21416614129f75
7
+ data.tar.gz: 5a5b41cdd7c275ae11f30b32533c5dbcc808d07afeca4e71bfe69b895222539567f0c6c50df24837e7d4de4bfee2129c898304a3569dec54459c763dde02f2c7
@@ -91,7 +91,7 @@ module Serfx
91
91
  def kill(sig = 'KILL')
92
92
  if running?
93
93
  begin
94
- Process.kill(sig, state_info['pid'].to_i)
94
+ Process.kill(sig, stateinfo['pid'].to_i)
95
95
  'success'
96
96
  rescue Exception
97
97
  'failed'
@@ -101,7 +101,7 @@ module Serfx
101
101
  end
102
102
  end
103
103
 
104
- # obtain current state information about the task
104
+ # obtain current state information about the task as json
105
105
  #
106
106
  # @return [String] JSON string representing current state of the task
107
107
  def state_info
@@ -112,11 +112,18 @@ module Serfx
112
112
  end
113
113
  end
114
114
 
115
+ # obtain current state information about the task as hash
116
+ #
117
+ # @return [Hash] JSON string representing current state of the task
118
+ def stateinfo
119
+ JSON.parse(state_info)
120
+ end
121
+
115
122
  # delete the statefile of a finished task
116
123
  #
117
124
  # @return [String] 'success' if the task is reaped, 'failed' otherwise
118
125
  def reap
119
- if state_info['status'] == 'finished'
126
+ if stateinfo['status'] == 'finished'
120
127
  File.unlink(state_file)
121
128
  'success'
122
129
  else
@@ -174,7 +181,7 @@ module Serfx
174
181
  # @return [TrueClass, FalseClass] true if the task running, else false
175
182
  def running?
176
183
  if exists?
177
- File.exist?(File.join('/proc', state_info['pid'].to_s))
184
+ File.exist?(File.join('/proc', stateinfo['pid'].to_s))
178
185
  else
179
186
  false
180
187
  end
data/lib/serfx/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  #
3
3
  # Provides version as a contsant for the serf gem
4
4
  module Serfx
5
- VERSION = '0.0.6'
5
+ VERSION = '0.0.7'
6
6
  end
data/lib/serfx.rb CHANGED
@@ -15,15 +15,19 @@ module Serfx
15
15
  # * host => Serf host's rpc bind address (127.0.0.1 by default)
16
16
  # * port => Serf host's rpc port (7373 by default)
17
17
  # * authkey => Encryption key for RPC communiction
18
+ #
19
+ # @return value of the block evaluation of nil
18
20
  def self.connect(opts = {})
19
21
  conn = Serfx::Connection.new(opts)
20
22
  conn.handshake
21
23
  conn.auth if opts.key?(:authkey)
24
+ res = nil
22
25
  if block_given?
23
- yield conn
26
+ res = yield conn
24
27
  conn.close unless conn.closed?
25
28
  else
26
29
  conn
27
30
  end
31
+ res
28
32
  end
29
33
  end
@@ -88,7 +88,7 @@ describe Serfx do
88
88
  response = @conn.members_filtered('group' => 'odd')
89
89
  expect(response.header.error).to be_empty
90
90
  tags = response.body['Members'].map { |x|x['Tags']['group'] }
91
- expect(tags.all? { |t| t == 'odd' }).to be_true
91
+ expect(tags.all? { |t| t == 'odd' }).to be(true)
92
92
  end
93
93
 
94
94
  it '#tags' do
@@ -110,7 +110,7 @@ describe Serfx do
110
110
  t.kill
111
111
  expect(data['Name']).to eq('test')
112
112
  expect(data['Payload']).to eq('whoa')
113
- expect(data['Coalesce']).to be_true
113
+ expect(data['Coalesce']).to be(true)
114
114
  expect(data['Event']).to eq('user')
115
115
  end
116
116
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serfx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rnjib Dey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-02 00:00:00.000000000 Z
11
+ date: 2014-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack