nrser 0.2.2 → 0.3.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 (188) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nrser/char/alpha_numeric_sub.rb +1 -2
  3. data/lib/nrser/char.rb +0 -6
  4. data/lib/nrser/core_ext/array.rb +120 -0
  5. data/lib/nrser/core_ext/binding.rb +44 -0
  6. data/lib/nrser/{functions → core_ext}/enumerable/find_map.rb +18 -15
  7. data/lib/nrser/{ext → core_ext}/enumerable.rb +10 -24
  8. data/lib/nrser/core_ext/exception.rb +30 -0
  9. data/lib/nrser/core_ext/hash/extract_values_at.rb +49 -0
  10. data/lib/nrser/core_ext/hash/transform_values_with_keys.rb +24 -0
  11. data/lib/nrser/core_ext/hash.rb +50 -0
  12. data/lib/nrser/core_ext/module/method_objects.rb +96 -0
  13. data/lib/nrser/core_ext/module/names.rb +69 -0
  14. data/lib/nrser/core_ext/module/source_locations.rb +214 -0
  15. data/lib/nrser/core_ext/module.rb +2 -0
  16. data/lib/nrser/core_ext/object/lazy_var.rb +31 -0
  17. data/lib/nrser/core_ext/object.rb +46 -0
  18. data/lib/nrser/core_ext/open_struct.rb +6 -0
  19. data/lib/nrser/{ext → core_ext}/pathname.rb +8 -5
  20. data/lib/nrser/{ext → core_ext}/string.rb +6 -12
  21. data/lib/nrser/core_ext/symbol.rb +13 -0
  22. data/lib/nrser/core_ext/time.rb +46 -0
  23. data/lib/nrser/core_ext.rb +13 -0
  24. data/lib/nrser/errors/abstract_method_error.rb +150 -0
  25. data/lib/nrser/errors/argument_error.rb +42 -0
  26. data/lib/nrser/errors/nicer_error.rb +298 -72
  27. data/lib/nrser/errors/type_error.rb +46 -0
  28. data/lib/nrser/errors.rb +4 -53
  29. data/lib/nrser/ext/tree.rb +3 -0
  30. data/lib/nrser/functions/enumerable/associate.rb +6 -9
  31. data/lib/nrser/functions/enumerable/include_slice.rb +2 -3
  32. data/lib/nrser/functions/enumerable.rb +1 -3
  33. data/lib/nrser/functions/exception.rb +1 -1
  34. data/lib/nrser/functions/hash.rb +0 -6
  35. data/lib/nrser/functions/merge_by.rb +2 -2
  36. data/lib/nrser/functions/module/method_objects.rb +77 -0
  37. data/lib/nrser/functions/module.rb +1 -2
  38. data/lib/nrser/functions/open_struct.rb +25 -35
  39. data/lib/nrser/functions/proc.rb +1 -6
  40. data/lib/nrser/functions/string/looks_like.rb +32 -1
  41. data/lib/nrser/functions/string.rb +1 -40
  42. data/lib/nrser/functions/text/lines.rb +2 -1
  43. data/lib/nrser/functions.rb +0 -1
  44. data/lib/nrser/graph/tsorter.rb +41 -0
  45. data/lib/nrser/labs/core_ext/binding.rb +37 -0
  46. data/lib/nrser/labs/stash.rb +372 -0
  47. data/lib/nrser/{logging → log}/appender/sync.rb +3 -3
  48. data/lib/nrser/log/appender.rb +3 -0
  49. data/lib/nrser/{logging → log}/formatters/color.rb +47 -20
  50. data/lib/nrser/log/formatters/mixin.rb +270 -0
  51. data/lib/nrser/{logging → log}/formatters.rb +0 -0
  52. data/lib/nrser/log/logger.rb +229 -0
  53. data/lib/nrser/log/mixin.rb +56 -0
  54. data/lib/nrser/log.rb +723 -0
  55. data/lib/nrser/message.rb +24 -3
  56. data/lib/nrser/meta/source/location.rb +158 -0
  57. data/lib/nrser/meta.rb +1 -1
  58. data/lib/nrser/props/class_methods.rb +118 -0
  59. data/lib/nrser/props/immutable/hash.rb +111 -0
  60. data/lib/nrser/props/immutable/hash_variable.rb +82 -0
  61. data/lib/nrser/props/immutable/instance_variables.rb +48 -0
  62. data/lib/nrser/props/immutable/vector.rb +107 -0
  63. data/lib/nrser/props/instance_methods.rb +184 -0
  64. data/lib/nrser/props/metadata.rb +359 -0
  65. data/lib/nrser/props/mutable/instance_variables.rb +60 -0
  66. data/lib/nrser/props/mutable/stash.rb +199 -0
  67. data/lib/nrser/{meta/props → props}/prop.rb +217 -112
  68. data/lib/nrser/props/storage/instance_variable.rb +85 -0
  69. data/lib/nrser/props/storage/instance_variables.rb +67 -0
  70. data/lib/nrser/props/storage/key.rb +88 -0
  71. data/lib/nrser/props.rb +9 -0
  72. data/lib/nrser/refinements/sugar.rb +41 -0
  73. data/lib/nrser/refinements/types.rb +2 -2
  74. data/lib/nrser/refinements.rb +14 -16
  75. data/lib/nrser/rspex/example_group/describe_attribute.rb +24 -0
  76. data/lib/nrser/rspex/example_group/describe_called_with.rb +1 -6
  77. data/lib/nrser/rspex/example_group/{describe_use_case.rb → describe_case.rb} +6 -3
  78. data/lib/nrser/rspex/example_group/describe_class.rb +1 -0
  79. data/lib/nrser/rspex/example_group/describe_group.rb +29 -0
  80. data/lib/nrser/rspex/example_group/describe_instance_method.rb +2 -2
  81. data/lib/nrser/rspex/example_group/describe_message.rb +35 -0
  82. data/lib/nrser/rspex/example_group/describe_method.rb +23 -2
  83. data/lib/nrser/rspex/example_group/describe_module.rb +19 -0
  84. data/lib/nrser/rspex/example_group/describe_response_to.rb +32 -0
  85. data/lib/nrser/rspex/example_group/describe_section.rb +38 -0
  86. data/lib/nrser/rspex/example_group/describe_sent_to.rb +52 -0
  87. data/lib/nrser/rspex/example_group/describe_source_file.rb +49 -0
  88. data/lib/nrser/rspex/example_group/describe_spec_file.rb +41 -108
  89. data/lib/nrser/rspex/example_group/describe_when.rb +14 -7
  90. data/lib/nrser/rspex/example_group/describe_x.rb +39 -12
  91. data/lib/nrser/rspex/example_group/overrides.rb +66 -0
  92. data/lib/nrser/rspex/example_group.rb +20 -252
  93. data/lib/nrser/rspex/format.rb +83 -17
  94. data/lib/nrser/rspex.rb +4 -34
  95. data/lib/nrser/sugar/method_missing_forwarder.rb +50 -0
  96. data/lib/nrser/{env → sys/env}/path.rb +1 -2
  97. data/lib/nrser/{env.rb → sys/env.rb} +2 -1
  98. data/lib/nrser/sys.rb +5 -0
  99. data/lib/nrser/types/any.rb +36 -7
  100. data/lib/nrser/types/{array.rb → arrays.rb} +32 -81
  101. data/lib/nrser/types/attrs.rb +68 -15
  102. data/lib/nrser/types/booleans.rb +95 -34
  103. data/lib/nrser/types/bounded.rb +12 -10
  104. data/lib/nrser/types/combinators.rb +74 -37
  105. data/lib/nrser/types/errors/check_error.rb +86 -0
  106. data/lib/nrser/types/errors/from_string_error.rb +82 -0
  107. data/lib/nrser/types/factory.rb +91 -0
  108. data/lib/nrser/types/hashes.rb +171 -26
  109. data/lib/nrser/types/in.rb +25 -12
  110. data/lib/nrser/types/is.rb +50 -18
  111. data/lib/nrser/types/is_a.rb +52 -33
  112. data/lib/nrser/types/labels.rb +6 -33
  113. data/lib/nrser/types/maybe.rb +12 -4
  114. data/lib/nrser/types/nil.rb +24 -4
  115. data/lib/nrser/types/not.rb +6 -16
  116. data/lib/nrser/types/numbers.rb +94 -57
  117. data/lib/nrser/types/pairs.rb +57 -57
  118. data/lib/nrser/types/paths.rb +112 -133
  119. data/lib/nrser/types/responds.rb +64 -74
  120. data/lib/nrser/types/shape.rb +29 -24
  121. data/lib/nrser/types/strings.rb +25 -17
  122. data/lib/nrser/types/symbols.rb +19 -17
  123. data/lib/nrser/types/trees.rb +18 -70
  124. data/lib/nrser/types/tuples.rb +36 -40
  125. data/lib/nrser/types/type.rb +342 -91
  126. data/lib/nrser/types/when.rb +40 -18
  127. data/lib/nrser/types/where.rb +94 -9
  128. data/lib/nrser/types.rb +72 -63
  129. data/lib/nrser/version.rb +1 -1
  130. data/lib/nrser.rb +18 -18
  131. data/spec/lib/nrser/{functions/binding/template_spec.rb → core_ext/binding/erb_spec.rb} +5 -5
  132. data/spec/lib/nrser/{functions → core_ext}/enumerable/find_map_spec.rb +8 -6
  133. data/spec/lib/nrser/{refinements → core_ext}/hash_spec.rb +9 -22
  134. data/spec/lib/nrser/errors/abstract_method_error_spec.rb +12 -5
  135. data/spec/lib/nrser/functions/enumerable/{to_h_by_spec.rb → associate_spec.rb} +1 -1
  136. data/spec/lib/nrser/functions/merge_by_spec.rb +1 -1
  137. data/spec/lib/nrser/functions/tree/each_branch_spec.rb +3 -3
  138. data/spec/lib/nrser/functions/tree/transform_spec.rb +14 -15
  139. data/spec/lib/nrser/gem_ext/hamster/json_spec.rb +4 -0
  140. data/spec/lib/nrser/meta/source/location_spec.rb +86 -0
  141. data/spec/lib/nrser/props/immutable/hash_spec.rb +297 -0
  142. data/spec/lib/nrser/props/immutable/vector_spec.rb +296 -0
  143. data/spec/lib/nrser/{meta/props_spec.rb → props/original_props_spec.rb} +11 -16
  144. data/spec/lib/nrser/{meta/props → props}/to_and_from_data_spec.rb +10 -8
  145. data/spec/lib/nrser/refinements/array_spec.rb +2 -15
  146. data/spec/lib/nrser/refinements/erb_spec.rb +5 -7
  147. data/spec/lib/nrser/refinements/set_spec.rb +2 -15
  148. data/spec/lib/nrser/{env → sys/env}/path/insert_spec.rb +4 -2
  149. data/spec/lib/nrser/{env → sys/env}/path_spec.rb +4 -2
  150. data/spec/lib/nrser/types/array_spec.rb +8 -8
  151. data/spec/lib/nrser/types/paths_spec.rb +15 -18
  152. data/spec/spec_helper.rb +4 -0
  153. metadata +109 -69
  154. data/lib/nrser/ext/binding.rb +0 -36
  155. data/lib/nrser/ext/module.rb +0 -62
  156. data/lib/nrser/ext.rb +0 -8
  157. data/lib/nrser/functions/binding.rb +0 -76
  158. data/lib/nrser/functions/enumerable/map_keys.rb +0 -0
  159. data/lib/nrser/functions/enumerable/map_values.rb +0 -94
  160. data/lib/nrser/functions/hash/deep_merge.rb +0 -57
  161. data/lib/nrser/functions/hash/except_keys.rb +0 -44
  162. data/lib/nrser/functions/hash/slice_keys.rb +0 -43
  163. data/lib/nrser/functions/hash/stringify_keys.rb +0 -55
  164. data/lib/nrser/functions/hash/symbolize_keys.rb +0 -57
  165. data/lib/nrser/functions/hash/transform_keys.rb +0 -140
  166. data/lib/nrser/functions/module/methods.rb +0 -206
  167. data/lib/nrser/functions/module/source_locations.rb +0 -213
  168. data/lib/nrser/logging/appender.rb +0 -3
  169. data/lib/nrser/logging.rb +0 -353
  170. data/lib/nrser/meta/props/base.rb +0 -31
  171. data/lib/nrser/meta/props.rb +0 -357
  172. data/lib/nrser/refinements/array.rb +0 -133
  173. data/lib/nrser/refinements/binding.rb +0 -6
  174. data/lib/nrser/refinements/enumerator.rb +0 -5
  175. data/lib/nrser/refinements/exception.rb +0 -35
  176. data/lib/nrser/refinements/hash.rb +0 -150
  177. data/lib/nrser/refinements/module.rb +0 -5
  178. data/lib/nrser/refinements/object.rb +0 -42
  179. data/lib/nrser/refinements/open_struct.rb +0 -28
  180. data/lib/nrser/refinements/pathname.rb +0 -5
  181. data/lib/nrser/refinements/set.rb +0 -5
  182. data/lib/nrser/refinements/string.rb +0 -5
  183. data/lib/nrser/refinements/symbol.rb +0 -20
  184. data/lib/nrser/rspex/described.rb +0 -99
  185. data/spec/design/mapping_spec.rb +0 -42
  186. data/spec/lib/nrser/functions/hash_spec.rb +0 -41
  187. data/spec/lib/nrser/functions/string/truncate_spec.rb +0 -11
  188. data/spec/lib/nrser/refinements/truncate_spec.rb +0 -10
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nrser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nrser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-22 00:00:00.000000000 Z
11
+ date: 2018-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hamster
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.17.7
83
+ - !ruby/object:Gem::Dependency
84
+ name: activesupport
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '5.1'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '5.1'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: bundler
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -218,46 +232,50 @@ files:
218
232
  - lib/nrser/char/alpha_numeric_sub.rb
219
233
  - lib/nrser/char/special.rb
220
234
  - lib/nrser/collection.rb
221
- - lib/nrser/env.rb
222
- - lib/nrser/env/path.rb
235
+ - lib/nrser/core_ext.rb
236
+ - lib/nrser/core_ext/array.rb
237
+ - lib/nrser/core_ext/binding.rb
238
+ - lib/nrser/core_ext/enumerable.rb
239
+ - lib/nrser/core_ext/enumerable/find_map.rb
240
+ - lib/nrser/core_ext/exception.rb
241
+ - lib/nrser/core_ext/hash.rb
242
+ - lib/nrser/core_ext/hash/extract_values_at.rb
243
+ - lib/nrser/core_ext/hash/transform_values_with_keys.rb
244
+ - lib/nrser/core_ext/module.rb
245
+ - lib/nrser/core_ext/module/method_objects.rb
246
+ - lib/nrser/core_ext/module/names.rb
247
+ - lib/nrser/core_ext/module/source_locations.rb
248
+ - lib/nrser/core_ext/object.rb
249
+ - lib/nrser/core_ext/object/lazy_var.rb
250
+ - lib/nrser/core_ext/open_struct.rb
251
+ - lib/nrser/core_ext/pathname.rb
252
+ - lib/nrser/core_ext/string.rb
253
+ - lib/nrser/core_ext/symbol.rb
254
+ - lib/nrser/core_ext/time.rb
223
255
  - lib/nrser/errors.rb
256
+ - lib/nrser/errors/abstract_method_error.rb
257
+ - lib/nrser/errors/argument_error.rb
224
258
  - lib/nrser/errors/attr_error.rb
225
259
  - lib/nrser/errors/count_error.rb
226
260
  - lib/nrser/errors/nicer_error.rb
261
+ - lib/nrser/errors/type_error.rb
227
262
  - lib/nrser/errors/value_error.rb
228
- - lib/nrser/ext.rb
229
- - lib/nrser/ext/binding.rb
230
- - lib/nrser/ext/enumerable.rb
231
- - lib/nrser/ext/module.rb
232
- - lib/nrser/ext/pathname.rb
233
- - lib/nrser/ext/string.rb
234
263
  - lib/nrser/ext/tree.rb
235
264
  - lib/nrser/functions.rb
236
265
  - lib/nrser/functions/array.rb
237
- - lib/nrser/functions/binding.rb
238
266
  - lib/nrser/functions/enumerable.rb
239
267
  - lib/nrser/functions/enumerable/associate.rb
240
268
  - lib/nrser/functions/enumerable/find_all_map.rb
241
- - lib/nrser/functions/enumerable/find_map.rb
242
269
  - lib/nrser/functions/enumerable/include_slice.rb
243
270
  - lib/nrser/functions/enumerable/include_slice/array_include_slice.rb
244
- - lib/nrser/functions/enumerable/map_keys.rb
245
- - lib/nrser/functions/enumerable/map_values.rb
246
271
  - lib/nrser/functions/exception.rb
247
272
  - lib/nrser/functions/git.rb
248
273
  - lib/nrser/functions/hash.rb
249
274
  - lib/nrser/functions/hash/bury.rb
250
- - lib/nrser/functions/hash/deep_merge.rb
251
- - lib/nrser/functions/hash/except_keys.rb
252
275
  - lib/nrser/functions/hash/guess_label_key_type.rb
253
- - lib/nrser/functions/hash/slice_keys.rb
254
- - lib/nrser/functions/hash/stringify_keys.rb
255
- - lib/nrser/functions/hash/symbolize_keys.rb
256
- - lib/nrser/functions/hash/transform_keys.rb
257
276
  - lib/nrser/functions/merge_by.rb
258
277
  - lib/nrser/functions/module.rb
259
- - lib/nrser/functions/module/methods.rb
260
- - lib/nrser/functions/module/source_locations.rb
278
+ - lib/nrser/functions/module/method_objects.rb
261
279
  - lib/nrser/functions/object.rb
262
280
  - lib/nrser/functions/object/as_array.rb
263
281
  - lib/nrser/functions/object/as_hash.rb
@@ -280,60 +298,82 @@ files:
280
298
  - lib/nrser/functions/tree/map_leaves.rb
281
299
  - lib/nrser/functions/tree/map_tree.rb
282
300
  - lib/nrser/functions/tree/transform.rb
301
+ - lib/nrser/graph/tsorter.rb
283
302
  - lib/nrser/labs.rb
303
+ - lib/nrser/labs/core_ext/binding.rb
284
304
  - lib/nrser/labs/globlin.rb
285
305
  - lib/nrser/labs/index.rb
286
- - lib/nrser/logging.rb
287
- - lib/nrser/logging/appender.rb
288
- - lib/nrser/logging/appender/sync.rb
289
- - lib/nrser/logging/formatters.rb
290
- - lib/nrser/logging/formatters/color.rb
306
+ - lib/nrser/labs/stash.rb
307
+ - lib/nrser/log.rb
308
+ - lib/nrser/log/appender.rb
309
+ - lib/nrser/log/appender/sync.rb
310
+ - lib/nrser/log/formatters.rb
311
+ - lib/nrser/log/formatters/color.rb
312
+ - lib/nrser/log/formatters/mixin.rb
313
+ - lib/nrser/log/logger.rb
314
+ - lib/nrser/log/mixin.rb
291
315
  - lib/nrser/mean_streak.rb
292
316
  - lib/nrser/mean_streak/document.rb
293
317
  - lib/nrser/message.rb
294
318
  - lib/nrser/meta.rb
295
319
  - lib/nrser/meta/class_attrs.rb
296
- - lib/nrser/meta/props.rb
297
- - lib/nrser/meta/props/base.rb
298
- - lib/nrser/meta/props/prop.rb
320
+ - lib/nrser/meta/source/location.rb
299
321
  - lib/nrser/no_arg.rb
322
+ - lib/nrser/props.rb
323
+ - lib/nrser/props/class_methods.rb
324
+ - lib/nrser/props/immutable/hash.rb
325
+ - lib/nrser/props/immutable/hash_variable.rb
326
+ - lib/nrser/props/immutable/instance_variables.rb
327
+ - lib/nrser/props/immutable/vector.rb
328
+ - lib/nrser/props/instance_methods.rb
329
+ - lib/nrser/props/metadata.rb
330
+ - lib/nrser/props/mutable/instance_variables.rb
331
+ - lib/nrser/props/mutable/stash.rb
332
+ - lib/nrser/props/prop.rb
333
+ - lib/nrser/props/storage/instance_variable.rb
334
+ - lib/nrser/props/storage/instance_variables.rb
335
+ - lib/nrser/props/storage/key.rb
300
336
  - lib/nrser/refinements.rb
301
- - lib/nrser/refinements/array.rb
302
- - lib/nrser/refinements/binding.rb
303
- - lib/nrser/refinements/enumerator.rb
304
- - lib/nrser/refinements/exception.rb
305
- - lib/nrser/refinements/hash.rb
306
- - lib/nrser/refinements/module.rb
307
- - lib/nrser/refinements/object.rb
308
- - lib/nrser/refinements/open_struct.rb
309
- - lib/nrser/refinements/pathname.rb
310
- - lib/nrser/refinements/set.rb
311
- - lib/nrser/refinements/string.rb
312
- - lib/nrser/refinements/symbol.rb
337
+ - lib/nrser/refinements/sugar.rb
313
338
  - lib/nrser/refinements/types.rb
314
339
  - lib/nrser/rspex.rb
315
- - lib/nrser/rspex/described.rb
316
340
  - lib/nrser/rspex/example.rb
317
341
  - lib/nrser/rspex/example_group.rb
342
+ - lib/nrser/rspex/example_group/describe_attribute.rb
318
343
  - lib/nrser/rspex/example_group/describe_called_with.rb
344
+ - lib/nrser/rspex/example_group/describe_case.rb
319
345
  - lib/nrser/rspex/example_group/describe_class.rb
346
+ - lib/nrser/rspex/example_group/describe_group.rb
320
347
  - lib/nrser/rspex/example_group/describe_instance.rb
321
348
  - lib/nrser/rspex/example_group/describe_instance_method.rb
349
+ - lib/nrser/rspex/example_group/describe_message.rb
322
350
  - lib/nrser/rspex/example_group/describe_method.rb
351
+ - lib/nrser/rspex/example_group/describe_module.rb
352
+ - lib/nrser/rspex/example_group/describe_response_to.rb
353
+ - lib/nrser/rspex/example_group/describe_section.rb
354
+ - lib/nrser/rspex/example_group/describe_sent_to.rb
323
355
  - lib/nrser/rspex/example_group/describe_setup.rb
356
+ - lib/nrser/rspex/example_group/describe_source_file.rb
324
357
  - lib/nrser/rspex/example_group/describe_spec_file.rb
325
- - lib/nrser/rspex/example_group/describe_use_case.rb
326
358
  - lib/nrser/rspex/example_group/describe_when.rb
327
359
  - lib/nrser/rspex/example_group/describe_x.rb
360
+ - lib/nrser/rspex/example_group/overrides.rb
328
361
  - lib/nrser/rspex/format.rb
329
362
  - lib/nrser/rspex/shared_examples.rb
363
+ - lib/nrser/sugar/method_missing_forwarder.rb
364
+ - lib/nrser/sys.rb
365
+ - lib/nrser/sys/env.rb
366
+ - lib/nrser/sys/env/path.rb
330
367
  - lib/nrser/types.rb
331
368
  - lib/nrser/types/any.rb
332
- - lib/nrser/types/array.rb
369
+ - lib/nrser/types/arrays.rb
333
370
  - lib/nrser/types/attrs.rb
334
371
  - lib/nrser/types/booleans.rb
335
372
  - lib/nrser/types/bounded.rb
336
373
  - lib/nrser/types/combinators.rb
374
+ - lib/nrser/types/errors/check_error.rb
375
+ - lib/nrser/types/errors/from_string_error.rb
376
+ - lib/nrser/types/factory.rb
337
377
  - lib/nrser/types/hashes.rb
338
378
  - lib/nrser/types/in.rb
339
379
  - lib/nrser/types/is.rb
@@ -355,29 +395,25 @@ files:
355
395
  - lib/nrser/types/when.rb
356
396
  - lib/nrser/types/where.rb
357
397
  - lib/nrser/version.rb
358
- - spec/design/mapping_spec.rb
359
398
  - spec/lib/nrser/collection/each_spec.rb
360
399
  - spec/lib/nrser/collection/map_spec.rb
361
- - spec/lib/nrser/env/path/insert_spec.rb
362
- - spec/lib/nrser/env/path_spec.rb
400
+ - spec/lib/nrser/core_ext/binding/erb_spec.rb
401
+ - spec/lib/nrser/core_ext/enumerable/find_map_spec.rb
402
+ - spec/lib/nrser/core_ext/hash_spec.rb
363
403
  - spec/lib/nrser/errors/abstract_method_error_spec.rb
364
- - spec/lib/nrser/functions/binding/template_spec.rb
404
+ - spec/lib/nrser/functions/enumerable/associate_spec.rb
365
405
  - spec/lib/nrser/functions/enumerable/find_all_map_spec.rb
366
406
  - spec/lib/nrser/functions/enumerable/find_bounded_spec.rb
367
- - spec/lib/nrser/functions/enumerable/find_map_spec.rb
368
407
  - spec/lib/nrser/functions/enumerable/find_only_spec.rb
369
408
  - spec/lib/nrser/functions/enumerable/include_slice_spec.rb
370
- - spec/lib/nrser/functions/enumerable/to_h_by_spec.rb
371
409
  - spec/lib/nrser/functions/exception/format_exception_spec.rb
372
410
  - spec/lib/nrser/functions/hash/bury_spec.rb
373
411
  - spec/lib/nrser/functions/hash/guess_label_key_type_spec.rb
374
- - spec/lib/nrser/functions/hash_spec.rb
375
412
  - spec/lib/nrser/functions/merge_by_spec.rb
376
413
  - spec/lib/nrser/functions/object/truthy_spec.rb
377
414
  - spec/lib/nrser/functions/open_struct_spec.rb
378
415
  - spec/lib/nrser/functions/string/common_prefix_spec.rb
379
416
  - spec/lib/nrser/functions/string/looks_like_spec.rb
380
- - spec/lib/nrser/functions/string/truncate_spec.rb
381
417
  - spec/lib/nrser/functions/text/dedent/gotchas_spec.rb
382
418
  - spec/lib/nrser/functions/text/dedent_spec.rb
383
419
  - spec/lib/nrser/functions/text/indent_spec.rb
@@ -388,23 +424,27 @@ files:
388
424
  - spec/lib/nrser/functions/tree/map_tree_spec.rb
389
425
  - spec/lib/nrser/functions/tree/transform_spec.rb
390
426
  - spec/lib/nrser/functions/tree/transformer_spec.rb
427
+ - spec/lib/nrser/gem_ext/hamster/json_spec.rb
391
428
  - spec/lib/nrser/labs/globlin_spec.rb
392
429
  - spec/lib/nrser/labs/index_spec.rb
393
430
  - spec/lib/nrser/mean_streak/design_spec.rb
394
431
  - spec/lib/nrser/mean_streak/identity_instance_spec.rb
395
432
  - spec/lib/nrser/meta/class_attrs_spec.rb
396
- - spec/lib/nrser/meta/props/to_and_from_data_spec.rb
397
- - spec/lib/nrser/meta/props_spec.rb
433
+ - spec/lib/nrser/meta/source/location_spec.rb
398
434
  - spec/lib/nrser/op/message_spec.rb
435
+ - spec/lib/nrser/props/immutable/hash_spec.rb
436
+ - spec/lib/nrser/props/immutable/vector_spec.rb
437
+ - spec/lib/nrser/props/original_props_spec.rb
438
+ - spec/lib/nrser/props/to_and_from_data_spec.rb
399
439
  - spec/lib/nrser/refinements/array_spec.rb
400
440
  - spec/lib/nrser/refinements/erb_spec.rb
401
441
  - spec/lib/nrser/refinements/format_exception_spec.rb
402
- - spec/lib/nrser/refinements/hash_spec.rb
403
442
  - spec/lib/nrser/refinements/indent_spec.rb
404
443
  - spec/lib/nrser/refinements/object_spec.rb
405
444
  - spec/lib/nrser/refinements/pathname_spec.rb
406
445
  - spec/lib/nrser/refinements/set_spec.rb
407
- - spec/lib/nrser/refinements/truncate_spec.rb
446
+ - spec/lib/nrser/sys/env/path/insert_spec.rb
447
+ - spec/lib/nrser/sys/env/path_spec.rb
408
448
  - spec/lib/nrser/types/array_spec.rb
409
449
  - spec/lib/nrser/types/attrs_spec.rb
410
450
  - spec/lib/nrser/types/combinators_spec.rb
@@ -444,29 +484,25 @@ signing_key:
444
484
  specification_version: 4
445
485
  summary: basic ruby utils i use in a lot of stuff.
446
486
  test_files:
447
- - spec/design/mapping_spec.rb
448
487
  - spec/lib/nrser/collection/each_spec.rb
449
488
  - spec/lib/nrser/collection/map_spec.rb
450
- - spec/lib/nrser/env/path/insert_spec.rb
451
- - spec/lib/nrser/env/path_spec.rb
489
+ - spec/lib/nrser/core_ext/binding/erb_spec.rb
490
+ - spec/lib/nrser/core_ext/enumerable/find_map_spec.rb
491
+ - spec/lib/nrser/core_ext/hash_spec.rb
452
492
  - spec/lib/nrser/errors/abstract_method_error_spec.rb
453
- - spec/lib/nrser/functions/binding/template_spec.rb
493
+ - spec/lib/nrser/functions/enumerable/associate_spec.rb
454
494
  - spec/lib/nrser/functions/enumerable/find_all_map_spec.rb
455
495
  - spec/lib/nrser/functions/enumerable/find_bounded_spec.rb
456
- - spec/lib/nrser/functions/enumerable/find_map_spec.rb
457
496
  - spec/lib/nrser/functions/enumerable/find_only_spec.rb
458
497
  - spec/lib/nrser/functions/enumerable/include_slice_spec.rb
459
- - spec/lib/nrser/functions/enumerable/to_h_by_spec.rb
460
498
  - spec/lib/nrser/functions/exception/format_exception_spec.rb
461
499
  - spec/lib/nrser/functions/hash/bury_spec.rb
462
500
  - spec/lib/nrser/functions/hash/guess_label_key_type_spec.rb
463
- - spec/lib/nrser/functions/hash_spec.rb
464
501
  - spec/lib/nrser/functions/merge_by_spec.rb
465
502
  - spec/lib/nrser/functions/object/truthy_spec.rb
466
503
  - spec/lib/nrser/functions/open_struct_spec.rb
467
504
  - spec/lib/nrser/functions/string/common_prefix_spec.rb
468
505
  - spec/lib/nrser/functions/string/looks_like_spec.rb
469
- - spec/lib/nrser/functions/string/truncate_spec.rb
470
506
  - spec/lib/nrser/functions/text/dedent/gotchas_spec.rb
471
507
  - spec/lib/nrser/functions/text/dedent_spec.rb
472
508
  - spec/lib/nrser/functions/text/indent_spec.rb
@@ -477,23 +513,27 @@ test_files:
477
513
  - spec/lib/nrser/functions/tree/map_tree_spec.rb
478
514
  - spec/lib/nrser/functions/tree/transform_spec.rb
479
515
  - spec/lib/nrser/functions/tree/transformer_spec.rb
516
+ - spec/lib/nrser/gem_ext/hamster/json_spec.rb
480
517
  - spec/lib/nrser/labs/globlin_spec.rb
481
518
  - spec/lib/nrser/labs/index_spec.rb
482
519
  - spec/lib/nrser/mean_streak/design_spec.rb
483
520
  - spec/lib/nrser/mean_streak/identity_instance_spec.rb
484
521
  - spec/lib/nrser/meta/class_attrs_spec.rb
485
- - spec/lib/nrser/meta/props/to_and_from_data_spec.rb
486
- - spec/lib/nrser/meta/props_spec.rb
522
+ - spec/lib/nrser/meta/source/location_spec.rb
487
523
  - spec/lib/nrser/op/message_spec.rb
524
+ - spec/lib/nrser/props/immutable/hash_spec.rb
525
+ - spec/lib/nrser/props/immutable/vector_spec.rb
526
+ - spec/lib/nrser/props/original_props_spec.rb
527
+ - spec/lib/nrser/props/to_and_from_data_spec.rb
488
528
  - spec/lib/nrser/refinements/array_spec.rb
489
529
  - spec/lib/nrser/refinements/erb_spec.rb
490
530
  - spec/lib/nrser/refinements/format_exception_spec.rb
491
- - spec/lib/nrser/refinements/hash_spec.rb
492
531
  - spec/lib/nrser/refinements/indent_spec.rb
493
532
  - spec/lib/nrser/refinements/object_spec.rb
494
533
  - spec/lib/nrser/refinements/pathname_spec.rb
495
534
  - spec/lib/nrser/refinements/set_spec.rb
496
- - spec/lib/nrser/refinements/truncate_spec.rb
535
+ - spec/lib/nrser/sys/env/path/insert_spec.rb
536
+ - spec/lib/nrser/sys/env/path_spec.rb
497
537
  - spec/lib/nrser/types/array_spec.rb
498
538
  - spec/lib/nrser/types/attrs_spec.rb
499
539
  - spec/lib/nrser/types/combinators_spec.rb
@@ -1,36 +0,0 @@
1
- # Extension methods for {Binding}
2
- #
3
- module NRSER::Ext::Binding
4
-
5
- # Calls {NRSER.template} with `self` prepended to `*args`
6
- #
7
- # @param (see NRSER.erb)
8
- # @return (see NRSER.erb)
9
- #
10
- def template *args
11
- NRSER.template self, *args
12
- end
13
-
14
- alias_method :erb, :template
15
-
16
-
17
- # Calls {NRSER.locals} with `self` prepended to `*args`
18
- #
19
- # @param (see NRSER.locals)
20
- # @return (see NRSER.locals)
21
- #
22
- def locals *args
23
- NRSER.locals self, *args
24
- end
25
-
26
-
27
- # Calls {NRSER.local_values} with `self` prepended to `*args`
28
- #
29
- # @param (see NRSER.local_values)
30
- # @return (see NRSER.local_values)
31
- #
32
- def local_values *args
33
- NRSER.local_values self, *args
34
- end
35
-
36
- end # module NRSER::Ext::Binding
@@ -1,62 +0,0 @@
1
- # Extension methods for {Module}
2
- #
3
- # @note
4
- # These **must not** conflict with function names, which are of course
5
- # also module methods on the {NRSER} module, because they will override
6
- # them and prevent access to the functions.
7
- #
8
- # Hence the target functions have been prefixed with `f_`.
9
- #
10
- module NRSER::Ext::Module
11
-
12
- # @!group Module Methods
13
- # ==========================================================================
14
-
15
- # Calls {NRSER.class_method_objects_for} with `self` as first arg.
16
- def class_method_objects *args
17
- NRSER.class_method_objects_for self, *args
18
- end
19
-
20
- alias_method :class_Methods, :class_method_objects
21
-
22
-
23
- # Calls {NRSER.own_class_method_objects_for} with `self` as first arg.
24
- def own_class_method_objects *args
25
- NRSER.own_class_method_objects_for self, *args
26
- end
27
-
28
- alias_method :own_class_Methods, :own_class_method_objects
29
-
30
-
31
- # Calls {NRSER.instance_method_objects_for} with `self` as first arg.
32
- def instance_method_objects *args
33
- NRSER.instance_method_objects_for self, *args
34
- end
35
-
36
- alias_method :instance_Methods, :instance_method_objects
37
-
38
-
39
- # Calls {NRSER.own_instance_method_objects_for} with `self` as first arg.
40
- def own_instance_method_objects *args
41
- NRSER.own_instance_method_objects_for self, *args
42
- end
43
-
44
- alias_method :own_instance_Methods, :own_instance_method_objects
45
-
46
-
47
- # Calls {NRSER.class_method_source_locations_for} with `self` as the
48
- # first arg.
49
- def class_method_source_locations *args
50
- NRSER.class_method_source_locations_for self, *args
51
- end
52
-
53
-
54
- # Calls {NRSER.class_method_source_locations_for} with `self` as the
55
- # first arg.
56
- def own_class_method_source_locations *args
57
- NRSER.own_class_method_source_locations_for self, *args
58
- end
59
-
60
- # @!endgroup Module Methods
61
-
62
- end # module NRSER::Ext::String
data/lib/nrser/ext.rb DELETED
@@ -1,8 +0,0 @@
1
- module NRSER::Ext; end
2
-
3
- require_relative './ext/enumerable'
4
- require_relative './ext/tree'
5
- require_relative './ext/pathname'
6
- require_relative './ext/string'
7
- require_relative './ext/binding'
8
- require_relative './ext/module'
@@ -1,76 +0,0 @@
1
- module NRSER
2
- def self.erb bnd, str
3
- require 'erb'
4
-
5
- filter_repeated_blank_lines(
6
- with_indent_tagged( dedent( str ) ) { |tagged_str|
7
- ERB.new( tagged_str ).result( bnd )
8
- },
9
- remove_leading: true
10
- )
11
- end # erb
12
-
13
- singleton_class.send :alias_method, :template, :erb
14
-
15
-
16
- # Get a {Hash} of all local variable names (as {Symbol}) to values.
17
- #
18
- # @param [Binding] bnd
19
- # Binding to get locals from.
20
- #
21
- # @return [Hash<Symbol, Object>]
22
- #
23
- def self.locals bnd
24
- NRSER.map_values( bnd.local_variables ) { |symbol, _|
25
- bnd.local_variable_get symbol
26
- }
27
- end # .locals
28
-
29
-
30
- # Get a {Array} of all local variable values.
31
- #
32
- # Written to facilitate checks like "all argument values are not `nil`".
33
- #
34
- # @param [Binding] bnd
35
- # Binding to get locals from.
36
- #
37
- # @return [Array<Object>]
38
- #
39
- def self.local_values bnd
40
- bnd.local_variables.map { |symbol| bnd.local_variable_get symbol }
41
- end # .locals
42
-
43
-
44
- def self.call_block bnd, *args, &block
45
- arg_count = 0
46
- arg_rest = false
47
- call_kwds = {}
48
- block.parameters.each do |type, name|
49
- logger.debug "Processing", type: type, name: name
50
-
51
- case type
52
- when :req, :opt
53
- arg_count += 1
54
- when :keyreq, :key
55
- if bnd.local_variable_defined? name
56
- call_kwds[name] = bnd.local_variable_get name
57
- end
58
- when :rest
59
- arg_rest = true
60
- end
61
- end
62
-
63
- call_args = if arg_rest
64
- args
65
- else
66
- args[0...arg_count]
67
- end
68
-
69
- logger.debug "CALLING WITH",
70
- args: call_args,
71
- kwds: call_kwds
72
-
73
- block.call *call_args, **call_kwds
74
- end
75
-
76
- end # module NRSER
File without changes
@@ -1,94 +0,0 @@
1
- module NRSER
2
-
3
- # Maps an enumerable object to a *new* hash with the same keys and values
4
- # obtained by calling `block` with the current key and value.
5
- #
6
- # If `enumerable` *does not* respond to `#to_pairs` then it's
7
- # treated as a hash where the elements iterated by `#each` are it's keys
8
- # and all it's values are `nil`.
9
- #
10
- # In this way, {NRSER.map_values} handles Hash, Array, Set, OpenStruct,
11
- # and probably pretty much anything else reasonable you may throw at it.
12
- #
13
- # @param [#each_pair, #each] enum
14
- #
15
- # @yieldparam [Object] key
16
- # The key that will be used for whatever value the block returns in the
17
- # new hash.
18
- #
19
- # @yieldparam [nil, Object] value
20
- # If `enumerable` responds to `#each_pair`, the second parameter it yielded
21
- # along with `key`. Otherwise `nil`.
22
- #
23
- # @yieldreturn [Object]
24
- # Value for the new hash.
25
- #
26
- # @return [Hash]
27
- #
28
- # @raise [ArgumentError]
29
- # If `enumerable` does not respond to `#each_pair` or `#each`.
30
- #
31
-
32
- # Kind-of a Swiss Army knife for "I have the keys right, but I need to do
33
- # some work to get the values I want".
34
- #
35
- # @overload map_values hash, &block
36
- #
37
- # Maps `hash` (which doesn't need to be a {Hash}, just support
38
- # `#each_pair` in the same way) to a new {Hash} with the same keys and
39
- # values created by calling `&block`.
40
- #
41
- # The arguments yielded to `&block` depend it's `#arity`:
42
- #
43
- # 1. If `&block` has more than one required argument
44
- # (`block.arity > 1 || block.arity < -2`) then `key` and `value`
45
- # will be yielded, so this works:
46
- #
47
- # NRSER.map_values( hash ) { |key, value| ... }
48
- #
49
- # 2. If `&block` has one required argument or less
50
- # (`-2 <= block.arity <= 1`) then just `value` is yielded, so this
51
- # also works:
52
- #
53
- # NRSER.map_values( hash ) { |value| ... }
54
- #
55
- # @overload map_values enumerable, &block
56
- #
57
- def self.map_values enum, &block
58
- result = {}
59
-
60
- arity = block.arity
61
-
62
- if enum.respond_to? :each_pair
63
- enum.each_pair { |key, value|
64
- result[key] = if arity > 1 || arity < -2
65
- block.call key, value
66
- else
67
- block.call value
68
- end
69
- }
70
- elsif enum.respond_to? :each
71
- value = nil
72
- enum.each_with_index { |key, index|
73
- result[key] = if arity > 1 || arity < -2
74
- block.call key, nil
75
- else
76
- block.call key
77
- end
78
- }
79
- else
80
- raise ArgumentError.new erb binding, <<-END
81
- First argument to {NRSER.map_values} must respond to #each_pair or #each
82
-
83
- Received
84
-
85
- <%= enum.pretty_inspect %>
86
-
87
- of class <%= enum.class %>
88
- END
89
- end
90
-
91
- result
92
- end # .map_values
93
-
94
- end # module NRSER
@@ -1,57 +0,0 @@
1
- # Definitions
2
- # =======================================================================
3
-
4
- module NRSER
5
-
6
- # @!group Hash Functions
7
-
8
- # Returns a new hash created by recursively merging `other_hash` on top of
9
- # `base_hash`.
10
- #
11
- # Adapted from ActiveSupport.
12
- #
13
- # @see https://github.com/rails/rails/blob/23c8f6918d4e6b9a823aa7a91377c6e3b5d60e13/activesupport/lib/active_support/core_ext/hash/deep_merge.rb
14
- #
15
- # @param [Hash] base_hash
16
- # Base hash - it's values will be overwritten by any key paths shared with
17
- # the other hash.
18
- #
19
- # @param [Hash] other_hash
20
- # "Update" hash - it's values will overwrite values at the same key path
21
- # in the base hash.
22
- #
23
- # I don't love the name; just went with what ActiveSupport used.
24
- #
25
- # @return [Hash]
26
- # New merged hash.
27
- #
28
- def self.deep_merge base_hash, other_hash, &block
29
- deep_merge! base_hash.dup, other_hash, &block
30
- end # .deep_merge
31
-
32
-
33
- # Same as {.deep_merge}, but modifies `base_hash`.
34
- #
35
- # @return [Hash]
36
- # The mutated base hash.
37
- #
38
- def self.deep_merge! base_hash, other_hash, &block
39
- other_hash.each_pair do |current_key, other_value|
40
- this_value = base_hash[current_key]
41
-
42
- base_hash[current_key] = if this_value.is_a?(Hash) &&
43
- other_value.is_a?(Hash)
44
- deep_merge this_value, other_value, &block
45
- else
46
- if block_given? && base_hash.key?( current_key )
47
- block.call(current_key, this_value, other_value)
48
- else
49
- other_value
50
- end
51
- end
52
- end
53
-
54
- base_hash
55
- end
56
-
57
- end # module NRSER