komenda 0.1.7 → 0.1.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: 539e892cf6dd52f871008d73d4597f549c40664a
4
- data.tar.gz: 6421357e13b63bb9e3c59f45532cd72b8e4ea4db
3
+ metadata.gz: 7363d1fd415448c30eb3c0f44f8ad366f2a9180a
4
+ data.tar.gz: ac53399da6a6e2bcda191b45e8d948e7eebfe110
5
5
  SHA512:
6
- metadata.gz: b9c596b3f1c0cf1c50630ca6044793f85be884fb78367b1250840d7f90626cef45a1610d1044cddcabfb3a47089720bac0dc792a7ba4787df0d2d58dcf47685d
7
- data.tar.gz: 5d0bd13566dfc652623f33240611830c1cf0fa205ba355e8ac98af28c4530d64c494db093201b5b94792065d11ae76faa4340b19c0fc59e699b202391753ffb9
6
+ metadata.gz: c5020b1f9715318ab60510e8884405d5b4d884f0e9e8897bc2d8786403304a51dd8b076da9fe248d50fd2d6aff5cc8e685b3a791f627170e1d7d6a1970d7e8a9
7
+ data.tar.gz: 35f4253ee44c608aa5ec532640f7891a9c3158327b3cc41ea6469bd3840bd4c1a33df166a7df5eb80e4b8e21b4bace67ddd03567128cdb91073ac59e60ca8b4e
data/README.md CHANGED
@@ -22,6 +22,7 @@ result.stderr # => ""
22
22
  result.output # => "Tue Nov 26 14:45:03 EST 2013\n" (combined stdout + stderr)
23
23
  result.status # => 0
24
24
  result.success? # => true
25
+ result.error? # => false
25
26
  result.pid # => 32157
26
27
  ```
27
28
  The program and its arguments can be passed as an array:
@@ -74,3 +75,9 @@ Run the tests:
74
75
  ```
75
76
  bundle exec rake spec
76
77
  ```
78
+
79
+ Release a new version:
80
+
81
+ 1. Bump the version in `komenda.gemspec`, merge to master.
82
+ 2. Push a new tag to master.
83
+ 3. Release to RubyGems with `bundle exec rake release`.
@@ -28,7 +28,7 @@ module Komenda
28
28
  def wait_for
29
29
  raise 'Process not started' unless started?
30
30
  @thread.join
31
- if @process_builder.fail_on_fail && !result.success?
31
+ if @process_builder.fail_on_fail && result.error?
32
32
  raise "Process failed with exit status `#{result.exitstatus}` and output:\n#{result.output}"
33
33
  end
34
34
  result
@@ -53,7 +53,10 @@ module Komenda
53
53
 
54
54
  # @return [TrueClass, FalseClass]
55
55
  def running?
56
- started? && !@pid.nil? && !finished?
56
+ return false if @pid.nil?
57
+ 1 == ::Process.kill(0, @pid)
58
+ rescue Errno::ESRCH
59
+ false
57
60
  end
58
61
 
59
62
  # @return [Komenda::Result]
@@ -69,24 +69,33 @@ module Komenda
69
69
 
70
70
  # @return [Hash]
71
71
  def env_final
72
- env_original = if !use_bundler_env && Object.const_defined?('Bundler')
73
- bundler_clean_env
74
- else
75
- ENV.to_hash
76
- end
77
72
  env_original.merge(env)
78
73
  end
79
74
 
80
75
  private
81
76
 
82
77
  # @return [Hash]
83
- def bundler_clean_env
84
- if Bundler.methods(false).include?(:clean_env)
85
- Bundler.clean_env
78
+ def env_original
79
+ if !use_bundler_env && Object.const_defined?('Bundler')
80
+ bundler_clean_env
86
81
  else
87
- # For Bundler < 1.12.0
88
- Bundler.with_clean_env { ENV.to_hash }
82
+ ENV.to_hash
89
83
  end
90
84
  end
85
+
86
+ # @return [Hash]
87
+ def bundler_clean_env
88
+ env = if Bundler.methods(false).include?(:clean_env)
89
+ Bundler.clean_env
90
+ else
91
+ # For Bundler < 1.12.0
92
+ Bundler.with_clean_env { ENV.to_hash }
93
+ end
94
+ # Work around limitations of `Bundler.clean_env`
95
+ env.delete('BUNDLER_VERSION')
96
+ env.delete('RUBYOPT') if env.key?('RUBYOPT') && env['RUBYOPT'] == ''
97
+ env.delete('RUBYLIB') if env.key?('RUBYLIB') && env['RUBYLIB'] == ''
98
+ env
99
+ end
91
100
  end
92
101
  end
@@ -31,6 +31,10 @@ module Komenda
31
31
  exitstatus == 0
32
32
  end
33
33
 
34
+ def error?
35
+ exitstatus != 0
36
+ end
37
+
34
38
  def pid
35
39
  @status.pid
36
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: komenda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cargo Media
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-10-06 00:00:00.000000000 Z
12
+ date: 2017-05-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: events
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  version: '0'
128
128
  requirements: []
129
129
  rubyforge_project:
130
- rubygems_version: 2.5.1
130
+ rubygems_version: 2.6.11
131
131
  signing_key:
132
132
  specification_version: 4
133
133
  summary: Convenience wrapper around `Open3` to run shell commands in Ruby.