mixlib-cli 2.1.1 → 2.1.5

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
  SHA256:
3
- metadata.gz: 2b8683633510a1051757c76330c88e8e4cab1cd60865201cd28a6279594c1864
4
- data.tar.gz: df37fea633f62f50794ab29e7ae906af86b64024ee028443ae02af63955aa03b
3
+ metadata.gz: 846ac98eeac7702d578383b5d8820e39f8cea5c23c6e4b137f2db0199becdefe
4
+ data.tar.gz: 772268d27fa8f9e17bcf4c59ce03e656b58b2a4e5e16ffc43c284424b365b1fb
5
5
  SHA512:
6
- metadata.gz: fe7536b6882b4c7886a7e00a2d723f201ed51f3bfedc3ff010a9af605da5d3885fc503f807ab813d5bacbfb41a7c084fe6c476ba7428721f268547f0401b6890
7
- data.tar.gz: 5433999e3552ee56aee2babbe847df8a30331759a7afe93632bf84d7c77968463907735f3fca768f407ce65372436e4c8cc865560355f169707f861b01a2ca3e
6
+ metadata.gz: f838cb43f024b39db6bd9975802fb75d2707524c2d2c34ce7f895c2b218e22d0d3a7f62f95c40ea5feddcede09c6a7e57656966d8b4f8d92f265ead741d0b757
7
+ data.tar.gz: aa62d3c7c57e47d7bb7aea504da13f3ded85402a2783ee4c7635a8ac32658cc4f5655384a6d53d6cf03fb78013d27d713255f9317336ff65ac9ef892f29525ec
@@ -52,8 +52,8 @@ module Mixlib
52
52
  # contents will be iterated and cloned as well.
53
53
  def deep_dup(object)
54
54
  cloned_object = object.respond_to?(:dup) ? object.dup : object
55
- if cloned_object.kind_of?(Enumerable)
56
- if cloned_object.kind_of?(Hash)
55
+ if cloned_object.is_a?(Enumerable)
56
+ if cloned_object.is_a?(Hash)
57
57
  new_hash = cloned_object.class.new
58
58
  cloned_object.each do |key, value|
59
59
  cloned_key = deep_dup(key)
@@ -122,7 +122,8 @@ module Mixlib
122
122
  # i
123
123
  def option(name, args)
124
124
  @options ||= {}
125
- raise(ArgumentError, "Option name must be a symbol") unless name.kind_of?(Symbol)
125
+ raise(ArgumentError, "Option name must be a symbol") unless name.is_a?(Symbol)
126
+
126
127
  @options[name.to_sym] = args
127
128
  end
128
129
 
@@ -148,12 +149,12 @@ module Mixlib
148
149
  # === Returns
149
150
  # <Hash> :: The config hash for the created option.
150
151
  def deprecated_option(name,
151
- replacement: nil,
152
- long: nil,
153
- short: nil,
154
- boolean: false,
155
- value_mapper: nil,
156
- keep: true)
152
+ replacement: nil,
153
+ long: nil,
154
+ short: nil,
155
+ boolean: false,
156
+ value_mapper: nil,
157
+ keep: true)
157
158
 
158
159
  description = if replacement
159
160
  replacement_cfg = options[replacement]
@@ -165,15 +166,15 @@ module Mixlib
165
166
  value_mapper ||= Proc.new { |v| v }
166
167
 
167
168
  option(name,
168
- long: long,
169
- short: short,
170
- boolean: boolean,
171
- description: description,
172
- on: :tail,
173
- deprecated: true,
174
- keep: keep,
175
- replacement: replacement,
176
- value_mapper: value_mapper)
169
+ long: long,
170
+ short: short,
171
+ boolean: boolean,
172
+ description: description,
173
+ on: :tail,
174
+ deprecated: true,
175
+ keep: keep,
176
+ replacement: replacement,
177
+ value_mapper: value_mapper)
177
178
  end
178
179
 
179
180
  # Get the hash of current options.
@@ -193,7 +194,8 @@ module Mixlib
193
194
  # === Returns
194
195
  # @options<Hash>:: The current options hash.
195
196
  def options=(val)
196
- raise(ArgumentError, "Options must recieve a hash") unless val.kind_of?(Hash)
197
+ raise(ArgumentError, "Options must recieve a hash") unless val.is_a?(Hash)
198
+
197
199
  @options = val
198
200
  end
199
201
 
@@ -256,9 +258,9 @@ module Mixlib
256
258
  # === Returns
257
259
  # object<Mixlib::Config>:: Returns an instance of whatever you wanted :)
258
260
  def initialize(*args)
259
- @options = Hash.new
260
- @config = Hash.new
261
- @default_config = Hash.new
261
+ @options = {}
262
+ @config = {}
263
+ @default_config = {}
262
264
  @opt_parser = nil
263
265
 
264
266
  # Set the banner
@@ -316,9 +318,10 @@ module Mixlib
316
318
  exit 2
317
319
  end
318
320
  if opt_config[:in]
319
- unless opt_config[:in].kind_of?(Array)
321
+ unless opt_config[:in].is_a?(Array)
320
322
  raise(ArgumentError, "Options config key :in must receive an Array")
321
323
  end
324
+
322
325
  if config[opt_key] && !opt_config[:in].include?(config[opt_key])
323
326
  reqarg = Formatter.combined_option_display_name(opt_config[:short], opt_config[:long])
324
327
  puts "#{reqarg}: #{config[opt_key]} is not one of the allowed values: #{Formatter.friendly_opt_list(opt_config[:in])}"
@@ -358,7 +361,7 @@ module Mixlib
358
361
  end
359
362
 
360
363
  parse_block =
361
- Proc.new() do |c|
364
+ Proc.new do |c|
362
365
  config[opt_key] = if opt_val[:proc]
363
366
  if opt_val[:proc].arity == 2
364
367
  # New hotness to allow for reducer-style procs.
@@ -427,7 +430,7 @@ module Mixlib
427
430
  end
428
431
 
429
432
  def build_option_arguments(opt_setting)
430
- arguments = Array.new
433
+ arguments = []
431
434
 
432
435
  arguments << opt_setting[:short] if opt_setting[:short]
433
436
  arguments << opt_setting[:long] if opt_setting[:long]
@@ -25,6 +25,7 @@ module Mixlib
25
25
  def self.friendly_opt_list(opt_array)
26
26
  opts = opt_array.map { |x| "'#{x}'" }
27
27
  return opts.join(" or ") if opts.size < 3
28
+
28
29
  opts[0..-2].join(", ") + ", or " + opts[-1]
29
30
  end
30
31
  end
@@ -1,5 +1,5 @@
1
1
  module Mixlib
2
2
  module CLI
3
- VERSION = "2.1.1".freeze
3
+ VERSION = "2.1.5".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixlib-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef Software, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-10 00:00:00.000000000 Z
11
+ date: 2019-12-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple mixin for CLI interfaces, including option parsing
14
14
  email: info@chef.io