komenda 0.1.5 → 0.1.6

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: 65a139b027294e09563bf3d7f73a1b412b5c642c
4
- data.tar.gz: 5923bb68d00d878c85d2dff63af29b91d772463e
3
+ metadata.gz: 5776b8baf0623308ba5d91c4af70d4de9e6a63c6
4
+ data.tar.gz: de78e64e458c3d8efe96cecbb630c7e5fb6274b7
5
5
  SHA512:
6
- metadata.gz: 4db2036b069b6e9ef3612241984ce32b186f9dbd4e0335818e55d610b8b4d452a41788171218574f6b73ffeacb6771afc51164527e827f4a04c5ce5a7f440cb1
7
- data.tar.gz: ba890be61d9563a5acd4a1e285eda09f3a8e3788c2ecd18cf06a7c0e127ffcdf04b4734b518d252f1c3229b593a181cc220dde7df9204b2133f96970dcab2f44
6
+ metadata.gz: 1644ff0df3f0e8954c6e9b81a736ae37763dc4a8efd0dd78bcab82d43048020d409a44a2fdbb2e131376224465e441b2122efdd040c5b314bfe7f158b5b0d206
7
+ data.tar.gz: 82d702d169daebb599300567684df3272d8c5aa3cd3fcbdf0e1cee2fec22aff15a1a7ccca596a82801a3196e9d9f712942bffbcc4f0703fa8d080a5ad2069a40
data/README.md CHANGED
@@ -34,6 +34,7 @@ The `run()` method has a second argument `options`, which accepts these optional
34
34
  - **`env`** (Hash): Additional environment variables to set.
35
35
  - **`use_bundler_env`** (Boolean): Use the environment variable of the current [bundle](http://bundler.io/). Defaults to `false`.
36
36
  - **`cwd`** (String): Directory to change to before running the process.
37
+ - **`fail_on_fail`** (Boolean): Whether to raise an error when the exit code is not "0". Defaults to `false`.
37
38
 
38
39
  ### Advanced usage
39
40
  The `create()` method creates a `Process` which can be `run()` (or `start()`ed as a Thread).
@@ -28,6 +28,9 @@ module Komenda
28
28
  def wait_for
29
29
  fail 'Process not started' unless started?
30
30
  @thread.join
31
+ if @process_builder.fail_on_fail && !result.success?
32
+ fail "Process failed with exit status `#{result.exitstatus}` and output:\n#{result.output}"
33
+ end
31
34
  result
32
35
  end
33
36
 
@@ -5,6 +5,7 @@ module Komenda
5
5
  attr_reader :env
6
6
  attr_reader :use_bundler_env
7
7
  attr_reader :cwd
8
+ attr_reader :fail_on_fail
8
9
  attr_reader :events
9
10
 
10
11
  # @param [String, String[]] command
@@ -14,6 +15,7 @@ module Komenda
14
15
  env: {},
15
16
  use_bundler_env: false,
16
17
  cwd: nil,
18
+ fail_on_fail: false,
17
19
  events: {}
18
20
  }
19
21
  options = defaults.merge(options)
@@ -22,6 +24,7 @@ module Komenda
22
24
  self.env = options[:env]
23
25
  self.use_bundler_env = options[:use_bundler_env]
24
26
  self.cwd = options[:cwd]
27
+ self.fail_on_fail = options[:fail_on_fail]
25
28
  self.events = options[:events]
26
29
  end
27
30
 
@@ -54,6 +57,11 @@ module Komenda
54
57
  @cwd = cwd.nil? ? nil : String(cwd)
55
58
  end
56
59
 
60
+ # @param [Boolean] fail_on_fail
61
+ def fail_on_fail=(fail_on_fail)
62
+ @fail_on_fail = fail_on_fail ? true : false
63
+ end
64
+
57
65
  # @param [Hash<Symbol, Proc>]
58
66
  def events=(events)
59
67
  @events = Hash[events.to_hash.map { |k, v| [k.to_sym, v.to_proc] }]
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.5
4
+ version: 0.1.6
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-03-19 00:00:00.000000000 Z
12
+ date: 2016-04-24 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.2
131
131
  signing_key:
132
132
  specification_version: 4
133
133
  summary: Convenience wrapper around `Open3` to run shell commands in Ruby.