komenda 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -2
- data/lib/komenda.rb +3 -2
- data/lib/komenda/definition.rb +10 -2
- data/lib/komenda/runner.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bde725b71b20821b932fda1e83ba82215bfd27d
|
4
|
+
data.tar.gz: e682bef86069a8d1d175c9e2d84b14f10c3068ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea96829bf08645726f9cc7727e1531c533a528f6f3b4a8cf3cb75648e206b1b624531b89bab09d34e1df06447fd316702945af386aeda93f47add7b83fbb571e
|
7
|
+
data.tar.gz: de7ce00b2c06fa819b2a4b8e3efeaf3cf784e108a78d3b1479db7b3c7aa07f40cbf2599edeb09fecbc7c907c969d0c84d239f88e3e43b7fbaa22ff9a73f6c7dc
|
data/README.md
CHANGED
@@ -22,7 +22,23 @@ result.success? # => true
|
|
22
22
|
result.pid # => 32157
|
23
23
|
```
|
24
24
|
|
25
|
+
The `run()` method has a second argument `options`, which expects these keys:
|
26
|
+
- **`env`** (Hash): The environment variables to use. Defaults to the current process' environment.
|
27
|
+
|
28
|
+
Development
|
29
|
+
-----------
|
30
|
+
Install dependencies:
|
31
|
+
```
|
32
|
+
bundle install
|
33
|
+
```
|
34
|
+
|
35
|
+
Run the tests:
|
36
|
+
```
|
37
|
+
bundle exec rake spec
|
38
|
+
```
|
39
|
+
|
25
40
|
TODO
|
26
41
|
----
|
27
|
-
|
28
|
-
-
|
42
|
+
Add options for:
|
43
|
+
- Passing STDIN
|
44
|
+
- Making `run()` fail when exit status is not "0"
|
data/lib/komenda.rb
CHANGED
@@ -7,9 +7,10 @@ require 'komenda/result'
|
|
7
7
|
module Komenda
|
8
8
|
|
9
9
|
# @param [String] cmd
|
10
|
+
# @param [Hash] options
|
10
11
|
# @return [Komenda::Result]
|
11
|
-
def self.run(cmd)
|
12
|
-
definition = Komenda::Definition.new(cmd)
|
12
|
+
def self.run(cmd, options = {})
|
13
|
+
definition = Komenda::Definition.new(cmd, options)
|
13
14
|
runner = Komenda::Runner.new
|
14
15
|
runner.run(definition)
|
15
16
|
end
|
data/lib/komenda/definition.rb
CHANGED
@@ -2,10 +2,18 @@ module Komenda
|
|
2
2
|
class Definition
|
3
3
|
|
4
4
|
attr_reader :cmd
|
5
|
+
attr_reader :env
|
5
6
|
|
6
7
|
# @param [String] cmd
|
7
|
-
|
8
|
-
|
8
|
+
# @param [Hash] options
|
9
|
+
def initialize(cmd, options = {})
|
10
|
+
defaults = {
|
11
|
+
:env => ENV.to_hash,
|
12
|
+
}
|
13
|
+
options = defaults.merge(options)
|
14
|
+
|
15
|
+
@cmd = String(cmd)
|
16
|
+
@env = Hash[options[:env].to_hash.map { |k, v| [String(k), String(v)] }]
|
9
17
|
end
|
10
18
|
|
11
19
|
end
|
data/lib/komenda/runner.rb
CHANGED
@@ -7,7 +7,7 @@ module Komenda
|
|
7
7
|
output = {:stdout => '', :stderr => '', :combined => ''}
|
8
8
|
status = nil
|
9
9
|
|
10
|
-
Open3.popen3(definition.cmd) do |stdin, stdout, stderr, wait_thr|
|
10
|
+
Open3.popen3(definition.env, definition.cmd) do |stdin, stdout, stderr, wait_thr|
|
11
11
|
stdin.close
|
12
12
|
|
13
13
|
streams_read_open = [stdout, stderr]
|
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.0.
|
4
|
+
version: 0.0.2
|
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: 2015-
|
12
|
+
date: 2015-11-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|