cmds 0.1.0 → 0.1.1

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: fbffca50ed0a5b832d53b5a3f5713734ce5ecd9c
4
- data.tar.gz: c3dbd1396df4501c412f6b5102aebf77fa3dc4e6
3
+ metadata.gz: 3f2767abdf674497cad3cfc8913da88fddcf6cbc
4
+ data.tar.gz: cd2458c8f02672b9e66d060557e7b996cfc1c8dc
5
5
  SHA512:
6
- metadata.gz: 2aa6e19cf215cbc820b3f0aece36bc3fe2925a915ef59ba5825d2319cae6d7db6ce8621cad0a3ef9f6132d2037ae77e59162d6ee01a6eccd5068fd775edbc221
7
- data.tar.gz: 3d6f7af1c264532734b17a83362619978f8a856476a4cf18f1f38f43077e40185dbd3af3b67e5f83ec7bfec4dde013446e2259789e05a4dc2aa5d9b73ca5d63e
6
+ metadata.gz: 52d88272291712ae57550d0822ae406d9723433866116a2f2802ac65c34423366eef8d1aeb6cb5e6aa778d46abaac3ed830fb96e1060e023f475b9bb4ac86727
7
+ data.tar.gz: c1125b57ebc1036bec4480bf7b3db332ed75305b65c73933e738a400e85892a0b9dafbb4fe49790042d053f14f4b2ab541e48ec631f80952afca81a744b1ba9e
data/.gitignore CHANGED
@@ -16,4 +16,12 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
 
19
- ref/repos
19
+ ref/repos
20
+ ##############################################################################
21
+ # BEGIN Qb.gitingore
22
+ #
23
+ # generated qb playbooks
24
+ .qb-playbook.yml
25
+ #
26
+ # END Qb.gitingore
27
+ ##############################################################################
data/lib/cmds/cmd.rb CHANGED
@@ -59,7 +59,7 @@ module Cmds
59
59
  #
60
60
  # defaults to `{}`.
61
61
  #
62
- # @return [Hash{Symbol => String}]
62
+ # @return [Hash{String | Symbol => String}]
63
63
  attr_reader :env
64
64
 
65
65
  # format specifier symbol:
@@ -165,7 +165,7 @@ module Cmds
165
165
  kwds: kwds,
166
166
  io_block: io_block
167
167
 
168
- Cmds.spawn prepare(*args, **kwds), @input, &io_block
168
+ Cmds.spawn prepare(*args, **kwds), @input, @env, &io_block
169
169
  end # #stream
170
170
 
171
171
 
@@ -210,7 +210,7 @@ module Cmds
210
210
 
211
211
  Cmds.debug "calling Cmds.spawn..."
212
212
 
213
- status = Cmds.spawn cmd do |io|
213
+ status = Cmds.spawn cmd, nil, @env do |io|
214
214
  # send the input to stream, which sends it to spawn
215
215
  io.in = input
216
216
 
data/lib/cmds/spawn.rb CHANGED
@@ -29,6 +29,9 @@ module Cmds
29
29
  # string or readable input. here so that Cmds instances can pass their
30
30
  # `@input` instance variable -- `&io_block` overrides it.
31
31
  #
32
+ # @param [Hash{Symbol | String => Object}] env
33
+ # blah
34
+ #
32
35
  # @param [#call & (#arity ∈ {0, 1})] &io_block
33
36
  # optional block to handle io. behavior depends on arity:
34
37
  #
@@ -42,7 +45,7 @@ module Cmds
42
45
  # @raise [ArgumentError]
43
46
  # if `&io_block` has arity greater than 1.
44
47
  #
45
- def self.spawn cmd, input = nil, &io_block
48
+ def self.spawn cmd, input = nil, env = {}, &io_block
46
49
  Cmds.debug "entering Cmds#really_stream",
47
50
  cmd: cmd,
48
51
  input: input,
@@ -145,10 +148,13 @@ module Cmds
145
148
  end # map outputs
146
149
 
147
150
  Cmds.debug "spawning...",
151
+ env: env,
148
152
  cmd: cmd,
149
153
  opts: spawn_opts
150
154
 
151
- pid = Process.spawn cmd, spawn_opts
155
+ pid = Process.spawn env.map {|k, v| [k.to_s, v]}.to_h,
156
+ cmd,
157
+ spawn_opts
152
158
 
153
159
  Cmds.debug "spawned.",
154
160
  pid: pid
data/lib/cmds/util.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  # stdlib
4
4
  require 'shellwords'
5
5
 
6
- require_relative 'util/tokenize_options'
6
+ require 'cmds/util/tokenize_options'
7
7
 
8
8
  module Cmds
9
9
  # class methods
data/lib/cmds/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cmds
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -11,4 +11,4 @@ describe "Cmds::curry" do
11
11
  expect( echo_cmd_argv x2.call y: 'who' ).to eq ['2', 'who']
12
12
  expect( echo_cmd_argv base.call x: 3, y: 4 ).to eq ['3', '4']
13
13
  end # it currys
14
- end # Cmds::run
14
+ end # Cmds::run
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Cmds ENV vars" do
4
+ it "sets basic (path-like) string ENV var" do
5
+ cmd = Cmds::Cmd.new 'echo "${BLAH}"', env: {BLAH: "x:y:z"}
6
+ expect(cmd.chomp!).to eq "x:y:z"
7
+ end
8
+
9
+ it "sets a string with spaces in it correctly" do
10
+ cmd = Cmds::Cmd.new 'echo "${BLAH}"', env: {BLAH: "hey there"}
11
+ expect(cmd.chomp!).to eq "hey there"
12
+ end
13
+
14
+ it "accepts string keys" do
15
+ cmd = Cmds::Cmd.new 'echo "${BLAH}"', env: {
16
+ 'BLAH' => [
17
+ "/usr/local/bin",
18
+ "/usr/bin",
19
+ "/bin"
20
+ ].join(':')
21
+ }
22
+ expect(cmd.chomp!).to eq "/usr/local/bin:/usr/bin:/bin"
23
+ end
24
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmds
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - nrser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-31 00:00:00.000000000 Z
11
+ date: 2017-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nrser
@@ -164,6 +164,7 @@ files:
164
164
  - spec/cmds/capture_spec.rb
165
165
  - spec/cmds/chomp_spec.rb
166
166
  - spec/cmds/curry_spec.rb
167
+ - spec/cmds/env_spec.rb
167
168
  - spec/cmds/erb_context_spec.rb
168
169
  - spec/cmds/err_spec.rb
169
170
  - spec/cmds/error_spec.rb
@@ -210,6 +211,7 @@ test_files:
210
211
  - spec/cmds/capture_spec.rb
211
212
  - spec/cmds/chomp_spec.rb
212
213
  - spec/cmds/curry_spec.rb
214
+ - spec/cmds/env_spec.rb
213
215
  - spec/cmds/erb_context_spec.rb
214
216
  - spec/cmds/err_spec.rb
215
217
  - spec/cmds/error_spec.rb