tins 1.31.1 → 1.54.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.
Files changed (152) hide show
  1. checksums.yaml +4 -4
  2. data/.envrc +1 -0
  3. data/CHANGES.md +356 -0
  4. data/Gemfile +0 -5
  5. data/README.md +161 -90
  6. data/Rakefile +34 -17
  7. data/examples/let.rb +8 -40
  8. data/examples/mail.rb +2 -1
  9. data/examples/null_pattern.rb +2 -0
  10. data/examples/ones_difference.stm +0 -1
  11. data/examples/turing.rb +5 -1
  12. data/lib/tins/alias.rb +1 -0
  13. data/lib/tins/annotate.rb +37 -27
  14. data/lib/tins/ask_and_send.rb +41 -0
  15. data/lib/tins/attempt.rb +43 -2
  16. data/lib/tins/bijection.rb +34 -0
  17. data/lib/tins/case_predicate.rb +21 -0
  18. data/lib/tins/complete.rb +16 -0
  19. data/lib/tins/concern.rb +100 -0
  20. data/lib/tins/date_dummy.rb +36 -4
  21. data/lib/tins/date_time_dummy.rb +34 -2
  22. data/lib/tins/deep_dup.rb +9 -2
  23. data/lib/tins/deprecate.rb +27 -0
  24. data/lib/tins/dslkit.rb +628 -59
  25. data/lib/tins/duration.rb +160 -3
  26. data/lib/tins/expose.rb +54 -5
  27. data/lib/tins/extract_last_argument_options.rb +9 -0
  28. data/lib/tins/file_binary.rb +108 -25
  29. data/lib/tins/find.rb +114 -11
  30. data/lib/tins/generator.rb +10 -2
  31. data/lib/tins/go.rb +106 -18
  32. data/lib/tins/hash_bfs.rb +66 -0
  33. data/lib/tins/hash_dfs.rb +81 -0
  34. data/lib/tins/hash_symbolize_keys_recursive.rb +97 -8
  35. data/lib/tins/hash_union.rb +47 -2
  36. data/lib/tins/if_predicate.rb +31 -0
  37. data/lib/tins/implement.rb +50 -0
  38. data/lib/tins/limited.rb +105 -29
  39. data/lib/tins/lines_file.rb +81 -2
  40. data/lib/tins/lru_cache.rb +53 -24
  41. data/lib/tins/memoize.rb +86 -58
  42. data/lib/tins/method_description.rb +87 -4
  43. data/lib/tins/minimize.rb +39 -11
  44. data/lib/tins/module_group.rb +27 -2
  45. data/lib/tins/named_set.rb +20 -0
  46. data/lib/tins/null.rb +86 -15
  47. data/lib/tins/once.rb +61 -4
  48. data/lib/tins/p.rb +44 -8
  49. data/lib/tins/partial_application.rb +66 -7
  50. data/lib/tins/proc_compose.rb +58 -1
  51. data/lib/tins/proc_prelude.rb +97 -10
  52. data/lib/tins/range_plus.rb +30 -2
  53. data/lib/tins/require_maybe.rb +36 -0
  54. data/lib/tins/responding.rb +39 -0
  55. data/lib/tins/secure_write.rb +25 -5
  56. data/lib/tins/sexy_singleton.rb +46 -48
  57. data/lib/tins/string_byte_order_mark.rb +33 -2
  58. data/lib/tins/string_camelize.rb +31 -2
  59. data/lib/tins/string_named_placeholders.rb +70 -0
  60. data/lib/tins/string_underscore.rb +33 -2
  61. data/lib/tins/string_version.rb +198 -12
  62. data/lib/tins/subhash.rb +35 -10
  63. data/lib/tins/temp_io.rb +7 -0
  64. data/lib/tins/temp_io_enum.rb +19 -0
  65. data/lib/tins/terminal.rb +34 -12
  66. data/lib/tins/thread_local.rb +69 -11
  67. data/lib/tins/time_dummy.rb +47 -21
  68. data/lib/tins/to.rb +15 -0
  69. data/lib/tins/to_proc.rb +17 -4
  70. data/lib/tins/token.rb +87 -5
  71. data/lib/tins/unit.rb +304 -149
  72. data/lib/tins/version.rb +1 -1
  73. data/lib/tins/write.rb +14 -3
  74. data/lib/tins/xt/blank.rb +81 -2
  75. data/lib/tins/xt/concern.rb +51 -0
  76. data/lib/tins/xt/deep_dup.rb +4 -2
  77. data/lib/tins/xt/deprecate.rb +5 -0
  78. data/lib/tins/xt/full.rb +56 -11
  79. data/lib/tins/xt/hash_bfs.rb +7 -0
  80. data/lib/tins/xt/hash_dfs.rb +7 -0
  81. data/lib/tins/xt/irb.rb +46 -2
  82. data/lib/tins/xt/method_description.rb +0 -12
  83. data/lib/tins/xt/minimize.rb +7 -0
  84. data/lib/tins/xt/named.rb +71 -16
  85. data/lib/tins/xt/proc_compose.rb +4 -0
  86. data/lib/tins/xt/secure_write.rb +0 -4
  87. data/lib/tins/xt/string.rb +1 -0
  88. data/lib/tins/xt/string_camelize.rb +4 -2
  89. data/lib/tins/xt/string_named_placeholders.rb +7 -0
  90. data/lib/tins/xt/string_underscore.rb +4 -2
  91. data/lib/tins/xt/subhash.rb +11 -0
  92. data/lib/tins/xt/time_freezer.rb +43 -6
  93. data/lib/tins/xt/write.rb +0 -4
  94. data/lib/tins/xt.rb +4 -3
  95. data/lib/tins.rb +20 -3
  96. data/tests/annotate_test.rb +0 -1
  97. data/tests/attempt_test.rb +12 -0
  98. data/tests/bijection_test.rb +0 -1
  99. data/tests/concern_test.rb +63 -4
  100. data/tests/date_dummy_test.rb +0 -1
  101. data/tests/date_time_dummy_test.rb +0 -1
  102. data/tests/delegate_test.rb +0 -1
  103. data/tests/deprecate_test.rb +41 -0
  104. data/tests/dslkit_test.rb +15 -1
  105. data/tests/duration_test.rb +23 -2
  106. data/tests/dynamic_scope_test.rb +0 -1
  107. data/tests/extract_last_argument_options_test.rb +0 -1
  108. data/tests/find_test.rb +0 -1
  109. data/tests/from_module_test.rb +30 -3
  110. data/tests/generator_test.rb +0 -1
  111. data/tests/go_test.rb +31 -3
  112. data/tests/hash_bfs_test.rb +34 -0
  113. data/tests/hash_dfs_test.rb +41 -0
  114. data/tests/hash_symbolize_keys_recursive_test.rb +57 -2
  115. data/tests/implement_test.rb +6 -9
  116. data/tests/limited_test.rb +12 -12
  117. data/tests/lines_file_test.rb +2 -1
  118. data/tests/lru_cache_test.rb +13 -1
  119. data/tests/memoize_test.rb +0 -1
  120. data/tests/method_description_test.rb +14 -20
  121. data/tests/minimize_test.rb +0 -1
  122. data/tests/module_group_test.rb +0 -1
  123. data/tests/named_set_test.rb +0 -1
  124. data/tests/null_test.rb +0 -1
  125. data/tests/partial_application_test.rb +4 -0
  126. data/tests/proc_prelude_test.rb +1 -1
  127. data/tests/require_maybe_test.rb +0 -1
  128. data/tests/scope_test.rb +1 -2
  129. data/tests/secure_write_test.rb +6 -1
  130. data/tests/sexy_singleton_test.rb +1 -1
  131. data/tests/string_named_placeholders.rb +109 -0
  132. data/tests/string_version_test.rb +16 -1
  133. data/tests/subhash_test.rb +0 -1
  134. data/tests/test_helper.rb +6 -6
  135. data/tests/time_dummy_test.rb +0 -1
  136. data/tests/time_freezer_test.rb +1 -1
  137. data/tests/to_test.rb +6 -6
  138. data/tests/token_test.rb +32 -2
  139. data/tests/unit_test.rb +18 -1
  140. data/tins.gemspec +19 -24
  141. metadata +113 -38
  142. data/lib/tins/count_by.rb +0 -8
  143. data/lib/tins/deep_const_get.rb +0 -42
  144. data/lib/tins/timed_cache.rb +0 -51
  145. data/lib/tins/uniq_by.rb +0 -10
  146. data/lib/tins/xt/count_by.rb +0 -11
  147. data/lib/tins/xt/deep_const_get.rb +0 -7
  148. data/lib/tins/xt/uniq_by.rb +0 -15
  149. data/tests/count_by_test.rb +0 -17
  150. data/tests/deep_const_get_test.rb +0 -37
  151. data/tests/uniq_by_test.rb +0 -31
  152. /data/{COPYING → LICENSE} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87ad7ef2a6b416068c43c548857ff7203db0323d327c57be10ec232ffe1d6d13
4
- data.tar.gz: e46267f97d4038323fe8805275213c8b825c6fbb2eec960788e6be7c172225ab
3
+ metadata.gz: 37a35478fdfa15cbd0c8bd8f554dca3138dd89b143145e30912b22ca805405a2
4
+ data.tar.gz: 629fd36c8ea8590ff71f930e864438d8788581cbf5f48cade5377640ae38a536
5
5
  SHA512:
6
- metadata.gz: 231237d41d049ba37ddc7be43df179988c8f5258034697576947c40536c63bb448f87be2616b4b9eb0bf20ce8173e2be4220a127c33cec8f559e7c1da9326ca8
7
- data.tar.gz: 04a6bd95875ac9f23ca0f1391595b062089cc3d085e895d4d1e3623db4507acf0252bc947ad632b814dc75cad6eae486d3ea5fae5699648c99854e8c054b6664
6
+ metadata.gz: 306182988f76014b783473801e192666ab080fc2e1ff1c11b9fcd61e3e3bde4b86904199581f42f77a28544524ee17e7d2bb4a08bfeb6babaeb5c403114b70df
7
+ data.tar.gz: b70e5675a5f202c2aa0ac71f10605c03a377d7a4abefbc6052462ce9996b575cccab525e785fa499133d8d1fb30cbfc0d9864b1628ee3c58ea7739d4325f02e2
data/.envrc ADDED
@@ -0,0 +1 @@
1
+ export OLLAMA_CHAT_TOOLS_TEST_RUNNER="bundle exec test-unit"
data/CHANGES.md ADDED
@@ -0,0 +1,356 @@
1
+ # Changes
2
+
3
+ ## 2026-05-20 v1.54.0
4
+
5
+ ### Changed
6
+
7
+ - **Tins::GO.go**
8
+ - Improved handling of missing arguments: the system now issues a warning
9
+ when an option requiring an argument is missing its value and prevents
10
+ subsequent flags from being consumed as arguments.
11
+ - Added protection against overlapping flag definitions; flags defined as
12
+ both boolean and value-requiring are now disabled, and a warning is issued.
13
+ - Expanded documentation for the `go` method to include pattern syntax,
14
+ ambiguity handling, side effects, and the in-place modification of the
15
+ `_args_` array.
16
+
17
+ - **Dependencies & Configuration**
18
+ - Updated `gem_hadar` dependency from **2.17.0** to **2.17.1**.
19
+ - Added `.envrc` to `s.files` in `tins.gemspec`.
20
+ - Configured the test runner for `ollama-chat` by setting the
21
+ `OLLAMA_CHAT_TOOLS_TEST_RUNNER` environment variable to `bundle exec
22
+ test-unit` via `.envrc`.
23
+
24
+ ## 2026-04-14 v1.53.0
25
+
26
+ - Added `stringify_keys_recursive` and `stringify_keys_recursive!` methods to convert hash keys from symbols to strings
27
+ - Renamed `_symbolize_keys_recursive` to `_transform_keys_recursive` to
28
+ support both `:to_sym` and `:to_s` transformations
29
+ - Updated `symbolize_keys_recursive` to use the new
30
+ `_transform_keys_recursive` with `transform: :to_sym`
31
+ - Added comprehensive tests for the new `stringify_keys_recursive` methods
32
+ including circular reference handling
33
+ - Updated YARD documentation for all new and modified methods
34
+ - Made `Token#bits` immutable from outside by changing `attr_accessor
35
+ :bits` to `attr_reader :bits` and using direct instance variable
36
+ assignment
37
+ - Bump `s.rubygems_version` from **4.0.3** to **4.0.10** in `tins.gemspec`
38
+
39
+ ## 2026-02-23 v1.52.0
40
+
41
+ - Renamed `BASE32_EXTENDED_HEX_ALPHABET` to
42
+ `BASE32_EXTENDED_UPPERCASE_HEX_ALPHABET` for clarity.
43
+ - Added new constant `BASE32_EXTENDED_LOWERCASE_HEX_ALPHABET` for lowercase hex
44
+ alphabet.
45
+ - Updated `BASE32_EXTENDED_HEX_ALPHABET` to reference the uppercase variant as
46
+ default.
47
+ - Updated comment for `BASE32_ALPHABET` to specify RFC 4648 compliance.
48
+ - Improved maintainability by clearly separating uppercase and lowercase hex
49
+ alphabet variants.
50
+ - Added `require 'tins/hash_dfs'` to `lib/tins.rb` and `lib/tins/xt.rb`.
51
+ - Renamed thread‑local flag in `HashBFS` from `:seen` to `:bfs_seen` and
52
+ updated all references.
53
+ - Replaced calls to `convert_to_hash_or_ary` with `bfs_convert_to_hash_or_ary`
54
+ in `HashBFS`.
55
+ - Added `bfs_convert_to_hash_or_ary` method to `HashBFS`.
56
+ - Added new module `Tins::HashDFS` with DFS traversal, thread‑local `dfs_seen`,
57
+ and `dfs_convert_to_hash_or_ary`.
58
+ - Added `lib/tins/xt/hash_dfs.rb` to mix `HashDFS` into `::Hash`.
59
+ - Added `tests/hash_dfs_test.rb` with DFS tests mirroring BFS tests.
60
+ - Updated YARD documentation for `HashBFS#bfs` with an example.
61
+ - Optimized token analysis bit calculation by avoiding large exponent
62
+ calculations and enhancing numerical stability for large token lengths.
63
+ - Maintained mathematical equivalence with **Ruby 2.0+** `Math.log2` method.
64
+ - Used more direct computation of bits needed for token entropy calculation.
65
+
66
+ ## 2026-01-14 v1.51.1
67
+
68
+ - Simplified `lru_cache` implementation to not need `NOT_EXIST`
69
+ - Updated `rubygems_version` from **4.0.2** to **4.0.3**
70
+ - Changed `gem_hadar` development dependency from "~> 2.10" to ">= 2.16.3"
71
+ - Updated Ruby image version from 4.0-rc-alpine to 4.0-alpine in CI pipeline
72
+ - Added comprehensive module documentation for `DSLKit` explaining its purpose
73
+ and features
74
+ - Added `CHANGES.md` file to gem release process using `GemHadar`
75
+
76
+ ## 2025-12-20 v1.51.0
77
+
78
+ - Added `readline` as a runtime dependency in both `Rakefile` and
79
+ `tins.gemspec`
80
+ - The `readline` dependency version is set to `>= 0` in `tins.gemspec`
81
+ - The `readline` dependency is added to the `GemHadar` block in `Rakefile`
82
+
83
+ ## 2025-12-19 v1.50.0
84
+
85
+ - Updated `gem_hadar` development dependency version to **2.10**
86
+ - Added `ruby:4.0-rc-alpine` image to the `images` section in `.all_images.yml`
87
+
88
+ ## 2025-12-18 v1.49.0
89
+
90
+ - Updated `bundle update` command to `bundle update --all` in `.all_images.yml`
91
+ to ensure all dependencies are updated recursively
92
+ - Added support for IEC binary prefixes with new `PREFIX_IEC_UC` constant and
93
+ updated `prefixes` method to handle `:iec_uc` and `:iec_uppercase`
94
+ identifiers
95
+ - Added corresponding test cases for IEC prefix mapping
96
+ - Added `:si_greek` alias for fractional prefixes (`m`, `µ`, `n`, etc.) in `PREFIX_F`
97
+ - Added `:si_uppercase` alias for SI uppercase prefixes (`K`, `M`, `G`, etc.) in `PREFIX_SI_UC`
98
+ - Updated `PREFIX_SI_UC` comment to clarify these are based on **1000**-step increments, not 1024
99
+ - Enhanced `prefixes` method to support new aliases while maintaining backward compatibility
100
+ - Added comprehensive tests for new aliases in `Tins::UnitTest`
101
+ - Updated `s.rubygems_version` from **3.7.2** to **4.0.2** in gemspec
102
+
103
+ ## 2025-12-05 v1.48.0
104
+
105
+ - Added `Tins::Token.analyze` class method to calculate bit strength
106
+ - Moved bit calculation logic from `initialize` to `analyze` method for reuse
107
+ - Implemented bit strength calculation using formula: `length ×
108
+ log₂(alphabet_size)`
109
+ - Added comprehensive tests for the `analyze` method with various alphabets
110
+ - Support both token string and length-based analysis
111
+ - Implemented proper error handling for required parameters
112
+ - Updated `initialize` method to use the new `analyze` method
113
+ - Test cases verify bit strength for **BASE16**, **BASE64**, and **BASE32**
114
+ alphabets
115
+ - Method returns integer bit strength for cryptographic token analysis
116
+
117
+ ## 2025-11-14 v1.47.0
118
+
119
+ - Tins::GO
120
+ - Renamed `EnumerableExtension` module to `ArrayExtension` throughout the
121
+ codebase
122
+ - Updated method calls from `<<` to `push` for consistency with
123
+ `ArrayExtension`
124
+ - Modified `to_a` method implementation to return `@arguments` directly
125
+ - Updated test assertions to expect `ArrayExtension` instead of
126
+ `EnumerableExtension`
127
+ - Changed documentation comments to reflect the new `ArrayExtension` name
128
+ - Updated type checking from `EnumerableExtension` to `ArrayExtension` in
129
+ conditional logic
130
+
131
+ ## 2025-11-10 v1.46.0
132
+
133
+ - Updated `s.rubygems_version` from **3.6.9** to **3.7.2** in gemspec
134
+ - In Tins::GO
135
+ - Extended string defaults with `EnumerableExtension` transformation
136
+ - Modified `v.transform_values!` to check and extend strings that aren't already `EnumerableExtension`
137
+ - Applied `w << w` to properly initialize the extension on default strings
138
+ - Updated tests to verify `EnumerableExtension` instances for both `v` and `w` options
139
+ - Set default value for `?w` option to **'baz'** in test cases
140
+ - Maintained backward compatibility while normalizing string handling
141
+ - Ensured consistent behavior between ARGV strings and default strings
142
+
143
+ ## 2025-10-16 v1.45.0
144
+
145
+ - Added `patch` alias for `build` and `build=` methods to align with SemVer terminology
146
+ - Updated `LEVELS` mapping to support `:patch` as alias for `:build` index
147
+ - Added `patch` and `patch=` aliases using the `alias` method
148
+ - Added tests for `patch` getter and setter functionality
149
+ - Updated `gem_hadar` development dependency from version **2.5** to **2.8**
150
+ - Added `openssl-dev` to Docker build dependencies
151
+ - Added `github_workflows` configuration to `Rakefile` for `static.yml` workflow
152
+ - Removed `.byebug_history` from `.gitignore` file
153
+ - Removed `.byebug_history` from ignore list in `Rakefile`
154
+ - Removed duplicate `mize` entry from code indexer configuration
155
+
156
+ ## 2025-09-13 v1.44.1
157
+
158
+ - Updated documentation link in README.md to point to GitHub.io instead of
159
+ RubyDoc.info
160
+ - Added graceful handling for missing `gem_hadar/simplecov` gem by wrapping
161
+ require and start in begin/rescue block to catch `LoadError`
162
+ - Modified gem packaging to include all files in `.github` and `.contexts` directories using `FileList` for dynamic inclusion
163
+ - Created `static.yml` file
164
+
165
+ ## 2025-09-12 v1.44.0
166
+
167
+ ### Major Changes
168
+
169
+ - **Ruby Version Requirement**: Updated minimum Ruby version requirement to 3.1
170
+ - **Dependency Modernization**: Replaced deprecated `Tins::Memoize` module
171
+ implementation with `mize` gem for memoization functionality
172
+ - **Documentation Overhaul**: Comprehensive YARD documentation added across all
173
+ modules with examples and parameter descriptions
174
+ - **README Enhancement**: Improved README.md with better documentation,
175
+ examples, and usage instructions
176
+
177
+ ## 2025-09-05 v1.43.0
178
+
179
+ - Added new `dsl_lazy_accessor` method that creates lazy-loaded accessors with
180
+ support for default blocks and dynamic block assignment
181
+ - Removed support for Ruby versions **3.1** and **3.0** from image definitions
182
+
183
+ ## 2025-08-19 v1.42.0
184
+
185
+ - Improved core class extension safety by using `respond_to?` checks to avoid
186
+ overriding existing methods such as `deep_dup`, `camelize`, and `underscore`
187
+ - Simplified GitHub directory ignore patterns in `Rakefile` by removing
188
+ recursive glob pattern for `.github` directory and directly specifying it as
189
+ a single entry
190
+ - Added documentation context files and YARD cheatsheet, including `.contexts/`
191
+ directory with code comment examples and updated `Rakefile` and
192
+ `tins.gemspec` to include context files and `context_spook` dependency
193
+
194
+ ## 2025-08-18 v1.41.0
195
+
196
+ - Added new `named_placeholders_interpolate` method for template substitution
197
+ - Method supports both static and dynamic default values via Proc
198
+ - Maintains backward compatibility with existing `named_placeholders_assign` method
199
+ - Includes comprehensive tests for all functionality and error handling
200
+ - Uses `named_placeholders_assign` internally for consistent implementation
201
+
202
+ ## 2025-08-18 v1.40.0
203
+
204
+ - Added `Tins::StringNamedPlaceholders` module with `named_placeholders` and
205
+ `named_placeholders_assign` methods for string template substitution
206
+ - Implemented support for both static and dynamic default values using Proc
207
+ objects
208
+ - Extended `String` class with `tins/xt/string` to include the new named
209
+ placeholders functionality
210
+ - Enhanced test coverage with comprehensive tests for all named placeholders
211
+ functionality including error handling and duplicate placeholder management
212
+ - Replaced manual SimpleCov setup with `GemHadar::SimpleCov.start` in test
213
+ helper
214
+
215
+ ## 2025-07-30 v1.39.1
216
+
217
+ - Updated `gem_hadar` development dependency to version **1.22**
218
+ - Bumped version from '1.39.0' to '1.39.1' in lib/tins/version.rb
219
+ - Updated `s.version` in tins.gemspec from "1.39.0" to "1.39.1"
220
+ - Updated stub version in tins.gemspec from **1.39.0** to **1.39.1**
221
+
222
+ ## 2025-07-30 v1.39.0
223
+
224
+ - Updated `VERSION` constant in `lib/tins/version.rb` from **1.38.0** to **1.39.0**
225
+ - Updated gem stub and version in `tins.gemspec`
226
+ - Updated `s.rubygems_version` from **3.6.2** to **3.6.9**
227
+ - Updated `s.add_development_dependency :gem_hadar` from ~> **1.19** to ~> **1.21**
228
+ - Added support for thread naming in `Limited` class
229
+ - Added `name` parameter to `Limited#initialize`
230
+ - Set `@name` attribute when provided
231
+ - Set executor name with `@name` if available
232
+ - Updated tests to use named threads
233
+ - Removed `binary` option from discover block in `.utilsrc`
234
+
235
+ ## 2025-01-04 v1.38.0
236
+
237
+ * Improved Tins::Limited concurrency handling:
238
+ * Added `execute` method for task submission with a block
239
+ * Changed `process` method to manage thread execution and queue management
240
+ * Introduced `stop` method to signal processing termination
241
+ * Modified test cases in `limited_test.rb` to accommodate new functionality
242
+ * Added `ensure` clause to decrement counter and signal continuation after
243
+ block execution
244
+ * Added support for Ruby **3.4** Alpine image:
245
+ * Updated `.all_images.yml` to include Ruby **3.4**-alpine environment
246
+ * Added `ruby:3.4-alpine` to the list of supported images
247
+ * Now uses **3.4** instead of **3.3**, **3.2**, and **3.1** for ruby versions
248
+
249
+ ## 2024-12-13 v1.37.1
250
+
251
+ * Renamed `ZERO` and `BINARY` constants to `ZERO_RE` and `BINARY_RE` to avoid
252
+ collisions with Logger/File constants.
253
+
254
+ ## 2024-10-19 v1.37.0
255
+
256
+ * Add support for module prepended blocks in **Tins::Concern**:
257
+ * Added `prepend_features` method to Tins concern
258
+ * Updated ConcernTest to test prepend feature
259
+ * Raise StandardError for duplicate block definitions for included and
260
+ prepended blocks
261
+ * Added `class_methods` method to Tins concern:
262
+ * Added `class_methods` method to lib/tins/concern.rb
263
+ - Creates or retrieves ClassMethods module for defining class-level methods
264
+ * Updated tests in `tests/concern_test.rb`
265
+ - Added test for new `baz1` and `baz2` methods
266
+ + Tested availability of `bar`, `baz1`, and `baz2` methods on A
267
+
268
+ ## 2024-10-11 v1.36.1
269
+
270
+ * Fixed a typo in the code
271
+
272
+ ## 2024-10-11 v1.36.0
273
+
274
+ ### Significant Changes
275
+
276
+ * Refactor bfs method in `hash_bfs.rb`:
277
+ + Rename `include_nodes` variable to `visit_internal`
278
+ + Update test cases in `hash_bfs_test.rb` to use new method signature
279
+ + Update method signature and docstring to reflect new behavior
280
+ * Update hash conversion logic:
281
+ + Rename method parameter from `v` to `object`
282
+ + Use `object` instead of `v` consistently throughout the method
283
+ + Add documentation for new method name and behavior
284
+
285
+ ## 2024-10-10 v1.35.0
286
+
287
+ ### New Features
288
+ * Implemented breadth-first search in hashes using the `Tins::HashBFS` module.
289
+ + Added tests for the `Tins::HashBFS` module.
290
+
291
+ ### Refactoring and Cleanup
292
+ * Reformatted code.
293
+ * Removed TODO note from the `TODO` file.
294
+ * Cleaned up test requirements:
295
+ - Added `require 'tins'` to `tests/test_helper.rb`.
296
+ - Removed unnecessary `require 'tins'` lines from test files.
297
+ * Refactored BASE16 constants and alphabet:
298
+ + Added `BASE16_LOWERCASE_ALPHABET` constant.
299
+ + Added `BASE16_UPPERCASE_ALPHABET` constant.
300
+
301
+ ### Tool Updates
302
+ * Updated bundler command to use full index:
303
+ - Added `--full-index` flag to `bundle install`.
304
+ - Replaced `bundle update` with `bundle install --full-index`.
305
+
306
+ ## 2024-09-30 v1.34.0
307
+
308
+ * **Secure write functionality updated**
309
+ + Added support for `Pathname` objects in `secure_write`
310
+ + Updated `File.new` call to use `to_s` method on filename
311
+ + New test case added for `secure_write` with `Pathname` object
312
+ * **Refactor version comparisons in various modules**
313
+ + Added `Tins::StringVersion.compare` method to compare Ruby versions with operators.
314
+ + Replaced direct version comparisons with `compare` method in multiple modules.
315
+ * **Deprecate deep_const_get and const_defined_in? methods**
316
+ + Add deprecation notice for `const_defined_in?` for ruby >= 1.8
317
+ + Add deprecation notice for `deep_const_get` method with a new method name `const_get` for ruby >= 2.0
318
+ * **Refactor deprecation logic and tests**
319
+ + Update `Tins::Deprecate#deprecate` method to allow for optional `new_method` parameter.
320
+ + Modify `tests/deprecate_test.rb` to test deprecated methods with and without messages.
321
+ * **Prepare count_by method for deprecation**
322
+ + Suggest using `count` with block instead in newer Rubies
323
+ * **Prepare uniq_by / uniq_by! method for deprecation**
324
+ + Suggest using `uniq` / `uniq!` with block instead in newer Rubies
325
+
326
+ ## 2024-04-17 v1.33.0
327
+
328
+ * **Changes for Ruby 3.3 and 3.4**
329
+ + Added support for Ruby **3.3**
330
+ + Added dependency on `bigdecimal` for upcoming Ruby **3.4**
331
+ * **Other Changes**
332
+ + Halting once is enough
333
+ + Added ruby **3.2**, removed some older ones
334
+ + Added test process convenience method
335
+
336
+ ## 2022-11-21 v1.32.1
337
+
338
+ * Removed mutex for finalizer, allowing Ruby to handle cleanup instead.
339
+ * Significant changes:
340
+ + Removed `mutex` variable
341
+ + Updated code to rely on Ruby's built-in finalization mechanism
342
+
343
+ ## 2022-11-17 v1.32.0
344
+
345
+ * **attempt** method now supports passing of previously caught exception into
346
+ the called block to let the handling behaviour depend on it.
347
+ * Some smaller changes to make debugging on multiple Ruby releases, easier via
348
+ all_images.
349
+ * Enable fast failing mode
350
+ * Add convenience method to create `Tins::StringVersion` objects.
351
+ * Pass previous exception to attempt block ...
352
+ ... to allow reacting to it, logging it etc.
353
+ * Remove additional groups
354
+ * Use debug instead of byebug for development
355
+ * Ignore more hidden files in the package
356
+ * Update Ruby version to **3.1**
data/Gemfile CHANGED
@@ -3,8 +3,3 @@
3
3
  source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
-
7
- group :development, :test do
8
- gem 'byebug', platform: :mri
9
- gem 'term-ansicolor'
10
- end
data/README.md CHANGED
@@ -2,99 +2,170 @@
2
2
 
3
3
  ## Description
4
4
 
5
- Non yet.
6
-
7
- ## Badges
8
-
9
- [![Code Climate](https://codeclimate.com/github/flori/tins.png)](https://codeclimate.com/github/flori/tins)
10
-
11
- [![Code Coverage](https://codeclimate.com/github/flori/tins/coverage.png)](https://codeclimate.com/github/flori/tins)
12
-
13
- ## Changes
14
-
15
- * 2018-11-14 Release 1.20.2
16
- - Fix ~x options
17
- * 2018-11-14 Release 1.20.1
18
- - Add disabling boolean options in Tins::GO#go method.
19
- * 2018-11-14 Release 1.20.0
20
- - Support default arguments in Tins::GO#go method.
21
- * 2018-11-07 Release 1.19.0
22
- - Allow annotations without arguments
23
- * 2018-11-02 Release 1.18.0
24
- - `thread_local` and `thread_global` with default block
25
- * 2018-10-15 Release 1.17.0
26
- - Add Tins::TempIO::Enum class to wrap `temp_io` into Enumerator.
27
- * 2017-12-05 Release 1.16.3
28
- - Improve `temp_io` method by not changing working dir.
29
- * 2017-12-05 Release 1.16.2
30
- - Improve `temp_io` method with a given name.
31
- * 2017-12-05 Release 1.16.1
32
- - Improve `temp_io` method with block
33
- * 2017-11-29 Release 1.16.0
34
- - Prove `temp_io` method with block
35
- * 2017-06-29 Release 1.15.0
36
- - Add support for smart duration formats with %D directive
37
- * 2017-05-16 Release 1.14.0
38
- - Add visit proc to determine if file should be visited.
39
- * 2017-05-14 Release 1.13.3
40
- - Fix some debugging warnings
41
- * 2017-02-03 Release 1.13.2
42
- - Fix test on older rubies
43
- * 2016-11-23 Release 1.13.1
44
- - Fix comparibility of Tins::Duration instances
45
- * 2016-11-23 Release 1.13.0
46
- - Add expose method mostly for testing hidden methods.
47
- * 2016-08-04 Release 1.12.0
48
- - Add Tins::Unit.parse? method to check for units in strings.
49
- * 2016-07-12 Release 1.11.0
50
- - Provide Tins::Unit.format and Tins::Unit.parse methods.
51
- * 2016-05-25 Release 1.10.2
52
- - Avoid some warnings.
53
- * 2016-04-15 Release 1.10.1
54
- - Fix bug in go if a concatenated argument comes last.
55
- * 2016-04-12 Release 1.10.0
56
- - Support mixed rest arguments in go argument parsing.
57
- * 2016-03-10 Release 1.9.0
58
- - Add Tins::Duration for displaying durations.
59
- * 2016-01-18 Release 1.8.2
60
- - Implement Tins::StringVersion::Version#dup and
61
- Tins::StringVersion::Version#clone.
62
- * 2015-12-03 Release 1.8.1
63
- - Remove some backports already existant in the newer supported rubies.
64
- * 2015-12-01 Release 1.8.0
65
- - Add `foo_of` and `foo_annotations` methods to instances of classes with
66
- annotated methods.
67
- * 2015-11-09 Release 1.7.0
68
- - Officially require ruby >= 2.0 and use new hash syntax.
69
- - New feature attempt: sleep:-30 sleeps upto 30 seconds while retrying with
70
- an exponential waiting pattern.
71
- - Remove rotate and shuffle, recent rubies all support them.
72
- - Add an object oriented view on method signatures and use it to create
73
- method descriptions.
74
- * 2015-08-13 Release 1.6.0
75
- - Add complete method for readline completion
76
- * 2015-06-21 Release 1.5.4
77
- - Avoid %i syntax for now
78
- * 2015-06-17 Release 1.5.3
79
- - Make it run on 1.9 again.
80
- - Avoid a warning in Time.dummy implementation.
81
- * 2015-05-27 Release 1.5.2
82
- - Fix parameter naming for c-methods in method descriptions.
83
- * 2015-04-24 Release 1.5.0/1.5.1
84
- - Implement bump logic for StringVersion
85
- * 2015-04-23 Release 1.4.0
86
- - Add implement module helper method.
87
- * 2015-03-03 Release 1.3.5
88
- - Don't automatically include #to method into Object, this can lead to some
89
- confusion.
90
- * 2015-02-04 Release 1.3.4
91
- - Add some default alphabets to Tins::Token, e. g. Base64
92
- - Add changes to Readme
5
+ A collection of useful Ruby utilities that extend the standard library with
6
+ practical conveniences. Tins provides lightweight, dependency-free tools for
7
+ common programming tasks.
8
+
9
+ ## Documentation
10
+
11
+ Complete API documentation is available at: [GitHub.io](https://flori.github.io/tins/)
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'tins'
19
+ ```
20
+
21
+ Or:
22
+
23
+ ```ruby
24
+ gem 'tins', require 'tins/xt'
25
+ ```
26
+
27
+ to automatically extend some core classes with useful methods.
28
+
29
+ And then execute:
30
+
31
+ $ bundle install
32
+
33
+ Or install it yourself as:
34
+
35
+ $ gem install tins
36
+
37
+ ## Usage
38
+
39
+ ```ruby
40
+ # Load all utilities
41
+
42
+ require 'tins'
43
+
44
+ # Load all utilities and extends core classes with useful methods
45
+ require 'tins/xt'
46
+ ```
47
+ ## Some Usage Examples
48
+
49
+ ### Duration Handling
50
+
51
+ ```ruby
52
+ require 'tins/duration'
53
+
54
+ duration = Tins::Duration.new(9000)
55
+ puts duration.to_s # "02:30:00"
56
+ puts duration.to_i # 9000 (seconds)
57
+
58
+ # Parse durations from strings
59
+ Tins::Duration.parse('2h 30m', template: '%hh %mm') # 9000 (seconds)
60
+ ```
61
+
62
+ ### Unit Conversion
63
+
64
+ ```ruby
65
+ require 'tins/unit'
66
+
67
+ bytes = Tins::Unit.parse('1.5 GB', unit: ?B).to_i # => 1610612736
68
+ puts Tins::Unit.format(bytes, unit: 'B') # "1.500000 GB"
69
+ ```
70
+
71
+ ### Secure File Writing
72
+
73
+ ```ruby
74
+ require 'tins/xt/secure_write'
75
+
76
+ # Write files safely (atomic operation)
77
+ File.secure_write('config.json', '{"key": "value"}')
78
+ ```
79
+
80
+ ### Time Freezing for Testing
81
+
82
+ ```ruby
83
+ require 'tins/xt/time_freezer'
84
+
85
+ # Freeze time during testing
86
+ Tins::TimeFreezer.freeze(Time.new('2011-12-13 14:15:16')) do
87
+ puts Time.now # Always returns the frozen time
88
+ end
89
+ ```
90
+
91
+ ### Building blocks for DSLs
92
+
93
+ ```ruby
94
+ class Foo
95
+ include Tins::DynamicScope
96
+
97
+ def let(bindings = {})
98
+ dynamic_scope do
99
+ bindings.each { |name, value| send("#{name}=", value) }
100
+ yield
101
+ end
102
+ end
103
+
104
+ def twice(x)
105
+ 2 * x
106
+ end
107
+
108
+ def test
109
+ let x: 1, y: twice(1) do
110
+ let z: twice(x) do
111
+ "#{x} * #{y} == #{z} # => #{x * y == twice(x)}"
112
+ end
113
+ end
114
+ end
115
+ end
116
+
117
+ Foo.new.test # "1 * 2 == 2 # => true"
118
+ ```
119
+
120
+ ### Core Class Extensions (xt)
121
+
122
+ When you require `tins/xt`, some useful methods are added to core classes:
123
+
124
+ ```ruby
125
+ default_options = {
126
+ format: :json,
127
+ timeout: 30,
128
+ retries: 3
129
+ }
130
+
131
+ user_options = { timeout: 60 }
132
+ options = user_options | default_options
133
+ # => { format: :json, timeout: 60, retries: 3 }
134
+
135
+ '1.10.3'.version < '1.9.2'.version # => false
136
+
137
+ add_one = -> x { x + 1 }
138
+ multiply_by_two = -> x { x * 2 }
139
+ composed = multiply_by_two * add_one
140
+ composed.(5) # => 12
141
+
142
+ # For Testing
143
+ >> o = Object.new
144
+ >> o.puts # => private method, NoMethodError
145
+ >> o = o.expose
146
+ >> o.puts "hello"
147
+ hello
148
+ ```
149
+
150
+ ### Hash Symbolization
151
+
152
+ ```ruby
153
+ require 'tins/hash_symbolize_keys_recursive'
154
+
155
+ hash = {
156
+ 'name' => 'John',
157
+ 'age' => 30,
158
+ 'address' => {
159
+ 'street' => '123 Main St'
160
+ }
161
+ }
162
+ hash.symbolize_keys_recursive! # Converts all keys to symbols recursively
163
+ ```
93
164
 
94
165
  ## Author
95
166
 
96
- Florian Frank mailto:flori@ping.de
167
+ [Florian Frank](mailto:flori@ping.de)
97
168
 
98
169
  ## License
99
170
 
100
- This software is licensed under the MIT (Expat) license.
171
+ [MIT License](./LICENSE)