tins 1.45.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 945ad77f98b8cdd413748f454fe3d45b37e7a0ac8a8057aef37bc500d2b6dead
4
- data.tar.gz: 4f5107a685e92ae9093957d33826d8f5700310841918a51120cf642a7ee09697
3
+ metadata.gz: 37dea3f4959ecf698b1908647ef0a7e1c19abe61aa669bbc63aa65fde10714e4
4
+ data.tar.gz: 78d9256391b2a6dd105be5bc8e0b37aef0508516ddc2cbc578e4766a4f02a50c
5
5
  SHA512:
6
- metadata.gz: 14bd945dda0a72f85969e0bba304cd76ae7298c7b90da2b7aa6b3fd7b671b72eb9482951b1a6051ce65db4a97b7a8225ac889d5359e48f2b675be53fc48aa275
7
- data.tar.gz: d814dd29b1ee840d4f30fe1ac1d5303105dcf65ed78a7b8c92e24092a5dcd9f13218573580acae63f05f011fb066e90d9116d7c7a8282106c4c4b64dce4e6c05
6
+ metadata.gz: 04d75c6e6264659e08574a21bf0a2899702a7765ca90e32baec72056b6a95a639b35aeef7c0ad0d81a35287b3b076b9185f029be9115ae1d0b009236a3a4ca2a
7
+ data.tar.gz: df69723660df31a08011a5209d460d55a6422cc1999067e2739365866ce30f4f2135a81484d722ae9ac9d83a0ed1c9cdbfe53d1f76ee6060457ad292717cd126
data/CHANGES.md CHANGED
@@ -1,5 +1,31 @@
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
+
17
+ ## 2025-11-10 v1.46.0
18
+
19
+ - Updated `s.rubygems_version` from **3.6.9** to **3.7.2** in gemspec
20
+ - In Tins::GO
21
+ - Extended string defaults with `EnumerableExtension` transformation
22
+ - Modified `v.transform_values!` to check and extend strings that aren't already `EnumerableExtension`
23
+ - Applied `w << w` to properly initialize the extension on default strings
24
+ - Updated tests to verify `EnumerableExtension` instances for both `v` and `w` options
25
+ - Set default value for `?w` option to **'baz'** in test cases
26
+ - Maintained backward compatibility while normalizing string handling
27
+ - Ensured consistent behavior between ARGV strings and default strings
28
+
3
29
  ## 2025-10-16 v1.45.0
4
30
 
5
31
  - Added `patch` alias for `build` and `build=` methods to align with SemVer terminology
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 EnumerableExtension collection with all
15
+ # # options['f'] will contain an ArrayExtension collection with all
16
16
  # values, see `option['f'].to_a`
17
17
  module GO
18
- # An extension module that provides Enumerable behavior for collecting
19
- # multiple values associated with the same command-line option.
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
- # Alias for {#push}
38
- #
39
- # Enables intuitive syntax for adding elements: `collection << item`
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 EnumerableExtension collection with
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? || !(EnumerableExtension === v[o])
126
+ if v[o].nil? || !(ArrayExtension === v[o])
149
127
  a = a.dup
150
- a.extend EnumerableExtension
151
- a << a
128
+ a.extend ArrayExtension
129
+ a.push a
152
130
  v[o] = a
153
131
  else
154
- v[o] << a
132
+ v[o].push a
155
133
  end
156
134
  break
157
135
  elsif b.key?(o)
@@ -166,6 +144,15 @@ module Tins
166
144
  end && break
167
145
  end
168
146
  r.reject! { |a| (b[p] = false) || true if /\A~(?<p>.)/ =~ a }
147
+ v.transform_values! do |w|
148
+ if w.is_a?(String) && !w.is_a?(ArrayExtension)
149
+ w = w.dup
150
+ w.extend ArrayExtension
151
+ w.push w
152
+ else
153
+ w
154
+ end
155
+ end
169
156
  args.replace r
170
157
  b.merge(v)
171
158
  end
data/lib/tins/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Tins
2
2
  # Tins version
3
- VERSION = '1.45.0'
3
+ VERSION = '1.47.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
data/tests/go_test.rb CHANGED
@@ -59,8 +59,10 @@ module Tins
59
59
  end
60
60
 
61
61
  def test_defaults
62
- r = go('bv:', args = %w[ -v bar ], defaults: { ?b => true, ?v => 'foo' })
63
- assert_equal({ ?b => 1, 'v' => 'bar' }, r)
62
+ r = go('bv:w:', args = %w[ -v bar ], defaults: { ?b => true, ?v => 'foo', ?w => 'baz' })
63
+ assert_equal({ ?b => 1, 'v' => 'bar', 'w' => 'baz' }, r)
64
+ assert_kind_of(Tins::GO::ArrayExtension, r[?v])
65
+ assert_kind_of(Tins::GO::ArrayExtension, r[?w])
64
66
  assert_equal [], args
65
67
  r = go('bv:', args = %w[ -v bar ~b baz ], defaults: { ?b => true, ?v => 'foo' })
66
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.45.0 ruby lib
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.45.0".freeze
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]
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.licenses = ["MIT".freeze]
18
18
  s.rdoc_options = ["--title".freeze, "Tins - Useful stuff.".freeze, "--main".freeze, "README.md".freeze]
19
19
  s.required_ruby_version = Gem::Requirement.new(">= 3.1".freeze)
20
- s.rubygems_version = "3.6.9".freeze
20
+ s.rubygems_version = "3.7.2".freeze
21
21
  s.summary = "Useful stuff.".freeze
22
22
  s.test_files = ["tests/annotate_test.rb".freeze, "tests/ask_and_send_test.rb".freeze, "tests/attempt_test.rb".freeze, "tests/bijection_test.rb".freeze, "tests/blank_full_test.rb".freeze, "tests/case_predicate_test.rb".freeze, "tests/concern_test.rb".freeze, "tests/date_dummy_test.rb".freeze, "tests/date_time_dummy_test.rb".freeze, "tests/deep_dup_test.rb".freeze, "tests/delegate_test.rb".freeze, "tests/deprecate_test.rb".freeze, "tests/dslkit_test.rb".freeze, "tests/duration_test.rb".freeze, "tests/dynamic_scope_test.rb".freeze, "tests/expose_test.rb".freeze, "tests/extract_last_argument_options_test.rb".freeze, "tests/file_binary_test.rb".freeze, "tests/find_test.rb".freeze, "tests/from_module_test.rb".freeze, "tests/generator_test.rb".freeze, "tests/go_test.rb".freeze, "tests/hash_bfs_test.rb".freeze, "tests/hash_symbolize_keys_recursive_test.rb".freeze, "tests/hash_union_test.rb".freeze, "tests/if_predicate_test.rb".freeze, "tests/implement_test.rb".freeze, "tests/limited_test.rb".freeze, "tests/lines_file_test.rb".freeze, "tests/lru_cache_test.rb".freeze, "tests/memoize_test.rb".freeze, "tests/method_description_test.rb".freeze, "tests/minimize_test.rb".freeze, "tests/module_group_test.rb".freeze, "tests/named_set_test.rb".freeze, "tests/named_test.rb".freeze, "tests/null_test.rb".freeze, "tests/p_test.rb".freeze, "tests/partial_application_test.rb".freeze, "tests/proc_compose_test.rb".freeze, "tests/proc_prelude_test.rb".freeze, "tests/range_plus_test.rb".freeze, "tests/require_maybe_test.rb".freeze, "tests/responding_test.rb".freeze, "tests/rotate_test.rb".freeze, "tests/scope_test.rb".freeze, "tests/secure_write_test.rb".freeze, "tests/sexy_singleton_test.rb".freeze, "tests/string_byte_order_mark_test.rb".freeze, "tests/string_camelize_test.rb".freeze, "tests/string_named_placeholders.rb".freeze, "tests/string_underscore_test.rb".freeze, "tests/string_version_test.rb".freeze, "tests/subhash_test.rb".freeze, "tests/temp_io_test.rb".freeze, "tests/test_helper.rb".freeze, "tests/time_dummy_test.rb".freeze, "tests/time_freezer_test.rb".freeze, "tests/to_test.rb".freeze, "tests/token_test.rb".freeze, "tests/unit_test.rb".freeze, "tests/annotate_test.rb".freeze, "tests/ask_and_send_test.rb".freeze, "tests/attempt_test.rb".freeze, "tests/bijection_test.rb".freeze, "tests/blank_full_test.rb".freeze, "tests/case_predicate_test.rb".freeze, "tests/concern_test.rb".freeze, "tests/date_dummy_test.rb".freeze, "tests/date_time_dummy_test.rb".freeze, "tests/deep_dup_test.rb".freeze, "tests/delegate_test.rb".freeze, "tests/deprecate_test.rb".freeze, "tests/dslkit_test.rb".freeze, "tests/duration_test.rb".freeze, "tests/dynamic_scope_test.rb".freeze, "tests/expose_test.rb".freeze, "tests/extract_last_argument_options_test.rb".freeze, "tests/file_binary_test.rb".freeze, "tests/find_test.rb".freeze, "tests/from_module_test.rb".freeze, "tests/generator_test.rb".freeze, "tests/go_test.rb".freeze, "tests/hash_bfs_test.rb".freeze, "tests/hash_symbolize_keys_recursive_test.rb".freeze, "tests/hash_union_test.rb".freeze, "tests/if_predicate_test.rb".freeze, "tests/implement_test.rb".freeze, "tests/limited_test.rb".freeze, "tests/lines_file_test.rb".freeze, "tests/lru_cache_test.rb".freeze, "tests/memoize_test.rb".freeze, "tests/method_description_test.rb".freeze, "tests/minimize_test.rb".freeze, "tests/module_group_test.rb".freeze, "tests/named_set_test.rb".freeze, "tests/named_test.rb".freeze, "tests/null_test.rb".freeze, "tests/p_test.rb".freeze, "tests/partial_application_test.rb".freeze, "tests/proc_compose_test.rb".freeze, "tests/proc_prelude_test.rb".freeze, "tests/range_plus_test.rb".freeze, "tests/require_maybe_test.rb".freeze, "tests/responding_test.rb".freeze, "tests/rotate_test.rb".freeze, "tests/scope_test.rb".freeze, "tests/secure_write_test.rb".freeze, "tests/sexy_singleton_test.rb".freeze, "tests/string_byte_order_mark_test.rb".freeze, "tests/string_camelize_test.rb".freeze, "tests/string_underscore_test.rb".freeze, "tests/string_version_test.rb".freeze, "tests/subhash_test.rb".freeze, "tests/temp_io_test.rb".freeze, "tests/time_dummy_test.rb".freeze, "tests/time_freezer_test.rb".freeze, "tests/to_test.rb".freeze, "tests/token_test.rb".freeze, "tests/unit_test.rb".freeze]
23
23
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tins
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.45.0
4
+ version: 1.47.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
@@ -484,7 +484,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
484
484
  - !ruby/object:Gem::Version
485
485
  version: '0'
486
486
  requirements: []
487
- rubygems_version: 3.6.9
487
+ rubygems_version: 3.7.2
488
488
  specification_version: 4
489
489
  summary: Useful stuff.
490
490
  test_files: