tins 1.32.0 → 1.44.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 (150) hide show
  1. checksums.yaml +4 -4
  2. data/.contexts/code_comment.rb +23 -0
  3. data/.contexts/full.rb +31 -0
  4. data/.contexts/lib.rb +24 -0
  5. data/.contexts/yard.md +92 -0
  6. data/.github/workflows/codeql-analysis.yml +72 -0
  7. data/CHANGES.md +194 -0
  8. data/README.md +161 -90
  9. data/Rakefile +23 -19
  10. data/examples/let.rb +8 -40
  11. data/examples/mail.rb +0 -1
  12. data/examples/ones_difference.stm +0 -1
  13. data/examples/turing.rb +3 -1
  14. data/lib/tins/alias.rb +1 -0
  15. data/lib/tins/annotate.rb +37 -27
  16. data/lib/tins/ask_and_send.rb +41 -0
  17. data/lib/tins/attempt.rb +39 -0
  18. data/lib/tins/bijection.rb +34 -0
  19. data/lib/tins/case_predicate.rb +21 -0
  20. data/lib/tins/complete.rb +16 -0
  21. data/lib/tins/concern.rb +100 -0
  22. data/lib/tins/date_dummy.rb +36 -4
  23. data/lib/tins/date_time_dummy.rb +34 -2
  24. data/lib/tins/deep_dup.rb +9 -2
  25. data/lib/tins/deprecate.rb +27 -0
  26. data/lib/tins/dslkit.rb +563 -59
  27. data/lib/tins/duration.rb +160 -3
  28. data/lib/tins/expose.rb +54 -5
  29. data/lib/tins/extract_last_argument_options.rb +9 -0
  30. data/lib/tins/file_binary.rb +108 -25
  31. data/lib/tins/find.rb +114 -11
  32. data/lib/tins/generator.rb +10 -2
  33. data/lib/tins/go.rb +81 -4
  34. data/lib/tins/hash_bfs.rb +69 -0
  35. data/lib/tins/hash_symbolize_keys_recursive.rb +62 -4
  36. data/lib/tins/hash_union.rb +47 -2
  37. data/lib/tins/if_predicate.rb +31 -0
  38. data/lib/tins/implement.rb +50 -0
  39. data/lib/tins/limited.rb +105 -29
  40. data/lib/tins/lines_file.rb +81 -2
  41. data/lib/tins/lru_cache.rb +54 -17
  42. data/lib/tins/memoize.rb +86 -58
  43. data/lib/tins/method_description.rb +87 -4
  44. data/lib/tins/minimize.rb +39 -11
  45. data/lib/tins/module_group.rb +27 -2
  46. data/lib/tins/named_set.rb +20 -0
  47. data/lib/tins/null.rb +86 -15
  48. data/lib/tins/once.rb +61 -4
  49. data/lib/tins/p.rb +44 -8
  50. data/lib/tins/partial_application.rb +66 -7
  51. data/lib/tins/proc_compose.rb +58 -1
  52. data/lib/tins/proc_prelude.rb +97 -10
  53. data/lib/tins/range_plus.rb +30 -2
  54. data/lib/tins/require_maybe.rb +36 -0
  55. data/lib/tins/responding.rb +39 -0
  56. data/lib/tins/secure_write.rb +25 -5
  57. data/lib/tins/sexy_singleton.rb +46 -48
  58. data/lib/tins/string_byte_order_mark.rb +33 -2
  59. data/lib/tins/string_camelize.rb +31 -2
  60. data/lib/tins/string_named_placeholders.rb +70 -0
  61. data/lib/tins/string_underscore.rb +33 -2
  62. data/lib/tins/string_version.rb +183 -10
  63. data/lib/tins/subhash.rb +35 -10
  64. data/lib/tins/temp_io.rb +7 -0
  65. data/lib/tins/temp_io_enum.rb +19 -0
  66. data/lib/tins/terminal.rb +34 -12
  67. data/lib/tins/thread_local.rb +69 -11
  68. data/lib/tins/time_dummy.rb +47 -21
  69. data/lib/tins/to.rb +15 -0
  70. data/lib/tins/to_proc.rb +17 -4
  71. data/lib/tins/token.rb +61 -2
  72. data/lib/tins/unit.rb +288 -149
  73. data/lib/tins/version.rb +1 -1
  74. data/lib/tins/write.rb +14 -3
  75. data/lib/tins/xt/blank.rb +81 -2
  76. data/lib/tins/xt/concern.rb +51 -0
  77. data/lib/tins/xt/deep_dup.rb +4 -2
  78. data/lib/tins/xt/deprecate.rb +5 -0
  79. data/lib/tins/xt/full.rb +56 -11
  80. data/lib/tins/xt/hash_bfs.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 +3 -3
  95. data/lib/tins.rb +19 -3
  96. data/tests/annotate_test.rb +0 -1
  97. data/tests/bijection_test.rb +0 -1
  98. data/tests/concern_test.rb +63 -4
  99. data/tests/date_dummy_test.rb +0 -1
  100. data/tests/date_time_dummy_test.rb +0 -1
  101. data/tests/delegate_test.rb +0 -1
  102. data/tests/deprecate_test.rb +41 -0
  103. data/tests/dslkit_test.rb +15 -1
  104. data/tests/duration_test.rb +23 -2
  105. data/tests/dynamic_scope_test.rb +0 -1
  106. data/tests/extract_last_argument_options_test.rb +0 -1
  107. data/tests/find_test.rb +0 -1
  108. data/tests/from_module_test.rb +30 -3
  109. data/tests/generator_test.rb +0 -1
  110. data/tests/go_test.rb +0 -1
  111. data/tests/hash_bfs_test.rb +34 -0
  112. data/tests/hash_symbolize_keys_recursive_test.rb +0 -1
  113. data/tests/implement_test.rb +6 -9
  114. data/tests/limited_test.rb +12 -12
  115. data/tests/lines_file_test.rb +2 -1
  116. data/tests/lru_cache_test.rb +12 -1
  117. data/tests/memoize_test.rb +0 -1
  118. data/tests/method_description_test.rb +14 -20
  119. data/tests/minimize_test.rb +0 -1
  120. data/tests/module_group_test.rb +0 -1
  121. data/tests/named_set_test.rb +0 -1
  122. data/tests/null_test.rb +0 -1
  123. data/tests/partial_application_test.rb +4 -0
  124. data/tests/proc_prelude_test.rb +1 -1
  125. data/tests/require_maybe_test.rb +0 -1
  126. data/tests/scope_test.rb +1 -2
  127. data/tests/secure_write_test.rb +6 -1
  128. data/tests/sexy_singleton_test.rb +1 -1
  129. data/tests/string_named_placeholders.rb +109 -0
  130. data/tests/string_version_test.rb +3 -1
  131. data/tests/subhash_test.rb +0 -1
  132. data/tests/test_helper.rb +4 -7
  133. data/tests/time_dummy_test.rb +0 -1
  134. data/tests/time_freezer_test.rb +1 -1
  135. data/tests/to_test.rb +6 -6
  136. data/tests/token_test.rb +0 -1
  137. data/tests/unit_test.rb +0 -1
  138. data/tins.gemspec +18 -30
  139. metadata +55 -38
  140. data/lib/tins/count_by.rb +0 -8
  141. data/lib/tins/deep_const_get.rb +0 -50
  142. data/lib/tins/timed_cache.rb +0 -51
  143. data/lib/tins/uniq_by.rb +0 -10
  144. data/lib/tins/xt/count_by.rb +0 -11
  145. data/lib/tins/xt/deep_const_get.rb +0 -7
  146. data/lib/tins/xt/uniq_by.rb +0 -15
  147. data/tests/count_by_test.rb +0 -17
  148. data/tests/deep_const_get_test.rb +0 -37
  149. data/tests/uniq_by_test.rb +0 -31
  150. /data/{COPYING → LICENSE} +0 -0
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tins
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.32.0
4
+ version: 1.44.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-11-17 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: gem_hadar
@@ -16,16 +15,16 @@ dependencies:
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: 1.12.0
18
+ version: '2.5'
20
19
  type: :development
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: 1.12.0
25
+ version: '2.5'
27
26
  - !ruby/object:Gem::Dependency
28
- name: utils
27
+ name: all_images
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - ">="
@@ -39,7 +38,7 @@ dependencies:
39
38
  - !ruby/object:Gem::Version
40
39
  version: '0'
41
40
  - !ruby/object:Gem::Dependency
42
- name: all_images
41
+ name: debug
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
44
  - - ">="
@@ -53,7 +52,7 @@ dependencies:
53
52
  - !ruby/object:Gem::Version
54
53
  version: '0'
55
54
  - !ruby/object:Gem::Dependency
56
- name: debug
55
+ name: simplecov
57
56
  requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
58
  - - ">="
@@ -86,22 +85,22 @@ dependencies:
86
85
  requirements:
87
86
  - - "~>"
88
87
  - !ruby/object:Gem::Version
89
- version: '3.1'
88
+ version: '3.7'
90
89
  type: :development
91
90
  prerelease: false
92
91
  version_requirements: !ruby/object:Gem::Requirement
93
92
  requirements:
94
93
  - - "~>"
95
94
  - !ruby/object:Gem::Version
96
- version: '3.1'
95
+ version: '3.7'
97
96
  - !ruby/object:Gem::Dependency
98
- name: simplecov
97
+ name: sync
99
98
  requirement: !ruby/object:Gem::Requirement
100
99
  requirements:
101
100
  - - ">="
102
101
  - !ruby/object:Gem::Version
103
102
  version: '0'
104
- type: :development
103
+ type: :runtime
105
104
  prerelease: false
106
105
  version_requirements: !ruby/object:Gem::Requirement
107
106
  requirements:
@@ -109,7 +108,7 @@ dependencies:
109
108
  - !ruby/object:Gem::Version
110
109
  version: '0'
111
110
  - !ruby/object:Gem::Dependency
112
- name: sync
111
+ name: bigdecimal
113
112
  requirement: !ruby/object:Gem::Requirement
114
113
  requirements:
115
114
  - - ">="
@@ -122,6 +121,20 @@ dependencies:
122
121
  - - ">="
123
122
  - !ruby/object:Gem::Version
124
123
  version: '0'
124
+ - !ruby/object:Gem::Dependency
125
+ name: mize
126
+ requirement: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '0.6'
131
+ type: :runtime
132
+ prerelease: false
133
+ version_requirements: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: '0.6'
125
138
  description: All the stuff that isn't good/big enough for a real library.
126
139
  email: flori@ping.de
127
140
  executables: []
@@ -141,11 +154,10 @@ extra_rdoc_files:
141
154
  - lib/tins/case_predicate.rb
142
155
  - lib/tins/complete.rb
143
156
  - lib/tins/concern.rb
144
- - lib/tins/count_by.rb
145
157
  - lib/tins/date_dummy.rb
146
158
  - lib/tins/date_time_dummy.rb
147
- - lib/tins/deep_const_get.rb
148
159
  - lib/tins/deep_dup.rb
160
+ - lib/tins/deprecate.rb
149
161
  - lib/tins/dslkit.rb
150
162
  - lib/tins/duration.rb
151
163
  - lib/tins/expose.rb
@@ -154,6 +166,7 @@ extra_rdoc_files:
154
166
  - lib/tins/find.rb
155
167
  - lib/tins/generator.rb
156
168
  - lib/tins/go.rb
169
+ - lib/tins/hash_bfs.rb
157
170
  - lib/tins/hash_symbolize_keys_recursive.rb
158
171
  - lib/tins/hash_union.rb
159
172
  - lib/tins/if_predicate.rb
@@ -179,6 +192,7 @@ extra_rdoc_files:
179
192
  - lib/tins/sexy_singleton.rb
180
193
  - lib/tins/string_byte_order_mark.rb
181
194
  - lib/tins/string_camelize.rb
195
+ - lib/tins/string_named_placeholders.rb
182
196
  - lib/tins/string_underscore.rb
183
197
  - lib/tins/string_version.rb
184
198
  - lib/tins/subhash.rb
@@ -187,11 +201,9 @@ extra_rdoc_files:
187
201
  - lib/tins/terminal.rb
188
202
  - lib/tins/thread_local.rb
189
203
  - lib/tins/time_dummy.rb
190
- - lib/tins/timed_cache.rb
191
204
  - lib/tins/to.rb
192
205
  - lib/tins/to_proc.rb
193
206
  - lib/tins/token.rb
194
- - lib/tins/uniq_by.rb
195
207
  - lib/tins/unit.rb
196
208
  - lib/tins/version.rb
197
209
  - lib/tins/write.rb
@@ -203,22 +215,23 @@ extra_rdoc_files:
203
215
  - lib/tins/xt/case_predicate.rb
204
216
  - lib/tins/xt/complete.rb
205
217
  - lib/tins/xt/concern.rb
206
- - lib/tins/xt/count_by.rb
207
218
  - lib/tins/xt/date_dummy.rb
208
219
  - lib/tins/xt/date_time_dummy.rb
209
- - lib/tins/xt/deep_const_get.rb
210
220
  - lib/tins/xt/deep_dup.rb
221
+ - lib/tins/xt/deprecate.rb
211
222
  - lib/tins/xt/dslkit.rb
212
223
  - lib/tins/xt/expose.rb
213
224
  - lib/tins/xt/extract_last_argument_options.rb
214
225
  - lib/tins/xt/file_binary.rb
215
226
  - lib/tins/xt/full.rb
227
+ - lib/tins/xt/hash_bfs.rb
216
228
  - lib/tins/xt/hash_symbolize_keys_recursive.rb
217
229
  - lib/tins/xt/hash_union.rb
218
230
  - lib/tins/xt/if_predicate.rb
219
231
  - lib/tins/xt/implement.rb
220
232
  - lib/tins/xt/irb.rb
221
233
  - lib/tins/xt/method_description.rb
234
+ - lib/tins/xt/minimize.rb
222
235
  - lib/tins/xt/named.rb
223
236
  - lib/tins/xt/null.rb
224
237
  - lib/tins/xt/p.rb
@@ -233,6 +246,7 @@ extra_rdoc_files:
233
246
  - lib/tins/xt/string.rb
234
247
  - lib/tins/xt/string_byte_order_mark.rb
235
248
  - lib/tins/xt/string_camelize.rb
249
+ - lib/tins/xt/string_named_placeholders.rb
236
250
  - lib/tins/xt/string_underscore.rb
237
251
  - lib/tins/xt/string_version.rb
238
252
  - lib/tins/xt/subhash.rb
@@ -240,11 +254,16 @@ extra_rdoc_files:
240
254
  - lib/tins/xt/time_dummy.rb
241
255
  - lib/tins/xt/time_freezer.rb
242
256
  - lib/tins/xt/to.rb
243
- - lib/tins/xt/uniq_by.rb
244
257
  - lib/tins/xt/write.rb
245
258
  files:
246
- - COPYING
259
+ - ".contexts/code_comment.rb"
260
+ - ".contexts/full.rb"
261
+ - ".contexts/lib.rb"
262
+ - ".contexts/yard.md"
263
+ - ".github/workflows/codeql-analysis.yml"
264
+ - CHANGES.md
247
265
  - Gemfile
266
+ - LICENSE
248
267
  - README.md
249
268
  - Rakefile
250
269
  - examples/add_one.png
@@ -285,11 +304,10 @@ files:
285
304
  - lib/tins/case_predicate.rb
286
305
  - lib/tins/complete.rb
287
306
  - lib/tins/concern.rb
288
- - lib/tins/count_by.rb
289
307
  - lib/tins/date_dummy.rb
290
308
  - lib/tins/date_time_dummy.rb
291
- - lib/tins/deep_const_get.rb
292
309
  - lib/tins/deep_dup.rb
310
+ - lib/tins/deprecate.rb
293
311
  - lib/tins/dslkit.rb
294
312
  - lib/tins/duration.rb
295
313
  - lib/tins/expose.rb
@@ -298,6 +316,7 @@ files:
298
316
  - lib/tins/find.rb
299
317
  - lib/tins/generator.rb
300
318
  - lib/tins/go.rb
319
+ - lib/tins/hash_bfs.rb
301
320
  - lib/tins/hash_symbolize_keys_recursive.rb
302
321
  - lib/tins/hash_union.rb
303
322
  - lib/tins/if_predicate.rb
@@ -323,6 +342,7 @@ files:
323
342
  - lib/tins/sexy_singleton.rb
324
343
  - lib/tins/string_byte_order_mark.rb
325
344
  - lib/tins/string_camelize.rb
345
+ - lib/tins/string_named_placeholders.rb
326
346
  - lib/tins/string_underscore.rb
327
347
  - lib/tins/string_version.rb
328
348
  - lib/tins/subhash.rb
@@ -331,11 +351,9 @@ files:
331
351
  - lib/tins/terminal.rb
332
352
  - lib/tins/thread_local.rb
333
353
  - lib/tins/time_dummy.rb
334
- - lib/tins/timed_cache.rb
335
354
  - lib/tins/to.rb
336
355
  - lib/tins/to_proc.rb
337
356
  - lib/tins/token.rb
338
- - lib/tins/uniq_by.rb
339
357
  - lib/tins/unit.rb
340
358
  - lib/tins/version.rb
341
359
  - lib/tins/write.rb
@@ -347,22 +365,23 @@ files:
347
365
  - lib/tins/xt/case_predicate.rb
348
366
  - lib/tins/xt/complete.rb
349
367
  - lib/tins/xt/concern.rb
350
- - lib/tins/xt/count_by.rb
351
368
  - lib/tins/xt/date_dummy.rb
352
369
  - lib/tins/xt/date_time_dummy.rb
353
- - lib/tins/xt/deep_const_get.rb
354
370
  - lib/tins/xt/deep_dup.rb
371
+ - lib/tins/xt/deprecate.rb
355
372
  - lib/tins/xt/dslkit.rb
356
373
  - lib/tins/xt/expose.rb
357
374
  - lib/tins/xt/extract_last_argument_options.rb
358
375
  - lib/tins/xt/file_binary.rb
359
376
  - lib/tins/xt/full.rb
377
+ - lib/tins/xt/hash_bfs.rb
360
378
  - lib/tins/xt/hash_symbolize_keys_recursive.rb
361
379
  - lib/tins/xt/hash_union.rb
362
380
  - lib/tins/xt/if_predicate.rb
363
381
  - lib/tins/xt/implement.rb
364
382
  - lib/tins/xt/irb.rb
365
383
  - lib/tins/xt/method_description.rb
384
+ - lib/tins/xt/minimize.rb
366
385
  - lib/tins/xt/named.rb
367
386
  - lib/tins/xt/null.rb
368
387
  - lib/tins/xt/p.rb
@@ -377,6 +396,7 @@ files:
377
396
  - lib/tins/xt/string.rb
378
397
  - lib/tins/xt/string_byte_order_mark.rb
379
398
  - lib/tins/xt/string_camelize.rb
399
+ - lib/tins/xt/string_named_placeholders.rb
380
400
  - lib/tins/xt/string_underscore.rb
381
401
  - lib/tins/xt/string_version.rb
382
402
  - lib/tins/xt/subhash.rb
@@ -384,7 +404,6 @@ files:
384
404
  - lib/tins/xt/time_dummy.rb
385
405
  - lib/tins/xt/time_freezer.rb
386
406
  - lib/tins/xt/to.rb
387
- - lib/tins/xt/uniq_by.rb
388
407
  - lib/tins/xt/write.rb
389
408
  - tests/annotate_test.rb
390
409
  - tests/ask_and_send_test.rb
@@ -393,12 +412,11 @@ files:
393
412
  - tests/blank_full_test.rb
394
413
  - tests/case_predicate_test.rb
395
414
  - tests/concern_test.rb
396
- - tests/count_by_test.rb
397
415
  - tests/date_dummy_test.rb
398
416
  - tests/date_time_dummy_test.rb
399
- - tests/deep_const_get_test.rb
400
417
  - tests/deep_dup_test.rb
401
418
  - tests/delegate_test.rb
419
+ - tests/deprecate_test.rb
402
420
  - tests/dslkit_test.rb
403
421
  - tests/duration_test.rb
404
422
  - tests/dynamic_scope_test.rb
@@ -409,6 +427,7 @@ files:
409
427
  - tests/from_module_test.rb
410
428
  - tests/generator_test.rb
411
429
  - tests/go_test.rb
430
+ - tests/hash_bfs_test.rb
412
431
  - tests/hash_symbolize_keys_recursive_test.rb
413
432
  - tests/hash_union_test.rb
414
433
  - tests/if_predicate_test.rb
@@ -436,6 +455,7 @@ files:
436
455
  - tests/sexy_singleton_test.rb
437
456
  - tests/string_byte_order_mark_test.rb
438
457
  - tests/string_camelize_test.rb
458
+ - tests/string_named_placeholders.rb
439
459
  - tests/string_underscore_test.rb
440
460
  - tests/string_version_test.rb
441
461
  - tests/subhash_test.rb
@@ -445,14 +465,12 @@ files:
445
465
  - tests/time_freezer_test.rb
446
466
  - tests/to_test.rb
447
467
  - tests/token_test.rb
448
- - tests/uniq_by_test.rb
449
468
  - tests/unit_test.rb
450
469
  - tins.gemspec
451
470
  homepage: https://github.com/flori/tins
452
471
  licenses:
453
472
  - MIT
454
473
  metadata: {}
455
- post_install_message:
456
474
  rdoc_options:
457
475
  - "--title"
458
476
  - Tins - Useful stuff.
@@ -464,15 +482,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
464
482
  requirements:
465
483
  - - ">="
466
484
  - !ruby/object:Gem::Version
467
- version: '2.0'
485
+ version: '3.1'
468
486
  required_rubygems_version: !ruby/object:Gem::Requirement
469
487
  requirements:
470
488
  - - ">="
471
489
  - !ruby/object:Gem::Version
472
490
  version: '0'
473
491
  requirements: []
474
- rubygems_version: 3.3.25
475
- signing_key:
492
+ rubygems_version: 3.6.9
476
493
  specification_version: 4
477
494
  summary: Useful stuff.
478
495
  test_files:
@@ -483,12 +500,11 @@ test_files:
483
500
  - tests/blank_full_test.rb
484
501
  - tests/case_predicate_test.rb
485
502
  - tests/concern_test.rb
486
- - tests/count_by_test.rb
487
503
  - tests/date_dummy_test.rb
488
504
  - tests/date_time_dummy_test.rb
489
- - tests/deep_const_get_test.rb
490
505
  - tests/deep_dup_test.rb
491
506
  - tests/delegate_test.rb
507
+ - tests/deprecate_test.rb
492
508
  - tests/dslkit_test.rb
493
509
  - tests/duration_test.rb
494
510
  - tests/dynamic_scope_test.rb
@@ -499,6 +515,7 @@ test_files:
499
515
  - tests/from_module_test.rb
500
516
  - tests/generator_test.rb
501
517
  - tests/go_test.rb
518
+ - tests/hash_bfs_test.rb
502
519
  - tests/hash_symbolize_keys_recursive_test.rb
503
520
  - tests/hash_union_test.rb
504
521
  - tests/if_predicate_test.rb
@@ -526,6 +543,7 @@ test_files:
526
543
  - tests/sexy_singleton_test.rb
527
544
  - tests/string_byte_order_mark_test.rb
528
545
  - tests/string_camelize_test.rb
546
+ - tests/string_named_placeholders.rb
529
547
  - tests/string_underscore_test.rb
530
548
  - tests/string_version_test.rb
531
549
  - tests/subhash_test.rb
@@ -535,5 +553,4 @@ test_files:
535
553
  - tests/time_freezer_test.rb
536
554
  - tests/to_test.rb
537
555
  - tests/token_test.rb
538
- - tests/uniq_by_test.rb
539
556
  - tests/unit_test.rb
data/lib/tins/count_by.rb DELETED
@@ -1,8 +0,0 @@
1
- module Tins
2
- module CountBy
3
- def count_by(&b)
4
- b ||= lambda { |x| true }
5
- inject(0) { |s, e| s += 1 if b[e]; s }
6
- end
7
- end
8
- end
@@ -1,50 +0,0 @@
1
- module Tins
2
- module DeepConstGet
3
- if ::Object.method(:const_defined?).arity == 1
4
- # :nocov:
5
- # We do not create coverage on 1.8
6
- def self.const_defined_in?(modul, constant)
7
- modul.const_defined?(constant)
8
- end
9
- # :nocov:
10
- else
11
- def self.const_defined_in?(modul, constant)
12
- modul.const_defined?(constant, false)
13
- end
14
- end
15
-
16
- if Tins::StringVersion(RUBY_VERSION) < Tins::StringVersion('2.0')
17
- def self.deep_const_get(path, start_module = Object)
18
- path.to_s.split('::').inject(start_module) do |p, c|
19
- case
20
- when c.empty?
21
- if start_module == Object
22
- Object
23
- else
24
- raise ArgumentError, "top level constants cannot be reached from"\
25
- " start module #{start_module.inspect}"
26
- end
27
- when const_defined_in?(p, c)
28
- p.const_get(c)
29
- else
30
- begin
31
- p.const_missing(c)
32
- rescue NameError => e
33
- raise ArgumentError, "can't get const #{path}: #{e}"
34
- end
35
- end
36
- end
37
- end
38
- else
39
- def self.deep_const_get(path, start_module = Object)
40
- start_module.const_get(path)
41
- rescue NameError => e
42
- raise ArgumentError, "can't get const #{path}: #{e}"
43
- end
44
- end
45
-
46
- def deep_const_get(path, start_module = Object)
47
- ::Tins::DeepConstGet.deep_const_get(path, start_module)
48
- end
49
- end
50
- end
@@ -1,51 +0,0 @@
1
- class TimedCache
2
- class Value < Struct.new(:value, :timestamp)
3
- def self.json_create(hash)
4
- new(*hash.values_at('value', 'timestamp'))
5
- end
6
-
7
- def as_json(*)
8
- super | { JSON.create_id => self.class.name }
9
- end
10
- end
11
-
12
- def initialize(name, ttl: 60, jitter: 1..5, &block)
13
- @name = name
14
- @ttl = ttl
15
- @jitter = jitter
16
- block or raise ArgumentError, 'block is required'
17
- @block = block
18
- @redis = Redis.new # RedisPool::Pool.connection(:timed_cache, configuration: :redis)
19
- end
20
-
21
- def namespaced(key)
22
- "timed_cache:#{key}"
23
- end
24
-
25
- def value
26
- now = Time.now
27
- if stored = stored_value
28
- if (now - @ttl).to_i >= stored.timestamp
29
- Thread.new {
30
- sleep @jitter
31
- if stored_value.timestamp <= stored.timestamp
32
- @redis.set namespaced(@name), new_value(now).to_json
33
- end
34
- }
35
- end
36
- stored.value
37
- else
38
- nv = new_value(now)
39
- @redis.set namespaced(@name), nv.to_json
40
- nv.value
41
- end
42
- end
43
-
44
- def new_value(now)
45
- Value.new(@block.(), now.to_i)
46
- end
47
-
48
- def stored_value
49
- @redis.get(namespaced(@name)).full? { |s| ::JSON.parse(s, create_additions: true) rescue nil }
50
- end
51
- end
data/lib/tins/uniq_by.rb DELETED
@@ -1,10 +0,0 @@
1
- module Tins
2
- module UniqBy
3
- def uniq_by(&b)
4
- b ||= lambda { |x| x }
5
- inject({}) { |h, e| h[b[e]] ||= e; h }.values
6
- end
7
- end
8
- end
9
-
10
- require 'tins/alias'
@@ -1,11 +0,0 @@
1
- require 'tins/count_by'
2
-
3
- module Tins
4
- module ::Enumerable
5
- include CountBy
6
- end
7
-
8
- class ::Array
9
- include CountBy
10
- end
11
- end
@@ -1,7 +0,0 @@
1
- require 'tins/deep_const_get'
2
-
3
- module Tins
4
- class ::Object
5
- include DeepConstGet
6
- end
7
- end
@@ -1,15 +0,0 @@
1
- require 'tins/uniq_by'
2
-
3
- module Tins
4
- module ::Enumerable
5
- include UniqBy
6
- end
7
-
8
- class ::Array
9
- include UniqBy
10
-
11
- def uniq_by!(&b)
12
- replace uniq_by(&b)
13
- end
14
- end
15
- end
@@ -1,17 +0,0 @@
1
- require 'test_helper'
2
- require 'tins/xt'
3
-
4
- module Tins
5
- class CountByTest < Test::Unit::TestCase
6
-
7
- def test_count_by
8
- assert_equal 0, [].count_by { |x| x % 2 == 0 }
9
- assert_equal 0, [ 1 ].count_by { |x| x % 2 == 0 }
10
- assert_equal 1, [ 1 ].count_by { |x| x % 2 == 1 }
11
- assert_equal 1, [ 1, 2 ].count_by { |x| x % 2 == 0 }
12
- assert_equal 1, [ 1, 2 ].count_by { |x| x % 2 == 1 }
13
- assert_equal 2, [ 1, 2, 3, 4, 5 ].count_by { |x| x % 2 == 0 }
14
- assert_equal 3, [ 1, 2, 3, 4, 5 ].count_by { |x| x % 2 == 1 }
15
- end
16
- end
17
- end
@@ -1,37 +0,0 @@
1
- require 'test_helper'
2
- require 'tins/xt/deep_const_get'
3
-
4
- module Tins
5
- class DeepConstGetTest < Test::Unit::TestCase
6
- module A
7
- module B
8
- end
9
- end
10
-
11
- module C
12
- module NotB
13
- end
14
-
15
- def self.const_missing(c)
16
- NotB
17
- end
18
- end
19
-
20
- def test_deep_const_get_with_start_module
21
- assert_raise(ArgumentError) { deep_const_get '::B', A }
22
- assert_equal A::B, deep_const_get('B', A)
23
- end
24
-
25
- def test_deep_const_get_without_start_module
26
- assert_equal Tins::DeepConstGetTest::A::B, deep_const_get('::Tins::DeepConstGetTest::A::B')
27
- assert_equal Tins::DeepConstGetTest::A::B, deep_const_get('Tins::DeepConstGetTest::A::B')
28
- assert_equal Array, deep_const_get('::Array')
29
- assert_equal Array, deep_const_get('Array')
30
- end
31
-
32
- def test_deep_const_get_with_const_missing
33
- assert_raise(ArgumentError) { deep_const_get '::Tins::DeepConstGetTest::A::NIXDA' }
34
- assert_equal Tins::DeepConstGetTest::C::NotB, deep_const_get('::Tins::DeepConstGetTest::C::B')
35
- end
36
- end
37
- end
@@ -1,31 +0,0 @@
1
- require 'test_helper'
2
- require 'tins/xt'
3
-
4
- module Tins
5
- class UniqByTest < Test::Unit::TestCase
6
-
7
- unless defined?(Point)
8
- class Point < Struct.new :x, :y
9
- end
10
- end
11
-
12
- def test_uniq_by
13
- assert_equal [ 1, 2, 3 ], [ 1, 2, 2, 3 ].uniq_by.sort
14
- a = [ 1, 2, 2, 3 ]; a.uniq_by!
15
- assert_equal [ 1, 2, 3 ], a.sort
16
- p1 = Point.new 1, 2
17
- p2 = Point.new 2, 2
18
- p3 = Point.new 2, 2
19
- p4 = Point.new 3, 3
20
- a = [ p1, p2, p3, p4 ]
21
- a_uniq = a.uniq_by { |p| p.y }
22
- assert_equal 2, a_uniq.size
23
- assert a_uniq.include?(p4)
24
- assert [ p1, p2, p3 ].any? { |p| a_uniq.include? p }
25
- a.uniq_by! { |p| p.y }
26
- assert_equal 2, a.size
27
- assert a.include?(p4)
28
- assert [ p1, p2, p3 ].any? { |p| a.include? p }
29
- end
30
- end
31
- end
File without changes