monolens 0.5.2 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +51 -84
  3. data/lib/monolens/command/tester.rb +95 -0
  4. data/lib/monolens/command.rb +137 -18
  5. data/lib/monolens/error.rb +2 -0
  6. data/lib/monolens/file.rb +11 -0
  7. data/lib/monolens/jsonpath.rb +76 -0
  8. data/lib/monolens/lens/options.rb +26 -12
  9. data/lib/monolens/lens/signature/missing.rb +11 -0
  10. data/lib/monolens/lens/signature.rb +60 -0
  11. data/lib/monolens/lens.rb +25 -4
  12. data/lib/monolens/macros.rb +28 -0
  13. data/lib/monolens/namespace.rb +11 -0
  14. data/lib/monolens/registry.rb +77 -0
  15. data/lib/monolens/{array → stdlib/array}/compact.rb +2 -0
  16. data/lib/monolens/{array → stdlib/array}/join.rb +4 -0
  17. data/lib/monolens/{array → stdlib/array}/map.rb +13 -19
  18. data/lib/monolens/{array.rb → stdlib/array.rb} +8 -6
  19. data/lib/monolens/{check → stdlib/check}/not_empty.rb +4 -0
  20. data/lib/monolens/{check.rb → stdlib/check.rb} +4 -2
  21. data/lib/monolens/{coerce → stdlib/coerce}/date.rb +5 -0
  22. data/lib/monolens/{coerce → stdlib/coerce}/date_time.rb +6 -1
  23. data/lib/monolens/{coerce → stdlib/coerce}/integer.rb +4 -0
  24. data/lib/monolens/{coerce → stdlib/coerce}/string.rb +2 -0
  25. data/lib/monolens/{coerce.rb → stdlib/coerce.rb} +10 -8
  26. data/lib/monolens/{core → stdlib/core}/chain.rb +5 -3
  27. data/lib/monolens/{core → stdlib/core}/dig.rb +5 -0
  28. data/lib/monolens/stdlib/core/literal.rb +68 -0
  29. data/lib/monolens/{core → stdlib/core}/mapping.rb +15 -5
  30. data/lib/monolens/stdlib/core.rb +31 -0
  31. data/lib/monolens/stdlib/object/allbut.rb +22 -0
  32. data/lib/monolens/{object → stdlib/object}/extend.rb +10 -5
  33. data/lib/monolens/{object → stdlib/object}/keys.rb +4 -0
  34. data/lib/monolens/stdlib/object/merge.rb +56 -0
  35. data/lib/monolens/{object → stdlib/object}/rename.rb +5 -1
  36. data/lib/monolens/{object → stdlib/object}/select.rb +9 -0
  37. data/lib/monolens/{object → stdlib/object}/transform.rb +8 -3
  38. data/lib/monolens/{object → stdlib/object}/values.rb +9 -4
  39. data/lib/monolens/stdlib/object.rb +55 -0
  40. data/lib/monolens/{skip → stdlib/skip}/null.rb +2 -0
  41. data/lib/monolens/{skip.rb → stdlib/skip.rb} +4 -2
  42. data/lib/monolens/{str → stdlib/str}/downcase.rb +2 -0
  43. data/lib/monolens/{str → stdlib/str}/split.rb +5 -1
  44. data/lib/monolens/{str → stdlib/str}/strip.rb +2 -0
  45. data/lib/monolens/{str → stdlib/str}/upcase.rb +2 -0
  46. data/lib/monolens/{str.rb → stdlib/str.rb} +10 -8
  47. data/lib/monolens/stdlib.rb +7 -0
  48. data/lib/monolens/type/any.rb +39 -0
  49. data/lib/monolens/type/array.rb +27 -0
  50. data/lib/monolens/type/boolean.rb +17 -0
  51. data/lib/monolens/type/callback.rb +17 -0
  52. data/lib/monolens/type/coercible.rb +10 -0
  53. data/lib/monolens/type/diggable.rb +9 -0
  54. data/lib/monolens/type/emptyable.rb +9 -0
  55. data/lib/monolens/type/integer.rb +18 -0
  56. data/lib/monolens/type/lenses.rb +17 -0
  57. data/lib/monolens/type/map.rb +30 -0
  58. data/lib/monolens/type/object.rb +17 -0
  59. data/lib/monolens/type/responding.rb +25 -0
  60. data/lib/monolens/type/strategy.rb +56 -0
  61. data/lib/monolens/type/string.rb +18 -0
  62. data/lib/monolens/type/symbol.rb +20 -0
  63. data/lib/monolens/type.rb +33 -0
  64. data/lib/monolens/version.rb +2 -2
  65. data/lib/monolens.rb +22 -66
  66. data/spec/fixtures/macro.yml +13 -0
  67. data/spec/fixtures/recursive.yml +15 -0
  68. data/spec/monolens/command/literal.yml +2 -0
  69. data/spec/monolens/command/literal2.yml +2 -0
  70. data/spec/monolens/command/test-ko-complex.yml +15 -0
  71. data/spec/monolens/command/test-ko.lens.yml +13 -0
  72. data/spec/monolens/command/test-ok.lens.yml +9 -0
  73. data/spec/monolens/command/upcase.lens.yml +4 -0
  74. data/spec/monolens/lens/test_options.rb +2 -14
  75. data/spec/monolens/lens/test_signature.rb +38 -0
  76. data/spec/monolens/{array → stdlib/array}/test_compact.rb +8 -0
  77. data/spec/monolens/{array → stdlib/array}/test_join.rb +0 -0
  78. data/spec/monolens/{array → stdlib/array}/test_map.rb +15 -0
  79. data/spec/monolens/{check → stdlib/check}/test_not_empty.rb +0 -0
  80. data/spec/monolens/{coerce → stdlib/coerce}/test_date.rb +0 -0
  81. data/spec/monolens/{coerce → stdlib/coerce}/test_datetime.rb +1 -1
  82. data/spec/monolens/{coerce → stdlib/coerce}/test_integer.rb +0 -0
  83. data/spec/monolens/{coerce → stdlib/coerce}/test_string.rb +0 -0
  84. data/spec/monolens/{core → stdlib/core}/test_dig.rb +0 -0
  85. data/spec/monolens/stdlib/core/test_literal.rb +73 -0
  86. data/spec/monolens/{core → stdlib/core}/test_mapping.rb +37 -1
  87. data/spec/monolens/stdlib/object/test_allbut.rb +31 -0
  88. data/spec/monolens/{object → stdlib/object}/test_extend.rb +0 -0
  89. data/spec/monolens/{object → stdlib/object}/test_keys.rb +0 -0
  90. data/spec/monolens/stdlib/object/test_merge.rb +133 -0
  91. data/spec/monolens/{object → stdlib/object}/test_rename.rb +0 -0
  92. data/spec/monolens/{object → stdlib/object}/test_select.rb +0 -0
  93. data/spec/monolens/{object → stdlib/object}/test_transform.rb +0 -0
  94. data/spec/monolens/{object → stdlib/object}/test_values.rb +0 -0
  95. data/spec/monolens/{skip → stdlib/skip}/test_null.rb +0 -0
  96. data/spec/monolens/{str → stdlib/str}/test_downcase.rb +0 -0
  97. data/spec/monolens/{str → stdlib/str}/test_split.rb +0 -0
  98. data/spec/monolens/{str → stdlib/str}/test_strip.rb +0 -0
  99. data/spec/monolens/{str → stdlib/str}/test_upcase.rb +0 -0
  100. data/spec/monolens/test_command.rb +179 -1
  101. data/spec/monolens/test_error_traceability.rb +1 -1
  102. data/spec/monolens/test_jsonpath.rb +88 -0
  103. data/spec/monolens/test_lens.rb +1 -1
  104. data/spec/test_documentation.rb +52 -0
  105. data/spec/test_monolens.rb +20 -0
  106. data/tasks/test.rake +1 -1
  107. metadata +124 -55
  108. data/lib/monolens/core.rb +0 -23
  109. data/lib/monolens/object.rb +0 -41
File without changes
@@ -37,6 +37,10 @@ module Monolens
37
37
  [FIXTURES/'map-upcase.lens.yml', FIXTURES/'names.json']
38
38
  end
39
39
 
40
+ let(:skip_before) do
41
+ false
42
+ end
43
+
40
44
  subject do
41
45
  begin
42
46
  command.call
@@ -45,6 +49,8 @@ module Monolens
45
49
  end
46
50
 
47
51
  before do
52
+ next if skip_before
53
+
48
54
  subject
49
55
  end
50
56
 
@@ -56,6 +62,10 @@ module Monolens
56
62
  JSON.parse(stdout.string)
57
63
  end
58
64
 
65
+ def reloaded_yaml
66
+ YAML.load(stdout.string)
67
+ end
68
+
59
69
  context 'with no option nor args' do
60
70
  let(:argv) do
61
71
  []
@@ -89,6 +99,47 @@ module Monolens
89
99
  end
90
100
  end
91
101
 
102
+ context 'when overriding the input file' do
103
+ let(:argv) do
104
+ ['--override', FIXTURES/'map-upcase.lens.yml', FIXTURES/'overrides.json']
105
+ end
106
+
107
+ let(:skip_before) do
108
+ true
109
+ end
110
+
111
+ before do
112
+ (FIXTURES/'overrides.json').write((FIXTURES/'names.json').read)
113
+ subject
114
+ end
115
+
116
+ it 'works as expected' do
117
+ expect(exit_status).to be_nil
118
+ expect(stdout.string).to be_empty
119
+ expect((FIXTURES/'overrides.json').load).to eql(['BERNARD', 'DAVID'])
120
+ end
121
+ end
122
+
123
+ context 'with --stdin instead of a file' do
124
+ let(:argv) do
125
+ ['--stdin', FIXTURES/'map-upcase.lens.yml']
126
+ end
127
+
128
+ let(:skip_before) do
129
+ true
130
+ end
131
+
132
+ before do
133
+ expect(command).to receive(:read_input).and_return((FIXTURES/'names.json').load)
134
+ subject
135
+ end
136
+
137
+ it 'works as expected' do
138
+ expect(exit_status).to be_nil
139
+ expect(reloaded_json).to eql(['BERNARD', 'DAVID'])
140
+ end
141
+ end
142
+
92
143
  context 'with --pretty' do
93
144
  let(:argv) do
94
145
  ['--pretty'] + file_args
@@ -101,18 +152,145 @@ module Monolens
101
152
  end
102
153
  end
103
154
 
155
+ context 'with --json' do
156
+ let(:argv) do
157
+ ['--json'] + file_args
158
+ end
159
+
160
+ it 'works as expected' do
161
+ expect(exit_status).to be_nil
162
+ expect(reloaded_json).to eql(['BERNARD', 'DAVID'])
163
+ end
164
+ end
165
+
166
+ context 'with --yaml' do
167
+ let(:argv) do
168
+ ['--yaml'] + file_args
169
+ end
170
+
171
+ it 'works as expected' do
172
+ expect(exit_status).to be_nil
173
+ expect(reloaded_yaml).to eql(['BERNARD', 'DAVID'])
174
+ end
175
+ end
176
+
177
+ context 'with --yaml and --stream' do
178
+ let(:argv) do
179
+ ['--yaml', '--stream'] + file_args
180
+ end
181
+
182
+ it 'works as expected' do
183
+ expect(exit_status).to be_nil
184
+ expect(stdout.string.gsub(/\n\.\.\.$/, '')).to eql(<<~YAML)
185
+ --- BERNARD
186
+ --- DAVID
187
+ YAML
188
+ end
189
+ end
190
+
191
+ context 'with --json and --stream' do
192
+ let(:argv) do
193
+ ['--json', '--stream'] + file_args
194
+ end
195
+
196
+ it 'works as expected' do
197
+ expect(exit_status).to be_nil
198
+ expect(stdout.string).to eql(<<~JSON)
199
+ "BERNARD"
200
+ "DAVID"
201
+ JSON
202
+ end
203
+ end
204
+
205
+ context 'with --map' do
206
+ let(:argv) do
207
+ ['--map'] + [FIXTURES/'upcase.lens.yml', FIXTURES/'names.json']
208
+ end
209
+
210
+ it 'works as expected' do
211
+ expect(exit_status).to be_nil
212
+ expect(reloaded_json).to eql(['BERNARD', 'DAVID'])
213
+ end
214
+ end
215
+
216
+ context 'with --literal' do
217
+ let(:argv) do
218
+ ['--literal'] + [FIXTURES/'literal.yml', FIXTURES/'names.json']
219
+ end
220
+
221
+ it 'works as expected' do
222
+ expect(exit_status).to be_nil
223
+ expect(reloaded_json).to eql('Bernard David')
224
+ end
225
+ end
226
+
227
+ context 'with --literal --map' do
228
+ let(:argv) do
229
+ ['--literal', '--map'] + [FIXTURES/'literal2.yml', FIXTURES/'names.json']
230
+ end
231
+
232
+ it 'works as expected' do
233
+ expect(exit_status).to be_nil
234
+ expect(reloaded_json).to eql(['Bernard', 'David'])
235
+ end
236
+ end
237
+
238
+ context 'with --paint --test (ignoring --map, --literal)' do
239
+ let(:argv) do
240
+ ['--map', '--literal', '--paint', '--test', FIXTURES/'test-ok.lens.yml']
241
+ end
242
+
243
+ it 'works as expected' do
244
+ expect(stdout.string).to match(/1 test. 1 success, 0 failure, 0 error./)
245
+ expect(exit_status).to be_nil
246
+ end
247
+ end
248
+
249
+ context 'with --no-paint --test' do
250
+ let(:argv) do
251
+ ['--no-paint', '--test', FIXTURES/'test-ok.lens.yml']
252
+ end
253
+
254
+ it 'works as expected' do
255
+ expect(stdout.string).to eql(".\n\n1 test. 1 success, 0 failure, 0 error.\n")
256
+ expect(exit_status).to be_nil
257
+ end
258
+ end
259
+
260
+ context 'with --no-paint --test with failures' do
261
+ let(:argv) do
262
+ ['--no-paint', '--test', FIXTURES/'test-ko.lens.yml']
263
+ end
264
+
265
+ it 'works as expected' do
266
+ expect(stdout.string).to eql("F.\n\nFailure on example 1:\nExpected: \"Monolens\"\n Actual: \"MONOLENS\"\n\n2 tests. 1 success, 1 failure, 0 error.\n")
267
+ expect(exit_status).to eql(1)
268
+ end
269
+ end
270
+
104
271
  context 'when yielding an error' do
105
272
  let(:argv) do
106
273
  [FIXTURES/'map-upcase.lens.yml', FIXTURES/'names-with-null.json']
107
274
  end
108
275
 
109
276
  it 'works as expected' do
110
- expect(exit_status).to eql(-2)
277
+ expect(exit_status).to eql(1)
111
278
  expect(stdout.string).to eql('')
112
279
  expect(stderr.string).to eql("[1] String expected, got NilClass\n")
113
280
  end
114
281
  end
115
282
 
283
+ context 'when yielding an error with --on-error=skip' do
284
+ let(:argv) do
285
+ ['--map', '--on-error=skip', FIXTURES/'upcase.lens.yml', FIXTURES/'names-with-null.json']
286
+ end
287
+
288
+ it 'works as expected' do
289
+ expect(exit_status).to be_nil
290
+ expect(reloaded_json).to eql(['BERNARD', 'DAVID'])
291
+ end
292
+ end
293
+
116
294
  context 'when yielding an error on a robust lens' do
117
295
  let(:argv) do
118
296
  [FIXTURES/'robust-map-upcase.lens.yml', FIXTURES/'names-with-null.json']
@@ -41,7 +41,7 @@ describe Monolens, 'error traceability' do
41
41
 
42
42
  context 'on array.map => object.values' do
43
43
  let(:lens) do
44
- Monolens.lens('array.map' => { lenses: { 'object.values' => 'str.upcase' } })
44
+ Monolens.lens('array.map' => { lenses: { 'object.values' => ['str.upcase'] } })
45
45
  end
46
46
 
47
47
  subject do
@@ -0,0 +1,88 @@
1
+ require 'spec_helper'
2
+
3
+ module Monolens
4
+ describe Jsonpath do
5
+ def one(path, on)
6
+ Jsonpath.one(path, on, options)
7
+ end
8
+
9
+ def interpolate(str, on)
10
+ Jsonpath.interpolate(str, on, options)
11
+ end
12
+
13
+ let(:options) do
14
+ {}
15
+ end
16
+
17
+ describe 'one' do
18
+ it 'supports the root object' do
19
+ got = one('$', { name: 'Monolens' })
20
+ expect(got).to eql({ name: 'Monolens' })
21
+ end
22
+
23
+ it 'supports simplest expressions' do
24
+ got = one('$.name', { name: 'Monolens' })
25
+ expect(got).to eql('Monolens')
26
+ end
27
+
28
+ it 'supports sub accesses' do
29
+ got = one('$.lib.name', { lib: { name: 'Monolens' } })
30
+ expect(got).to eql('Monolens')
31
+ end
32
+
33
+ it 'supports array accesses' do
34
+ got = one('$[0].name', [{ name: 'Monolens' }])
35
+ expect(got).to eql('Monolens')
36
+ end
37
+
38
+ it 'supports quoted object accesses' do
39
+ got = one("$['name']", { name: 'Monolens' })
40
+ expect(got).to eql('Monolens')
41
+ end
42
+ end
43
+
44
+ describe 'interpolate' do
45
+ it 'supports simplest expressions' do
46
+ got = interpolate('Hello $.name', { name: 'Monolens' })
47
+ expect(got).to eql('Hello Monolens')
48
+ end
49
+
50
+ it 'supports parenthesized expressions' do
51
+ got = interpolate('Hello $(.name)', { name: 'Monolens' })
52
+ expect(got).to eql('Hello Monolens')
53
+ end
54
+ end
55
+
56
+ describe 'use_symbols: false' do
57
+ let(:options) do
58
+ { use_symbols: false }
59
+ end
60
+
61
+ it 'works with String keys' do
62
+ got = one('$.name', { 'name' => 'Monolens' })
63
+ expect(got).to eql('Monolens')
64
+ end
65
+ end
66
+
67
+ describe 'changing the root symbol' do
68
+ let(:options) do
69
+ { root_symbol: '<' }
70
+ end
71
+
72
+ it 'one keeps working' do
73
+ got = one('<.name', { name: 'Monolens' })
74
+ expect(got).to eql('Monolens')
75
+ end
76
+
77
+ it 'interpolate keeps working' do
78
+ got = interpolate('Hello <.name', { name: 'Monolens' })
79
+ expect(got).to eql('Hello Monolens')
80
+ end
81
+
82
+ it 'interpolate keeps supporting parentheses' do
83
+ got = interpolate('Hello <(.name)', { name: 'Monolens' })
84
+ expect(got).to eql('Hello Monolens')
85
+ end
86
+ end
87
+ end
88
+ end
@@ -28,7 +28,7 @@ describe Monolens, '.lens' do
28
28
  it 'raises an error if the lens namespace is not known' do
29
29
  expect {
30
30
  Monolens.lens('nosuchone.tp')
31
- }.to raise_error(Monolens::Error, 'No such lens nosuchone.tp')
31
+ }.to raise_error(Monolens::Error, 'No such namespace nosuchone')
32
32
  end
33
33
 
34
34
  it 'raises an error if the lens is not known' do
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ rx = %r{
4
+ Applying the following lens:
5
+
6
+ ```yaml
7
+ ([^`]+)
8
+ ```
9
+
10
+ to the following input:
11
+
12
+ ```yaml
13
+ ([^`]+)
14
+ ```
15
+
16
+ will return:
17
+
18
+ ```yaml
19
+ ([^`]+)
20
+ ```
21
+ }
22
+
23
+ def yaml_load(input)
24
+ if YAML.respond_to?(:unsafe_load)
25
+ YAML.unsafe_load(input)
26
+ else
27
+ YAML.load(input)
28
+ end
29
+ end
30
+
31
+ Path.dir.parent.glob('documentation/**/*.md') do |file|
32
+ #next unless file.to_s =~ /literal/
33
+
34
+ describe file do
35
+ matches = file.read.scan(rx)
36
+
37
+ if matches.empty?
38
+ puts "WARN: missing or invalid example in #{file}"
39
+ else
40
+ matches.each do |example|
41
+ lens, input, output = example
42
+
43
+ it 'has correct examples' do
44
+ lens = Monolens.lens(yaml_load(lens))
45
+ input = yaml_load(input)
46
+ output = yaml_load(output)
47
+ expect(lens.call(input)).to eql(output)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -43,4 +43,24 @@ describe Monolens do
43
43
  expect(subject.call(input)).to eql(expected)
44
44
  end
45
45
  end
46
+
47
+ context 'on macro.yml' do
48
+ let(:file){ Path.dir/'fixtures/macro.yml' }
49
+
50
+ it 'works' do
51
+ input = [' Monolens ', ' Finitio ', ' Bmg']
52
+ expected = 'MONOLENS, FINITIO, BMG'
53
+ expect(subject.call(input)).to eql(expected)
54
+ end
55
+ end
56
+
57
+ context 'on recursive.yml' do
58
+ let(:file){ Path.dir/'fixtures/recursive.yml' }
59
+
60
+ it 'fails' do
61
+ expect {
62
+ subject
63
+ }.to raise_error(/No such lens core.join_them/)
64
+ end
65
+ end
46
66
  end
data/tasks/test.rake CHANGED
@@ -6,6 +6,6 @@ namespace :test do
6
6
  t.rspec_opts = %w[-I. -Ilib -Ispec --pattern=spec/**/test_*.rb --color .]
7
7
  end
8
8
 
9
- task :all => :"unit"
9
+ task :all => [:unit]
10
10
  end
11
11
  task :test => :"test:all"
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monolens
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernard Lambeau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-20 00:00:00.000000000 Z
11
+ date: 2022-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: minitest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.16'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: paint
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.3'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: rake
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -68,7 +96,8 @@ dependencies:
68
96
  version: '0'
69
97
  description: Data transformations inspired by Cambria lenses
70
98
  email: blambeau@gmail.com
71
- executables: []
99
+ executables:
100
+ - monolens
72
101
  extensions: []
73
102
  extra_rdoc_files: []
74
103
  files:
@@ -78,77 +107,118 @@ files:
78
107
  - Rakefile
79
108
  - bin/monolens
80
109
  - lib/monolens.rb
81
- - lib/monolens/array.rb
82
- - lib/monolens/array/compact.rb
83
- - lib/monolens/array/join.rb
84
- - lib/monolens/array/map.rb
85
- - lib/monolens/check.rb
86
- - lib/monolens/check/not_empty.rb
87
- - lib/monolens/coerce.rb
88
- - lib/monolens/coerce/date.rb
89
- - lib/monolens/coerce/date_time.rb
90
- - lib/monolens/coerce/integer.rb
91
- - lib/monolens/coerce/string.rb
92
110
  - lib/monolens/command.rb
93
- - lib/monolens/core.rb
94
- - lib/monolens/core/chain.rb
95
- - lib/monolens/core/dig.rb
96
- - lib/monolens/core/mapping.rb
111
+ - lib/monolens/command/tester.rb
97
112
  - lib/monolens/error.rb
98
113
  - lib/monolens/error_handler.rb
99
114
  - lib/monolens/file.rb
115
+ - lib/monolens/jsonpath.rb
100
116
  - lib/monolens/lens.rb
101
117
  - lib/monolens/lens/fetch_support.rb
102
118
  - lib/monolens/lens/location.rb
103
119
  - lib/monolens/lens/options.rb
104
- - lib/monolens/object.rb
105
- - lib/monolens/object/extend.rb
106
- - lib/monolens/object/keys.rb
107
- - lib/monolens/object/rename.rb
108
- - lib/monolens/object/select.rb
109
- - lib/monolens/object/transform.rb
110
- - lib/monolens/object/values.rb
111
- - lib/monolens/skip.rb
112
- - lib/monolens/skip/null.rb
113
- - lib/monolens/str.rb
114
- - lib/monolens/str/downcase.rb
115
- - lib/monolens/str/split.rb
116
- - lib/monolens/str/strip.rb
117
- - lib/monolens/str/upcase.rb
120
+ - lib/monolens/lens/signature.rb
121
+ - lib/monolens/lens/signature/missing.rb
122
+ - lib/monolens/macros.rb
123
+ - lib/monolens/namespace.rb
124
+ - lib/monolens/registry.rb
125
+ - lib/monolens/stdlib.rb
126
+ - lib/monolens/stdlib/array.rb
127
+ - lib/monolens/stdlib/array/compact.rb
128
+ - lib/monolens/stdlib/array/join.rb
129
+ - lib/monolens/stdlib/array/map.rb
130
+ - lib/monolens/stdlib/check.rb
131
+ - lib/monolens/stdlib/check/not_empty.rb
132
+ - lib/monolens/stdlib/coerce.rb
133
+ - lib/monolens/stdlib/coerce/date.rb
134
+ - lib/monolens/stdlib/coerce/date_time.rb
135
+ - lib/monolens/stdlib/coerce/integer.rb
136
+ - lib/monolens/stdlib/coerce/string.rb
137
+ - lib/monolens/stdlib/core.rb
138
+ - lib/monolens/stdlib/core/chain.rb
139
+ - lib/monolens/stdlib/core/dig.rb
140
+ - lib/monolens/stdlib/core/literal.rb
141
+ - lib/monolens/stdlib/core/mapping.rb
142
+ - lib/monolens/stdlib/object.rb
143
+ - lib/monolens/stdlib/object/allbut.rb
144
+ - lib/monolens/stdlib/object/extend.rb
145
+ - lib/monolens/stdlib/object/keys.rb
146
+ - lib/monolens/stdlib/object/merge.rb
147
+ - lib/monolens/stdlib/object/rename.rb
148
+ - lib/monolens/stdlib/object/select.rb
149
+ - lib/monolens/stdlib/object/transform.rb
150
+ - lib/monolens/stdlib/object/values.rb
151
+ - lib/monolens/stdlib/skip.rb
152
+ - lib/monolens/stdlib/skip/null.rb
153
+ - lib/monolens/stdlib/str.rb
154
+ - lib/monolens/stdlib/str/downcase.rb
155
+ - lib/monolens/stdlib/str/split.rb
156
+ - lib/monolens/stdlib/str/strip.rb
157
+ - lib/monolens/stdlib/str/upcase.rb
158
+ - lib/monolens/type.rb
159
+ - lib/monolens/type/any.rb
160
+ - lib/monolens/type/array.rb
161
+ - lib/monolens/type/boolean.rb
162
+ - lib/monolens/type/callback.rb
163
+ - lib/monolens/type/coercible.rb
164
+ - lib/monolens/type/diggable.rb
165
+ - lib/monolens/type/emptyable.rb
166
+ - lib/monolens/type/integer.rb
167
+ - lib/monolens/type/lenses.rb
168
+ - lib/monolens/type/map.rb
169
+ - lib/monolens/type/object.rb
170
+ - lib/monolens/type/responding.rb
171
+ - lib/monolens/type/strategy.rb
172
+ - lib/monolens/type/string.rb
173
+ - lib/monolens/type/symbol.rb
118
174
  - lib/monolens/version.rb
119
175
  - spec/fixtures/coerce.yml
176
+ - spec/fixtures/macro.yml
177
+ - spec/fixtures/recursive.yml
120
178
  - spec/fixtures/simple.yml
121
179
  - spec/fixtures/transform.yml
122
- - spec/monolens/array/test_compact.rb
123
- - spec/monolens/array/test_join.rb
124
- - spec/monolens/array/test_map.rb
125
- - spec/monolens/check/test_not_empty.rb
126
- - spec/monolens/coerce/test_date.rb
127
- - spec/monolens/coerce/test_datetime.rb
128
- - spec/monolens/coerce/test_integer.rb
129
- - spec/monolens/coerce/test_string.rb
180
+ - spec/monolens/command/literal.yml
181
+ - spec/monolens/command/literal2.yml
130
182
  - spec/monolens/command/map-upcase.lens.yml
131
183
  - spec/monolens/command/names-with-null.json
132
184
  - spec/monolens/command/names.json
133
185
  - spec/monolens/command/robust-map-upcase.lens.yml
134
- - spec/monolens/core/test_dig.rb
135
- - spec/monolens/core/test_mapping.rb
186
+ - spec/monolens/command/test-ko-complex.yml
187
+ - spec/monolens/command/test-ko.lens.yml
188
+ - spec/monolens/command/test-ok.lens.yml
189
+ - spec/monolens/command/upcase.lens.yml
136
190
  - spec/monolens/lens/test_options.rb
137
- - spec/monolens/object/test_extend.rb
138
- - spec/monolens/object/test_keys.rb
139
- - spec/monolens/object/test_rename.rb
140
- - spec/monolens/object/test_select.rb
141
- - spec/monolens/object/test_transform.rb
142
- - spec/monolens/object/test_values.rb
143
- - spec/monolens/skip/test_null.rb
144
- - spec/monolens/str/test_downcase.rb
145
- - spec/monolens/str/test_split.rb
146
- - spec/monolens/str/test_strip.rb
147
- - spec/monolens/str/test_upcase.rb
191
+ - spec/monolens/lens/test_signature.rb
192
+ - spec/monolens/stdlib/array/test_compact.rb
193
+ - spec/monolens/stdlib/array/test_join.rb
194
+ - spec/monolens/stdlib/array/test_map.rb
195
+ - spec/monolens/stdlib/check/test_not_empty.rb
196
+ - spec/monolens/stdlib/coerce/test_date.rb
197
+ - spec/monolens/stdlib/coerce/test_datetime.rb
198
+ - spec/monolens/stdlib/coerce/test_integer.rb
199
+ - spec/monolens/stdlib/coerce/test_string.rb
200
+ - spec/monolens/stdlib/core/test_dig.rb
201
+ - spec/monolens/stdlib/core/test_literal.rb
202
+ - spec/monolens/stdlib/core/test_mapping.rb
203
+ - spec/monolens/stdlib/object/test_allbut.rb
204
+ - spec/monolens/stdlib/object/test_extend.rb
205
+ - spec/monolens/stdlib/object/test_keys.rb
206
+ - spec/monolens/stdlib/object/test_merge.rb
207
+ - spec/monolens/stdlib/object/test_rename.rb
208
+ - spec/monolens/stdlib/object/test_select.rb
209
+ - spec/monolens/stdlib/object/test_transform.rb
210
+ - spec/monolens/stdlib/object/test_values.rb
211
+ - spec/monolens/stdlib/skip/test_null.rb
212
+ - spec/monolens/stdlib/str/test_downcase.rb
213
+ - spec/monolens/stdlib/str/test_split.rb
214
+ - spec/monolens/stdlib/str/test_strip.rb
215
+ - spec/monolens/stdlib/str/test_upcase.rb
148
216
  - spec/monolens/test_command.rb
149
217
  - spec/monolens/test_error_traceability.rb
218
+ - spec/monolens/test_jsonpath.rb
150
219
  - spec/monolens/test_lens.rb
151
220
  - spec/spec_helper.rb
221
+ - spec/test_documentation.rb
152
222
  - spec/test_monolens.rb
153
223
  - spec/test_readme.rb
154
224
  - tasks/gem.rake
@@ -172,8 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
242
  - !ruby/object:Gem::Version
173
243
  version: '0'
174
244
  requirements: []
175
- rubyforge_project:
176
- rubygems_version: 2.6.14.4
245
+ rubygems_version: 3.1.4
177
246
  signing_key:
178
247
  specification_version: 4
179
248
  summary: Data transformations inspired by Cambria lenses
data/lib/monolens/core.rb DELETED
@@ -1,23 +0,0 @@
1
- module Monolens
2
- module Core
3
- def chain(parts)
4
- Chain.new(parts)
5
- end
6
- module_function :chain
7
-
8
- def dig(options)
9
- Dig.new(options)
10
- end
11
- module_function :dig
12
-
13
- def mapping(options)
14
- Mapping.new(options)
15
- end
16
- module_function :mapping
17
-
18
- Monolens.define_namespace 'core', self
19
- end
20
- end
21
- require_relative 'core/chain'
22
- require_relative 'core/dig'
23
- require_relative 'core/mapping'