rake-commander 0.2.10 → 0.2.12

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: e78481443a21eacbeddb2075f3b483b272a12b62097313934783b36d97666fc6
4
- data.tar.gz: 4ba805e5fe073aa4ac10d856360364a6c0ab3e0a03bb30cec88f66bb9fed63f6
3
+ metadata.gz: 00c13e58c8b9c78ac538ca0100d714a7c3f72ca98a655ae564ebbca13cacf2f6
4
+ data.tar.gz: bfbf686120c4245ba541605db6fbb46e14455b77553948827946fb1417cb376b
5
5
  SHA512:
6
- metadata.gz: eed71d7885cf03d3eb4341936ddeb0c5a155fa2058a5f0cc4f0dbb0d0fdfb20b3effee5c0671f07070b79025e031192f9e3150e389e478d768d92892de046237
7
- data.tar.gz: cb696bb18618c2b547a7d3708d66ff54aa6011cd60e7e40e91f01b617e5ee7a5e7e5146ccbfd453070513faf0baac608383fe9deaf80a264bf3cfd2dcc9491e3
6
+ metadata.gz: 1d7941181f5ea5b4bd1210bcb3e5a1307bbedbd0a503636144af350a320a6a7ed4a5d8948d2212c81b401513bb383c37ad4645825e544cb952a73bbdf3d62110
7
+ data.tar.gz: 41a29e32b0536d073c4481df467ff65351bd84c5782db961398ea6ac66c73d6652d623df7d1c363e321130182f32db78368528996b7331478c16505b1b059c76
data/CHANGELOG.md CHANGED
@@ -32,12 +32,23 @@ All notable changes to this project will be documented in this file.
32
32
  - Option to globally enable/disable the 2nd patch?
33
33
  * That would make this gem completely useless.
34
34
 
35
- ## [0.2.11] - 2023-05-xx
35
+ ## [0.2.13] - 2023-05-xx
36
36
 
37
37
  ### Added
38
38
  ### Fixed
39
39
  ### Changed
40
40
 
41
+ ## [0.2.12] - 2023-05-xx
42
+
43
+ ### Fixed
44
+ - `RakeCommander::Option#type_coercion` wasn't correctly captured.
45
+
46
+
47
+ ## [0.2.11] - 2023-05-01
48
+
49
+ ### Fixed
50
+ - When `RakeCommander::Option#type_coercion` is `FalseClass`, it should reverse the result.
51
+
41
52
  ## [0.2.10] - 2023-05-01
42
53
 
43
54
  ### Fixed
@@ -7,6 +7,7 @@ class RakeCommander::Custom::ChainedPlus < RakeCommander::Custom::Chained
7
7
  option :e, '--exit-on-error', TrueClass, desc: 'If it should just exit on "missing argument" error or raise an exception'
8
8
  # Move option to the end, make **required** the argument (SOMETHING) as well as the option itself.
9
9
  option :s, '--say SOMETHING', "It says 'something'", required: true
10
+ option :y, '--no-way', FalseClass, "It returns 'true' when used"
10
11
 
11
12
  error_on_options error: RakeCommander::Options::Error::MissingArgument do |err, _argv, results, _leftovers|
12
13
  msg = "Parsed results when 'missing argument' error was raised"
@@ -92,7 +92,9 @@ class RakeCommander
92
92
 
93
93
  # @return [Class, NilClass]
94
94
  def type_coercion
95
- @type_coercion || (default? && default.class)
95
+ value = @type_coercion || (default? && default.class)
96
+ return nil unless value.is_a?(Class)
97
+ value
96
98
  end
97
99
 
98
100
  # @return [Boolean]
@@ -151,7 +153,8 @@ class RakeCommander
151
153
  def option_block(&middleware)
152
154
  block_extra_args = [default, short, name, self]
153
155
  proc do |value|
154
- args = block_extra_args.dup.unshift(value)
156
+ value = !value if type_coercion == FalseClass
157
+ args = block_extra_args.dup.unshift(value)
155
158
  original_block&.call(*args)
156
159
  middleware&.call(*args)
157
160
  end
@@ -229,14 +232,14 @@ class RakeCommander
229
232
 
230
233
  # It consumes `other_args`, to prevent direct overrides to be overriden by it.
231
234
  def configure_other
232
- @type_coertion ||= fetch_type_from_other
235
+ @type_coercion ||= fetch_type_from_other
233
236
  @desc ||= fetch_desc_from_other
234
237
  nil
235
238
  end
236
239
 
237
240
  def fetch_type_from_other
238
241
  return nil unless type = other_args.find {|arg| arg.is_a?(Class)}
239
- other_args.delete(type)
242
+ type.tap { other_args.delete(type) }
240
243
  end
241
244
 
242
245
  def fetch_desc_from_other
@@ -1,3 +1,3 @@
1
1
  class RakeCommander
2
- VERSION = '0.2.10'.freeze
2
+ VERSION = '0.2.12'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake-commander
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura Samper