mixlib-shellout 3.1.1-universal-mingw32 → 3.1.2-universal-mingw32

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
  SHA256:
3
- metadata.gz: 7113f252c59a3efdeea40d32a3198d5a9f12f75bc3f937f9c336dad70af2df35
4
- data.tar.gz: 1ce89dd828db10b56ab70efdf57c1aa696087dc2ada86b30d8b7678fe30676df
3
+ metadata.gz: ff0d68faea99e58c39edacd851b596bfd5a39d53fb778b9e12da8abb3bab8a46
4
+ data.tar.gz: b9e6f5efb5f63c8767dda3f47b46fac20829dc7bfd6de35c3317d5f02fe98652
5
5
  SHA512:
6
- metadata.gz: 16e054814bab6099704d204b9473243ed594ebaf04f632287bc8fb5cbe73d35933596be255de9ee5b32f733c1163063c8606067750db52592dd53137c137e450
7
- data.tar.gz: 44adaa809681d53a81b9e1ffafe3f5c692037662149917a874f18dfb4a910e0613a8064b98b090f51810adb5e3603ba5c18bf96f20e84f2c81f47379858270f5
6
+ metadata.gz: ba31783f95a5db34698906f43591e649eb1615e1eee536f94e61f27e87622aed9e1b7714c9c00602d64e529ccd8b9d7db2061525d7142ded0580b6760cbbca28
7
+ data.tar.gz: bdf404d7c0ab0ce145170428388c5a02994cea8088a880fc2a71865896fdc75c9b562bc65eb9131e855dd0bf8190e30a6553c246fb5eb2863723e0f786560ae8
@@ -17,32 +17,22 @@
17
17
 
18
18
  require_relative "../shellout"
19
19
  require "chef-utils"
20
- require "chef-utils/dsl/path_sanity"
20
+ require "chef-utils/dsl/default_paths"
21
21
  require "chef-utils/internal"
22
22
 
23
23
  module Mixlib
24
24
  class ShellOut
25
25
  module Helper
26
26
  include ChefUtils::Internal
27
- include ChefUtils::DSL::PathSanity
27
+ include ChefUtils::DSL::DefaultPaths
28
28
 
29
- # PREFERRED APIS:
30
29
  #
31
- # all consumers should now call shell_out!/shell_out.
30
+ # These APIs are considered public for use in ohai and chef (by cookbooks and plugins, etc)
31
+ # but are considered private/experimental for now for the direct users of mixlib-shellout.
32
32
  #
33
- # the shell_out_compacted/shell_out_compacted! APIs are private but are intended for use
34
- # in rspec tests, and should ideally always be used to make code refactoring that do not
35
- # change behavior easier:
36
- #
37
- # allow(provider).to receive(:shell_out_compacted!).with("foo", "bar", "baz")
38
- # provider.shell_out!("foo", [ "bar", nil, "baz"])
39
- # provider.shell_out!(["foo", nil, "bar" ], ["baz"])
40
- #
41
- # note that shell_out_compacted also includes adding the magical timeout option to force
42
- # people to setup expectations on that value explicitly. it does not include the default_env
43
- # mangling in order to avoid users having to setup an expectation on anything other than
44
- # setting `default_env: false` and allow us to make tweak to the default_env without breaking
45
- # a thousand unit tests.
33
+ # You can see an example of how to handle the "dependenecy injection" in the rspec unit test.
34
+ # That backend API is left deliberately undocumented for now and may not follow SemVer and may
35
+ # break at any time (at least for the rest of 2020).
46
36
  #
47
37
 
48
38
  def shell_out(*args, **options)
@@ -98,15 +88,28 @@ module Mixlib
98
88
  "LC_ALL" => __config[:internal_locale],
99
89
  "LANGUAGE" => __config[:internal_locale],
100
90
  "LANG" => __config[:internal_locale],
101
- __env_path_name => sanitized_path,
91
+ __env_path_name => default_paths,
102
92
  }.update(options[env_key] || {})
103
93
  end
104
94
  options
105
95
  end
106
96
 
107
- # this SHOULD be used for setting up expectations in rspec, see banner comment at top.
97
+ # The shell_out_compacted/shell_out_compacted! APIs are private but are intended for use
98
+ # in rspec tests. They should always be used in rspec tests instead of shell_out to allow
99
+ # for less brittle rspec tests.
108
100
  #
109
- # the private constraint is meant to avoid code calling this directly, rspec expectations are fine.
101
+ # This expectation:
102
+ #
103
+ # allow(provider).to receive(:shell_out_compacted!).with("foo", "bar", "baz")
104
+ #
105
+ # Is met by many different possible calling conventions that mean the same thing:
106
+ #
107
+ # provider.shell_out!("foo", [ "bar", nil, "baz"])
108
+ # provider.shell_out!(["foo", nil, "bar" ], ["baz"])
109
+ #
110
+ # Note that when setting `default_env: false` that you should just setup an expectation on
111
+ # :shell_out_compacted for `default_env: false`, rather than the expanded env settings so
112
+ # that the default_env implementation can change without breaking unit tests.
110
113
  #
111
114
  def shell_out_compacted(*args, **options)
112
115
  options = __apply_default_env(options)
@@ -117,10 +120,6 @@ module Mixlib
117
120
  end
118
121
  end
119
122
 
120
- # this SHOULD be used for setting up expectations in rspec, see banner comment at top.
121
- #
122
- # the private constraint is meant to avoid code calling this directly, rspec expectations are fine.
123
- #
124
123
  def shell_out_compacted!(*args, **options)
125
124
  options = __apply_default_env(options)
126
125
  cmd = if options.empty?
@@ -132,23 +131,12 @@ module Mixlib
132
131
  cmd
133
132
  end
134
133
 
135
- # Helper for subclasses to reject nil out of an array. It allows
136
- # using the array form of shell_out (which avoids the need to surround arguments with
137
- # quote marks to deal with shells).
138
- #
139
- # Usage:
140
- # shell_out!(*clean_array("useradd", universal_options, useradd_options, new_resource.username))
141
- #
142
- # universal_options and useradd_options can be nil, empty array, empty string, strings or arrays
143
- # and the result makes sense.
144
- #
145
- # keeping this separate from shell_out!() makes it a bit easier to write expectations against the
146
- # shell_out args and be able to omit nils and such in the tests (and to test that the nils are
147
- # being rejected correctly).
134
+ # Helper for subclasses to reject nil out of an array. It allows using the array form of
135
+ # shell_out (which avoids the need to surround arguments with quote marks to deal with shells).
148
136
  #
149
137
  # @param args [String] variable number of string arguments
150
138
  # @return [Array] array of strings with nil and null string rejection
151
-
139
+ #
152
140
  def __clean_array(*args)
153
141
  args.flatten.compact.map(&:to_s)
154
142
  end
@@ -1,5 +1,5 @@
1
1
  module Mixlib
2
2
  class ShellOut
3
- VERSION = "3.1.1".freeze
3
+ VERSION = "3.1.2".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixlib-shellout
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.1.2
5
5
  platform: universal-mingw32
6
6
  authors:
7
7
  - Chef Software Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-17 00:00:00.000000000 Z
11
+ date: 2020-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-utils