rake-commander 0.2.3 → 0.2.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 +4 -4
- data/CHANGELOG.md +13 -4
- data/lib/rake-commander/base/class_inheritable.rb +3 -3
- data/lib/rake-commander/options.rb +16 -4
- data/lib/rake-commander/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 580b47f2dc5213236846d91e47832787c2f1d50cd396dae322ea1ab91b6c31f7
|
4
|
+
data.tar.gz: 348609827f993bea3b61a9ca43d59456a98f093bd1029e1988bf2f2862633ee2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aae7e0db0dcd102dc43b4a1a5f1281be80ddb6246edaeb5507b1bf17d88f6cca7fcac31f090cf10a95176eaf880a891b937b5136fdcc374003ab0afc2daf622e
|
7
|
+
data.tar.gz: '0080e78b63488f7ce927e8364a479f3bc11d5f920708b0b640fd0fc3e7668d69edb3940df958a4cd3e667a0842d5c63ac6c89cf548b2f4e239b41db26e30d2fd'
|
data/CHANGELOG.md
CHANGED
@@ -32,20 +32,29 @@ 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.6] - 2023-05-xx
|
36
36
|
|
37
37
|
### Added
|
38
38
|
### Fixed
|
39
39
|
### Changed
|
40
40
|
|
41
|
+
## [0.2.5] - 2023-05-01
|
42
|
+
|
43
|
+
### Changed
|
44
|
+
- `RakeCommander::Base::ClassInheritable#inherited_class_value` now expects a reference to the subclass
|
45
|
+
|
46
|
+
## [0.2.4] - 2023-04-30
|
47
|
+
|
48
|
+
### Added
|
49
|
+
- `RakeCommander::Options`
|
50
|
+
- `::option_get` retrieves an option by name or short, may it exist.
|
51
|
+
- `::option?` to check if an opion exists.
|
52
|
+
|
41
53
|
## [0.2.3] - 2023-04-29
|
42
54
|
|
43
55
|
### Added
|
44
56
|
- Include Symbol option names in the parsed option results.
|
45
57
|
|
46
|
-
### Fixed
|
47
|
-
### Changed
|
48
|
-
|
49
58
|
## [0.2.2] - 2023-04-29
|
50
59
|
|
51
60
|
### Fixed
|
@@ -50,7 +50,7 @@ class RakeCommander
|
|
50
50
|
definitions.each do |var, action|
|
51
51
|
instance_var = instance_variable_name(var)
|
52
52
|
value = instance_variable_get(instance_var)
|
53
|
-
child_value = inherited_class_value(value, method, action)
|
53
|
+
child_value = inherited_class_value(value, method, action, subclass)
|
54
54
|
subclass.instance_variable_set(instance_var, child_value)
|
55
55
|
end
|
56
56
|
end
|
@@ -58,14 +58,14 @@ class RakeCommander
|
|
58
58
|
end
|
59
59
|
|
60
60
|
# @return [Variant] the value that the child class will inherit
|
61
|
-
def inherited_class_value(value, method, action)
|
61
|
+
def inherited_class_value(value, method, action, subclass)
|
62
62
|
case method
|
63
63
|
when :mirror
|
64
64
|
value
|
65
65
|
when :deep_dup
|
66
66
|
case action
|
67
67
|
when Proc
|
68
|
-
action.call(value)
|
68
|
+
action.call(value, subclass)
|
69
69
|
when :default
|
70
70
|
custom_deep_dup(value)
|
71
71
|
end
|
@@ -94,6 +94,18 @@ class RakeCommander
|
|
94
94
|
options_hash.values.uniq
|
95
95
|
end
|
96
96
|
|
97
|
+
# @param sym [Symbol] the `name` or `short` of the option.
|
98
|
+
# @return [RakeCommander::Option, NilClass] retrieves the option.
|
99
|
+
def option_get(sym)
|
100
|
+
options_hash[sym.to_sym]
|
101
|
+
end
|
102
|
+
|
103
|
+
# @param sym [Symbol] the `name` or `short` of the option.
|
104
|
+
# @return [Boolean] whether an option has been declared.
|
105
|
+
def option?(sym)
|
106
|
+
options_hash.key?(sym.to_sym)
|
107
|
+
end
|
108
|
+
|
97
109
|
# @return [Boolean] are there options defined?
|
98
110
|
def options?
|
99
111
|
!options.empty?
|
@@ -149,7 +161,7 @@ class RakeCommander
|
|
149
161
|
def implicit_shorts
|
150
162
|
options.each_with_object({}) do |opt, implicit|
|
151
163
|
short = opt.short_implicit
|
152
|
-
implicit[short] = opt unless
|
164
|
+
implicit[short] = opt unless option?(short)
|
153
165
|
end
|
154
166
|
end
|
155
167
|
|
@@ -159,7 +171,7 @@ class RakeCommander
|
|
159
171
|
# @note `OptionParser` already has `-h --help` as a native option.
|
160
172
|
# @param opts [OptionParser] where the help will be added.
|
161
173
|
def option_help(opts)
|
162
|
-
return false if
|
174
|
+
return false if option?(:help) || option?(:h)
|
163
175
|
option(:h, :help, 'Prints this help') do
|
164
176
|
puts opts
|
165
177
|
exit(0)
|
@@ -191,12 +203,12 @@ class RakeCommander
|
|
191
203
|
# @return [RakeCommander::Option, NilClass] the option that was added, `nil` is returned otherwise.
|
192
204
|
def add_to_options(opt, override: true)
|
193
205
|
name_ref = respond_to?(:name)? " (#{name})" : ''
|
194
|
-
if sprev =
|
206
|
+
if sprev = option_get(opt.short)
|
195
207
|
return nil unless override
|
196
208
|
puts "Warning#{name_ref}: Overriding option '#{sprev.name}' with short '#{sprev.short}' ('#{opt.name}')"
|
197
209
|
delete_from_options(sprev)
|
198
210
|
end
|
199
|
-
if nprev =
|
211
|
+
if nprev = option_get(opt.name)
|
200
212
|
return nil unless override
|
201
213
|
puts "Warning#{name_ref}: Overriding option '#{nprev.short}' with name '#{nprev.name}' ('#{opt.short}')"
|
202
214
|
delete_from_options(nprev)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rake-commander
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Segura Samper
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|