tins 1.46.0 → 1.47.0
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/CHANGES.md +14 -0
- data/lib/tins/go.rb +16 -38
- data/lib/tins/version.rb +1 -1
- data/tests/go_test.rb +2 -2
- data/tins.gemspec +2 -2
- 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: 37dea3f4959ecf698b1908647ef0a7e1c19abe61aa669bbc63aa65fde10714e4
|
|
4
|
+
data.tar.gz: 78d9256391b2a6dd105be5bc8e0b37aef0508516ddc2cbc578e4766a4f02a50c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 04d75c6e6264659e08574a21bf0a2899702a7765ca90e32baec72056b6a95a639b35aeef7c0ad0d81a35287b3b076b9185f029be9115ae1d0b009236a3a4ca2a
|
|
7
|
+
data.tar.gz: df69723660df31a08011a5209d460d55a6422cc1999067e2739365866ce30f4f2135a81484d722ae9ac9d83a0ed1c9cdbfe53d1f76ee6060457ad292717cd126
|
data/CHANGES.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2025-11-14 v1.47.0
|
|
4
|
+
|
|
5
|
+
- Tins::GO
|
|
6
|
+
- Renamed `EnumerableExtension` module to `ArrayExtension` throughout the
|
|
7
|
+
codebase
|
|
8
|
+
- Updated method calls from `<<` to `push` for consistency with
|
|
9
|
+
`ArrayExtension`
|
|
10
|
+
- Modified `to_a` method implementation to return `@arguments` directly
|
|
11
|
+
- Updated test assertions to expect `ArrayExtension` instead of
|
|
12
|
+
`EnumerableExtension`
|
|
13
|
+
- Changed documentation comments to reflect the new `ArrayExtension` name
|
|
14
|
+
- Updated type checking from `EnumerableExtension` to `ArrayExtension` in
|
|
15
|
+
conditional logic
|
|
16
|
+
|
|
3
17
|
## 2025-11-10 v1.46.0
|
|
4
18
|
|
|
5
19
|
- Updated `s.rubygems_version` from **3.6.9** to **3.7.2** in gemspec
|
data/lib/tins/go.rb
CHANGED
|
@@ -12,15 +12,12 @@ module Tins
|
|
|
12
12
|
# @example Multiple values for same option
|
|
13
13
|
# # Handle: -f foo -f bar -f baz
|
|
14
14
|
# options = Tins::GO.go('f:', ARGV)
|
|
15
|
-
# # options['f'] will contain an
|
|
15
|
+
# # options['f'] will contain an ArrayExtension collection with all
|
|
16
16
|
# values, see `option['f'].to_a`
|
|
17
17
|
module GO
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
# This extension enables command-line flags like `-f foo -f bar` to be
|
|
22
|
-
# collected into a single collection that can be queried via #to_a or #each.
|
|
23
|
-
module EnumerableExtension
|
|
18
|
+
# A module that provides extension methods for Strings let them double as
|
|
19
|
+
# arrays.
|
|
20
|
+
module ArrayExtension
|
|
24
21
|
# Adds an element to the collection.
|
|
25
22
|
#
|
|
26
23
|
# This method allows for chaining operations and collects multiple
|
|
@@ -34,30 +31,11 @@ module Tins
|
|
|
34
31
|
self
|
|
35
32
|
end
|
|
36
33
|
|
|
37
|
-
#
|
|
38
|
-
#
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
# @see #push
|
|
42
|
-
alias << push
|
|
43
|
-
|
|
44
|
-
# Iterates over each element in the collection.
|
|
45
|
-
#
|
|
46
|
-
# Implements the Enumerable interface, allowing the use of all Enumerable
|
|
47
|
-
# methods like map, select, find, etc.
|
|
48
|
-
#
|
|
49
|
-
# @yield [element] Yields each element in the collection
|
|
50
|
-
# @yieldparam element [Object] Each element in the collection
|
|
51
|
-
# @return [self] Returns self to enable method chaining
|
|
52
|
-
def each(&block)
|
|
53
|
-
@arguments.each(&block)
|
|
54
|
-
self
|
|
34
|
+
# The to_a method converts the object to an array.
|
|
35
|
+
# @return [Array] a new array containing the object's elements
|
|
36
|
+
def to_a
|
|
37
|
+
@arguments
|
|
55
38
|
end
|
|
56
|
-
|
|
57
|
-
# Includes the Enumerable module to provide rich iteration capabilities.
|
|
58
|
-
#
|
|
59
|
-
# This enables the use of methods like map, select, find, etc.
|
|
60
|
-
include Enumerable
|
|
61
39
|
end
|
|
62
40
|
|
|
63
41
|
module_function
|
|
@@ -89,7 +67,7 @@ module Tins
|
|
|
89
67
|
# @example Multiple values for same option
|
|
90
68
|
# # Handle: -f foo -f bar -f baz
|
|
91
69
|
# options = Tins::GO.go('f:', ARGV)
|
|
92
|
-
# # options['f'] will contain an
|
|
70
|
+
# # options['f'] will contain an ArrayExtension collection with
|
|
93
71
|
# # all values, see options['f'].to_a
|
|
94
72
|
#
|
|
95
73
|
# @example Boolean flag counting
|
|
@@ -145,13 +123,13 @@ module Tins
|
|
|
145
123
|
else
|
|
146
124
|
a = p
|
|
147
125
|
end
|
|
148
|
-
if v[o].nil? || !(
|
|
126
|
+
if v[o].nil? || !(ArrayExtension === v[o])
|
|
149
127
|
a = a.dup
|
|
150
|
-
a.extend
|
|
151
|
-
a
|
|
128
|
+
a.extend ArrayExtension
|
|
129
|
+
a.push a
|
|
152
130
|
v[o] = a
|
|
153
131
|
else
|
|
154
|
-
v[o]
|
|
132
|
+
v[o].push a
|
|
155
133
|
end
|
|
156
134
|
break
|
|
157
135
|
elsif b.key?(o)
|
|
@@ -167,10 +145,10 @@ module Tins
|
|
|
167
145
|
end
|
|
168
146
|
r.reject! { |a| (b[p] = false) || true if /\A~(?<p>.)/ =~ a }
|
|
169
147
|
v.transform_values! do |w|
|
|
170
|
-
if w.is_a?(String) && !w.is_a?(
|
|
148
|
+
if w.is_a?(String) && !w.is_a?(ArrayExtension)
|
|
171
149
|
w = w.dup
|
|
172
|
-
w.extend
|
|
173
|
-
w
|
|
150
|
+
w.extend ArrayExtension
|
|
151
|
+
w.push w
|
|
174
152
|
else
|
|
175
153
|
w
|
|
176
154
|
end
|
data/lib/tins/version.rb
CHANGED
data/tests/go_test.rb
CHANGED
|
@@ -61,8 +61,8 @@ module Tins
|
|
|
61
61
|
def test_defaults
|
|
62
62
|
r = go('bv:w:', args = %w[ -v bar ], defaults: { ?b => true, ?v => 'foo', ?w => 'baz' })
|
|
63
63
|
assert_equal({ ?b => 1, 'v' => 'bar', 'w' => 'baz' }, r)
|
|
64
|
-
assert_kind_of(Tins::GO::
|
|
65
|
-
assert_kind_of(Tins::GO::
|
|
64
|
+
assert_kind_of(Tins::GO::ArrayExtension, r[?v])
|
|
65
|
+
assert_kind_of(Tins::GO::ArrayExtension, r[?w])
|
|
66
66
|
assert_equal [], args
|
|
67
67
|
r = go('bv:', args = %w[ -v bar ~b baz ], defaults: { ?b => true, ?v => 'foo' })
|
|
68
68
|
assert_equal({ ?b => false, 'v' => 'bar' }, r)
|
data/tins.gemspec
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
# stub: tins 1.
|
|
2
|
+
# stub: tins 1.47.0 ruby lib
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
5
|
s.name = "tins".freeze
|
|
6
|
-
s.version = "1.
|
|
6
|
+
s.version = "1.47.0".freeze
|
|
7
7
|
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
|
9
9
|
s.require_paths = ["lib".freeze]
|