switches.rb 0.12.0 → 0.12.1
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 +15 -12
- data/lib/Switches/VERSION.rb +1 -1
- data/lib/Switches.rb +0 -9
- 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: 43cb8cbe7416baef56a0b3da428ad241fcd8b4622d926e6c64e0db0aa311d439
|
|
4
|
+
data.tar.gz: cbd74c3f9d883474c4e207ae1974f9f8271d2fb25865cf606c48794bc1498a61
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 06ab95f84758ab089a5ce0665ed43e5177b9fd638a0a663ade5ab52c94d587447ccd25fa890c26cd126a44b9da801bbb4aa0d1b647cc3d3423d6095cebdd64e8
|
|
7
|
+
data.tar.gz: bdc919b1bb6d903752337f606c91cd8cde56df35185c5b3b22a54aa5e7ef69bc30ac4553a03de60ff65773f4460bc905e6f5324c8ddf01d0deec0a8a7b55a29c
|
data/CHANGELOG
CHANGED
|
@@ -2,30 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
## 20260816
|
|
4
4
|
|
|
5
|
+
0.12.1: Move the reasoning out of the CHANGELOG and the header into a ROADMAP.
|
|
6
|
+
|
|
7
|
+
1. + ROADMAP.md: the design philosophy, a section per shipped version carrying why it went the way it did, the open questions, and the settled items. Not listed in the gemspec, so it does not ship. Follows namo's ROADMAP.md.
|
|
8
|
+
2. - lib/Switches.rb: the # Todo: and # Ideas: header sections, now in ROADMAP.md, finishing what 0.10.2 began.
|
|
9
|
+
3. ~ CHANGELOG: the 0.10.5 and 0.11.0 entries carried reasoning, measurement and outstanding work in prose between their numbered items; that is now in ROADMAP.md, and the entries record what changed.
|
|
10
|
+
|
|
5
11
|
0.12.0: Refuse a switch whose accessor is a method the instance already has, rather than losing it.
|
|
6
12
|
|
|
7
13
|
1. + lib/Switches.rb: Switches#check_switch_names, called first in #do_set and #do_action, which raises where respond_to?(accessor) is true, #method_missing firing only where no method exists.
|
|
8
14
|
2. + lib/Switches.rb: SwitchNameCollision < ArgumentError.
|
|
9
15
|
3. ~ README.md: + a Notes entry for the refusal, and for the booleans and OptionParser names it does not cover.
|
|
10
16
|
4. + spec/all.rb: the refusal through #set and #perform, the message, that nothing reaches the parser first, and the two legal cases.
|
|
17
|
+
5. + ROADMAP.md, and - the # Todo: and # Ideas: sections from the lib/Switches.rb header, which is where they were. Not listed in the gemspec, so it does not ship.
|
|
11
18
|
|
|
12
19
|
0.11.0: Forward to OptionParser, which #method_missing has never actually done.
|
|
13
20
|
|
|
14
|
-
1. ~ lib/Switches.rb: #method_missing
|
|
15
|
-
2. ~ lib/Switches.rb:
|
|
16
|
-
3.
|
|
17
|
-
4. ~ lib/Switches.rb: + Switches#option_parser_methods, memoised,
|
|
18
|
-
5. + spec/all.rb: forwarding
|
|
19
|
-
6. ~ README.md: the Notes entry
|
|
20
|
-
|
|
21
|
-
Not done: #respond_to_missing?, which ordinarily accompanies #method_missing. Note that it would not have prevented the to_a case above — Ruby's conversion check falls back to calling #method_missing directly when the ordinary dispatch fails, so Array() reaches #to_a whatever respond_to? answers. It wants deciding alongside the collision question below, both being about which names the object should own.
|
|
22
|
-
|
|
23
|
-
Still outstanding: the converse fault, where #method_missing does not fire at all because the method exists. A switch named after a method Object already has — :tap, :class, :display, :hash, :method, :type — never reaches the settings, and Kernel#tap without a block raises LocalJumpError nowhere near the declaration.
|
|
21
|
+
1. ~ lib/Switches.rb: #method_missing compared method_name.to_s against @op.methods, an array of Symbols, so the forwarding branch was never true; now compared in symbols.
|
|
22
|
+
2. ~ lib/Switches.rb: + Switches#declared_switch?, giving a declared switch precedence over the OptionParser method of the same name.
|
|
23
|
+
3. + lib/Switches.rb: Switches::NEVER_FORWARDED, the names Ruby may call implicitly, excluded from the forwarded set, OptionParser#to_a otherwise answering Array() with the help.
|
|
24
|
+
4. ~ lib/Switches.rb: + Switches#option_parser_methods, memoised, and + Switches#option_parser_method?.
|
|
25
|
+
5. + spec/all.rb: the forwarding, the precedence rule, the fall-through, and #to_a.
|
|
26
|
+
6. ~ README.md: the Notes entry describing forwarding, which had it backwards.
|
|
24
27
|
|
|
25
28
|
0.10.5: Specify and document that a multi-word switch may be supplied hyphenated, and name that form when it is missing.
|
|
26
29
|
|
|
27
|
-
1. + spec/all.rb: multi-word switches
|
|
28
|
-
2. ~ lib/Switches.rb: the missing-switch message names the hyphenated form, so a switch declared :access_token is reported as --access-token, in place of the --access_token built from the symbol verbatim.
|
|
30
|
+
1. + spec/all.rb: multi-word switches in both their underscored and their hyphenated form, for a boolean, an optional argument (#set), a required argument (#set!) and a required switch (#required); that either form counts as supplied; and that the setting is named for the symbol declared. The behaviour is OptionParser's, a long switch being filed under a lookup key with its underscores turned to hyphens.
|
|
31
|
+
2. ~ lib/Switches.rb: the missing-switch message names the hyphenated form, so a switch declared :access_token is reported as --access-token, in place of the --access_token built from the symbol verbatim.
|
|
29
32
|
3. ~ lib/Switches.rb: + Switches#switch_string, which builds the switch string for an attribute, in place of the identical construction #on_args and #check_required_switches each carried.
|
|
30
33
|
4. ~ README.md: + a multi-word switch to the Usage section, and + a note recording where the behaviour comes from, that the setting is named for the symbol declared, and that declaring the attribute hyphenated buys nothing and costs the accessor.
|
|
31
34
|
|
data/lib/Switches/VERSION.rb
CHANGED
data/lib/Switches.rb
CHANGED
|
@@ -3,15 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
# Description: Switches provides for a nice wrapper to OptionParser to also act as a store for switches supplied.
|
|
5
5
|
|
|
6
|
-
# Todo:
|
|
7
|
-
# 1. Clean up #set. Done as of 0.4.0.
|
|
8
|
-
# 2. Reinstitute some specs. Done as of 0.9.8.
|
|
9
|
-
|
|
10
|
-
# Ideas:
|
|
11
|
-
# 1. Use ! for options with required switches? Done as of 0.6.0. (Changed to being for required arguments in 0.9.0 however.)
|
|
12
|
-
# 2. Do away with optional arguments entirely. Since when does anyone want to specify a non-boolean switch and then supply no arguments anyway?... OK, maybe sometimes, but this is pretty obscure IMO. OK, bad idea. These can be used as action oriented sub-commands.
|
|
13
|
-
# 3. Allow for any one of the switches OpenStruct methods to assign values for any of the other associated methods, so as it is more than a read once switch and can be used for storage through out the application; although this might be stepping on Attributes.rb's toes?...
|
|
14
|
-
|
|
15
6
|
# Dependencies:
|
|
16
7
|
# 1. Standard Ruby Library.
|
|
17
8
|
# 2. ostruct, which ceased to be a default gem as of Ruby 4.0 and so is declared in the gemspec.
|