serfx 0.0.7 → 0.0.8

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: 192f63ff3c81b7514e291a9ddd7e4061c3ec97a3
4
- data.tar.gz: 9a4dfc3ca65be460ba0097338c1c57f5fce3bd89
3
+ metadata.gz: 93d9b356f7f57d5d478e7029cfd102ba0f4df9c9
4
+ data.tar.gz: 56328c5f96c7b274a1b1e9cafd3e6d34cf0ee989
5
5
  SHA512:
6
- metadata.gz: e98cf655dbb65a787eafecdd57c222d1a802bafe5d4aafaf2779283e630b26c629a0c6db88f62e46363fbdceeb01c4759793a2566c1a1725dd21416614129f75
7
- data.tar.gz: 5a5b41cdd7c275ae11f30b32533c5dbcc808d07afeca4e71bfe69b895222539567f0c6c50df24837e7d4de4bfee2129c898304a3569dec54459c763dde02f2c7
6
+ metadata.gz: d00717242ab33e17855a25952e4d75c820e9cfc4b13aa6a3cabde733701bb6736abf00dcf0d15964398c3eba954fdf14135279e4c1196d023e5a12a22d0c63e6
7
+ data.tar.gz: b2244787a7fa11cd352b44d74f4ee44dc6b75e47f285fcee053ff1c9e12c448f78d8e1866f3fb63008605a32897fb3b6039e5fa6cdffcca1e0c9327c4884942b
@@ -2,7 +2,6 @@ before_install:
2
2
  - bash download_serf
3
3
  - bundle install --path .bundle
4
4
  rvm:
5
- - 1.9.2
6
5
  - 1.9.3
7
6
  - 2.0.0
8
7
  - 2.1.0
@@ -7,16 +7,16 @@ require 'serfx/connection'
7
7
  # Serfx is a minimal ruby client for serf.
8
8
  module Serfx
9
9
  # Creates a serf rpc connection, performs handshake and auth
10
- # (if authkey is supplied), if
11
- # a block if provided, the connection will be closed after the block's
12
- # execution.
10
+ # (if authkey is supplied). If a block is provided, the connection
11
+ # object will be yield-ed and the connection will be closed after
12
+ # the block's execution, otherwise the connection will be returned
13
13
  # Params:
14
14
  # +opts+:: An optional hash which can have following keys:
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
18
  #
19
- # @return value of the block evaluation of nil
19
+ # @return value of the block evaluation or the connection object
20
20
  def self.connect(opts = {})
21
21
  conn = Serfx::Connection.new(opts)
22
22
  conn.handshake
@@ -25,9 +25,9 @@ module Serfx
25
25
  if block_given?
26
26
  res = yield conn
27
27
  conn.close unless conn.closed?
28
+ res
28
29
  else
29
30
  conn
30
31
  end
31
- res
32
32
  end
33
33
  end
@@ -68,7 +68,13 @@ module Serfx
68
68
  # serf query bash_test reap # delete a finished job's state file
69
69
  # serf query bash_test kill
70
70
  class AsyncJob
71
- attr_reader :command, :state_file, :stdout_file, :stderr_file
71
+
72
+ attr_reader :command
73
+ attr_reader :state_file
74
+ attr_reader :stdout_file
75
+ attr_reader :stderr_file
76
+ attr_reader :environment
77
+ attr_reader :cwd
72
78
 
73
79
  # @param opts [Hash] specify the job details
74
80
  # @option opts [Symbol] :state file path which will be used to store
@@ -77,11 +83,15 @@ module Serfx
77
83
  # in the background
78
84
  # @option opts [Symbol] :stdout standard output file for the task
79
85
  # @option opts [Symbol] :stderr standard error file for the task
86
+ # @option opts [Symbol] :environment a hash containing environment variables
87
+ # @option opts [Symbol] :cwd a string (directory path) containing current directory of the command
80
88
  def initialize(opts = {})
81
89
  @state_file = opts[:state] || fail(ArgumentError, 'Specify state file')
82
90
  @command = opts[:command]
83
91
  @stdout_file = opts[:stdout] || File::NULL
84
92
  @stderr_file = opts[:stderr] || File::NULL
93
+ @environment = opts[:environment] || {}
94
+ @cwd = opts[:cwd] || Dir.pwd
85
95
  end
86
96
 
87
97
  # kill an already running task
@@ -153,9 +163,11 @@ module Serfx
153
163
  write_state(state)
154
164
  begin
155
165
  child_pid = Process.spawn(
166
+ environment,
156
167
  command,
157
168
  out: stdout_file,
158
- err: stderr_file
169
+ err: stderr_file,
170
+ chdir: cwd
159
171
  )
160
172
  state[:pid] = child_pid
161
173
  state[:status] = 'running'
@@ -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.7'
5
+ VERSION = '0.0.8'
6
6
  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.7
4
+ version: 0.0.8
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-22 00:00:00.000000000 Z
11
+ date: 2014-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack