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 +4 -4
- data/CHANGELOG.md +12 -1
- data/examples/03_b_chained_plus_example.rb +1 -0
- data/lib/rake-commander/option.rb +7 -4
- data/lib/rake-commander/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00c13e58c8b9c78ac538ca0100d714a7c3f72ca98a655ae564ebbca13cacf2f6
|
4
|
+
data.tar.gz: bfbf686120c4245ba541605db6fbb46e14455b77553948827946fb1417cb376b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
-
|
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
|
-
@
|
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
|