nrser 0.0.25 → 0.0.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +39 -11
  3. data/lib/nrser.rb +5 -1
  4. data/lib/nrser/array.rb +10 -53
  5. data/lib/nrser/enumerable.rb +21 -0
  6. data/lib/nrser/hash.rb +13 -476
  7. data/lib/nrser/hash/bury.rb +154 -0
  8. data/lib/nrser/hash/deep_merge.rb +57 -0
  9. data/lib/nrser/hash/except_keys.rb +42 -0
  10. data/lib/nrser/hash/guess_label_key_type.rb +37 -0
  11. data/lib/nrser/hash/slice_keys.rb +41 -0
  12. data/lib/nrser/hash/stringify_keys.rb +37 -0
  13. data/lib/nrser/hash/symbolize_keys.rb +41 -0
  14. data/lib/nrser/hash/transform_keys.rb +45 -0
  15. data/lib/nrser/merge_by.rb +26 -0
  16. data/lib/nrser/message.rb +125 -0
  17. data/lib/nrser/meta/props.rb +2 -2
  18. data/lib/nrser/meta/props/prop.rb +5 -2
  19. data/lib/nrser/object.rb +5 -0
  20. data/lib/nrser/object/as_array.rb +37 -0
  21. data/lib/nrser/object/as_hash.rb +101 -0
  22. data/lib/nrser/{truthy.rb → object/truthy.rb} +0 -0
  23. data/lib/nrser/proc.rb +132 -0
  24. data/lib/nrser/refinements.rb +1 -2
  25. data/lib/nrser/refinements/array.rb +94 -5
  26. data/lib/nrser/refinements/enumerable.rb +5 -0
  27. data/lib/nrser/refinements/hash.rb +43 -6
  28. data/lib/nrser/refinements/object.rb +22 -2
  29. data/lib/nrser/refinements/symbol.rb +12 -0
  30. data/lib/nrser/refinements/tree.rb +41 -0
  31. data/lib/nrser/rspex.rb +329 -0
  32. data/lib/nrser/string.rb +3 -0
  33. data/lib/nrser/string/looks_like.rb +51 -0
  34. data/lib/nrser/temp/where.rb +52 -0
  35. data/lib/nrser/tree.rb +86 -0
  36. data/lib/nrser/tree/leaves.rb +92 -0
  37. data/lib/nrser/tree/map_leaves.rb +63 -0
  38. data/lib/nrser/tree/transform.rb +30 -0
  39. data/lib/nrser/types.rb +9 -4
  40. data/lib/nrser/types/any.rb +1 -1
  41. data/lib/nrser/types/array.rb +167 -25
  42. data/lib/nrser/types/{hash.rb → hashes.rb} +19 -5
  43. data/lib/nrser/types/in.rb +47 -0
  44. data/lib/nrser/types/is_a.rb +2 -2
  45. data/lib/nrser/types/labels.rb +49 -0
  46. data/lib/nrser/types/numbers.rb +63 -27
  47. data/lib/nrser/types/pairs.rb +109 -0
  48. data/lib/nrser/types/responds.rb +2 -3
  49. data/lib/nrser/types/strings.rb +17 -18
  50. data/lib/nrser/types/symbols.rb +39 -0
  51. data/lib/nrser/types/trees.rb +93 -0
  52. data/lib/nrser/types/tuples.rb +116 -0
  53. data/lib/nrser/types/type.rb +26 -2
  54. data/lib/nrser/version.rb +1 -1
  55. data/spec/nrser/hash/{guess_name_type_spec.rb → guess_label_key_type_spec.rb} +3 -3
  56. data/spec/nrser/hash_spec.rb +0 -20
  57. data/spec/nrser/merge_by_spec.rb +73 -0
  58. data/spec/nrser/meta/props_spec.rb +136 -43
  59. data/spec/nrser/op/message_spec.rb +62 -0
  60. data/spec/nrser/refinements/array_spec.rb +36 -0
  61. data/spec/nrser/refinements/hash_spec.rb +34 -0
  62. data/spec/nrser/string/looks_like_spec.rb +31 -0
  63. data/spec/nrser/tree/each_branch_spec.rb +82 -0
  64. data/spec/nrser/tree/leaves_spec.rb +112 -0
  65. data/spec/nrser/tree/transform_spec.rb +165 -0
  66. data/spec/nrser/types/array_spec.rb +82 -0
  67. data/spec/nrser/types/attrs_spec.rb +4 -4
  68. data/spec/nrser/types/pairs_spec.rb +41 -0
  69. data/spec/nrser/types/paths_spec.rb +3 -3
  70. data/spec/nrser/types/strings_spec.rb +66 -0
  71. data/spec/nrser/types/symbols_spec.rb +38 -0
  72. data/spec/nrser/types/tuples_spec.rb +37 -0
  73. data/spec/nrser/types_spec.rb +0 -13
  74. data/spec/spec_helper.rb +71 -22
  75. metadata +58 -10
  76. data/lib/nrser/spex.rb +0 -68
  77. data/lib/nrser/types/symbol.rb +0 -23
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.0.25
4
+ version: 0.0.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - nrser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-08 00:00:00.000000000 Z
11
+ date: 2017-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -139,14 +139,29 @@ files:
139
139
  - lib/nrser/errors.rb
140
140
  - lib/nrser/exception.rb
141
141
  - lib/nrser/hash.rb
142
+ - lib/nrser/hash/bury.rb
143
+ - lib/nrser/hash/deep_merge.rb
144
+ - lib/nrser/hash/except_keys.rb
145
+ - lib/nrser/hash/guess_label_key_type.rb
146
+ - lib/nrser/hash/slice_keys.rb
147
+ - lib/nrser/hash/stringify_keys.rb
148
+ - lib/nrser/hash/symbolize_keys.rb
149
+ - lib/nrser/hash/transform_keys.rb
142
150
  - lib/nrser/logger.rb
151
+ - lib/nrser/merge_by.rb
152
+ - lib/nrser/message.rb
143
153
  - lib/nrser/meta.rb
144
154
  - lib/nrser/meta/class_attrs.rb
145
155
  - lib/nrser/meta/props.rb
146
156
  - lib/nrser/meta/props/base.rb
147
157
  - lib/nrser/meta/props/prop.rb
148
158
  - lib/nrser/no_arg.rb
159
+ - lib/nrser/object.rb
160
+ - lib/nrser/object/as_array.rb
161
+ - lib/nrser/object/as_hash.rb
162
+ - lib/nrser/object/truthy.rb
149
163
  - lib/nrser/open_struct.rb
164
+ - lib/nrser/proc.rb
150
165
  - lib/nrser/refinements.rb
151
166
  - lib/nrser/refinements/array.rb
152
167
  - lib/nrser/refinements/binding.rb
@@ -159,10 +174,17 @@ files:
159
174
  - lib/nrser/refinements/pathname.rb
160
175
  - lib/nrser/refinements/set.rb
161
176
  - lib/nrser/refinements/string.rb
177
+ - lib/nrser/refinements/symbol.rb
178
+ - lib/nrser/refinements/tree.rb
162
179
  - lib/nrser/refinements/types.rb
163
- - lib/nrser/spex.rb
180
+ - lib/nrser/rspex.rb
164
181
  - lib/nrser/string.rb
165
- - lib/nrser/truthy.rb
182
+ - lib/nrser/string/looks_like.rb
183
+ - lib/nrser/temp/where.rb
184
+ - lib/nrser/tree.rb
185
+ - lib/nrser/tree/leaves.rb
186
+ - lib/nrser/tree/map_leaves.rb
187
+ - lib/nrser/tree/transform.rb
166
188
  - lib/nrser/types.rb
167
189
  - lib/nrser/types/any.rb
168
190
  - lib/nrser/types/array.rb
@@ -170,15 +192,20 @@ files:
170
192
  - lib/nrser/types/booleans.rb
171
193
  - lib/nrser/types/bounded.rb
172
194
  - lib/nrser/types/combinators.rb
173
- - lib/nrser/types/hash.rb
195
+ - lib/nrser/types/hashes.rb
196
+ - lib/nrser/types/in.rb
174
197
  - lib/nrser/types/is.rb
175
198
  - lib/nrser/types/is_a.rb
199
+ - lib/nrser/types/labels.rb
176
200
  - lib/nrser/types/maybe.rb
177
201
  - lib/nrser/types/numbers.rb
202
+ - lib/nrser/types/pairs.rb
178
203
  - lib/nrser/types/paths.rb
179
204
  - lib/nrser/types/responds.rb
180
205
  - lib/nrser/types/strings.rb
181
- - lib/nrser/types/symbol.rb
206
+ - lib/nrser/types/symbols.rb
207
+ - lib/nrser/types/trees.rb
208
+ - lib/nrser/types/tuples.rb
182
209
  - lib/nrser/types/type.rb
183
210
  - lib/nrser/types/where.rb
184
211
  - lib/nrser/version.rb
@@ -189,7 +216,7 @@ files:
189
216
  - spec/nrser/enumerable_spec.rb
190
217
  - spec/nrser/format_exception_spec.rb
191
218
  - spec/nrser/hash/bury_spec.rb
192
- - spec/nrser/hash/guess_name_type_spec.rb
219
+ - spec/nrser/hash/guess_label_key_type_spec.rb
193
220
  - spec/nrser/hash_spec.rb
194
221
  - spec/nrser/indent_spec.rb
195
222
  - spec/nrser/logger/dest_spec.rb
@@ -200,8 +227,10 @@ files:
200
227
  - spec/nrser/logger/level_sym_spec.rb
201
228
  - spec/nrser/logger/send_log_spec.rb
202
229
  - spec/nrser/logger/use_spec.rb
230
+ - spec/nrser/merge_by_spec.rb
203
231
  - spec/nrser/meta/class_attrs_spec.rb
204
232
  - spec/nrser/meta/props_spec.rb
233
+ - spec/nrser/op/message_spec.rb
205
234
  - spec/nrser/open_struct_spec.rb
206
235
  - spec/nrser/refinements/array_spec.rb
207
236
  - spec/nrser/refinements/erb_spec.rb
@@ -212,13 +241,22 @@ files:
212
241
  - spec/nrser/refinements/pathname_spec.rb
213
242
  - spec/nrser/refinements/set_spec.rb
214
243
  - spec/nrser/refinements/truncate_spec.rb
244
+ - spec/nrser/string/looks_like_spec.rb
215
245
  - spec/nrser/template_spec.rb
246
+ - spec/nrser/tree/each_branch_spec.rb
247
+ - spec/nrser/tree/leaves_spec.rb
248
+ - spec/nrser/tree/transform_spec.rb
216
249
  - spec/nrser/truncate_spec.rb
217
250
  - spec/nrser/truthy_spec.rb
251
+ - spec/nrser/types/array_spec.rb
218
252
  - spec/nrser/types/attrs_spec.rb
219
253
  - spec/nrser/types/combinators_spec.rb
220
254
  - spec/nrser/types/is_spec.rb
255
+ - spec/nrser/types/pairs_spec.rb
221
256
  - spec/nrser/types/paths_spec.rb
257
+ - spec/nrser/types/strings_spec.rb
258
+ - spec/nrser/types/symbols_spec.rb
259
+ - spec/nrser/types/tuples_spec.rb
222
260
  - spec/nrser/types_spec.rb
223
261
  - spec/nrser_spec.rb
224
262
  - spec/spec_helper.rb
@@ -242,7 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
242
280
  version: '0'
243
281
  requirements: []
244
282
  rubyforge_project:
245
- rubygems_version: 2.6.11
283
+ rubygems_version: 2.5.2
246
284
  signing_key:
247
285
  specification_version: 4
248
286
  summary: basic ruby utils i use in a lot of stuff.
@@ -254,7 +292,7 @@ test_files:
254
292
  - spec/nrser/enumerable_spec.rb
255
293
  - spec/nrser/format_exception_spec.rb
256
294
  - spec/nrser/hash/bury_spec.rb
257
- - spec/nrser/hash/guess_name_type_spec.rb
295
+ - spec/nrser/hash/guess_label_key_type_spec.rb
258
296
  - spec/nrser/hash_spec.rb
259
297
  - spec/nrser/indent_spec.rb
260
298
  - spec/nrser/logger/dest_spec.rb
@@ -265,8 +303,10 @@ test_files:
265
303
  - spec/nrser/logger/level_sym_spec.rb
266
304
  - spec/nrser/logger/send_log_spec.rb
267
305
  - spec/nrser/logger/use_spec.rb
306
+ - spec/nrser/merge_by_spec.rb
268
307
  - spec/nrser/meta/class_attrs_spec.rb
269
308
  - spec/nrser/meta/props_spec.rb
309
+ - spec/nrser/op/message_spec.rb
270
310
  - spec/nrser/open_struct_spec.rb
271
311
  - spec/nrser/refinements/array_spec.rb
272
312
  - spec/nrser/refinements/erb_spec.rb
@@ -277,14 +317,22 @@ test_files:
277
317
  - spec/nrser/refinements/pathname_spec.rb
278
318
  - spec/nrser/refinements/set_spec.rb
279
319
  - spec/nrser/refinements/truncate_spec.rb
320
+ - spec/nrser/string/looks_like_spec.rb
280
321
  - spec/nrser/template_spec.rb
322
+ - spec/nrser/tree/each_branch_spec.rb
323
+ - spec/nrser/tree/leaves_spec.rb
324
+ - spec/nrser/tree/transform_spec.rb
281
325
  - spec/nrser/truncate_spec.rb
282
326
  - spec/nrser/truthy_spec.rb
327
+ - spec/nrser/types/array_spec.rb
283
328
  - spec/nrser/types/attrs_spec.rb
284
329
  - spec/nrser/types/combinators_spec.rb
285
330
  - spec/nrser/types/is_spec.rb
331
+ - spec/nrser/types/pairs_spec.rb
286
332
  - spec/nrser/types/paths_spec.rb
333
+ - spec/nrser/types/strings_spec.rb
334
+ - spec/nrser/types/symbols_spec.rb
335
+ - spec/nrser/types/tuples_spec.rb
287
336
  - spec/nrser/types_spec.rb
288
337
  - spec/nrser_spec.rb
289
338
  - spec/spec_helper.rb
290
- has_rdoc:
data/lib/nrser/spex.rb DELETED
@@ -1,68 +0,0 @@
1
- ##############################################################################
2
- # RSpec helpers, shared examples, and other goodies.
3
- #
4
- # This file is *not* required by default when `nrser` is since it **defines
5
- # global methods** and is not needed unless you're in [Rspec][].
6
- #
7
- # [Rspec]: http://rspec.info/
8
- #
9
- ##############################################################################
10
-
11
-
12
- # Helpers
13
- # =====================================================================
14
-
15
- # Merge "expectation" hashes by appending all clauses for each state.
16
- #
17
- # @example
18
- #
19
- #
20
- # @param [Array<Hash>] *expectations
21
- # Splat of "expectation" hashes - see the examples.
22
- #
23
- def merge_expectations *expectations
24
- Hash.new { |result, state|
25
- result[state] = []
26
- }.tap { |result|
27
- expectations.each { |ex|
28
- ex.each { |state, clauses|
29
- result[state] += clauses.to_a
30
- }
31
- }
32
- }
33
- end
34
-
35
-
36
- # Refine the subject of the parent scope by `#send`ing it a message and setting
37
- # the result as the new subject.
38
- #
39
- # @param [Symbol | String] method_name
40
- # Name of the method to send to.
41
- #
42
- # @param [Array] args*
43
- # Arguments to send to the method.
44
- #
45
- # @return [void]
46
- # Seems to be what RSpec's `subject` method returns.
47
- #
48
- def refine_subject method_name, *args
49
- subject {
50
- super().send method_name, *args
51
- }
52
- end # #refine_subject
53
-
54
-
55
- # Shared Examples
56
- # =====================================================================
57
-
58
- shared_examples "expect subject" do |*expectations|
59
- merge_expectations( *expectations ).each { |state, specs|
60
- specs.each { |verb, noun|
61
- it {
62
- # like: is_expected.to(include(noun))
63
- is_expected.send state, self.send(verb, noun)
64
- }
65
- }
66
- }
67
- end # is expected
68
-
@@ -1,23 +0,0 @@
1
- require 'nrser/refinements'
2
- require 'nrser/types/is'
3
- require 'nrser/types/is_a'
4
-
5
- using NRSER
6
-
7
- module NRSER::Types
8
- SYM = IsA.new Symbol, name: 'Sym', from_s: ->(s) { s.to_sym }
9
-
10
- def self.sym **options
11
- if options.empty?
12
- # if there are no options can point to the constant for efficiency
13
- SYM
14
- else
15
- raise "Not Implemented"
16
- end
17
- end # string
18
-
19
- def self.symbol *args
20
- sym *args
21
- end
22
-
23
- end # NRSER::Types