monolens 0.5.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +51 -85
- data/lib/monolens/command.rb +111 -14
- data/lib/monolens/error.rb +2 -0
- data/lib/monolens/file.rb +6 -0
- data/lib/monolens/jsonpath.rb +76 -0
- data/lib/monolens/lens/options.rb +26 -12
- data/lib/monolens/lens/signature/missing.rb +11 -0
- data/lib/monolens/lens/signature.rb +60 -0
- data/lib/monolens/lens.rb +25 -4
- data/lib/monolens/macros.rb +28 -0
- data/lib/monolens/namespace.rb +11 -0
- data/lib/monolens/registry.rb +77 -0
- data/lib/monolens/{array → stdlib/array}/compact.rb +2 -0
- data/lib/monolens/{array → stdlib/array}/join.rb +4 -0
- data/lib/monolens/{array → stdlib/array}/map.rb +13 -19
- data/lib/monolens/{array.rb → stdlib/array.rb} +8 -6
- data/lib/monolens/{check → stdlib/check}/not_empty.rb +4 -0
- data/lib/monolens/{check.rb → stdlib/check.rb} +4 -2
- data/lib/monolens/{coerce → stdlib/coerce}/date.rb +5 -0
- data/lib/monolens/{coerce → stdlib/coerce}/date_time.rb +6 -1
- data/lib/monolens/{coerce → stdlib/coerce}/integer.rb +4 -0
- data/lib/monolens/{coerce → stdlib/coerce}/string.rb +2 -0
- data/lib/monolens/{coerce.rb → stdlib/coerce.rb} +10 -8
- data/lib/monolens/{core → stdlib/core}/chain.rb +5 -3
- data/lib/monolens/{core → stdlib/core}/dig.rb +5 -0
- data/lib/monolens/stdlib/core/literal.rb +68 -0
- data/lib/monolens/{core → stdlib/core}/mapping.rb +15 -5
- data/lib/monolens/{core.rb → stdlib/core.rb} +10 -8
- data/lib/monolens/stdlib/object/allbut.rb +22 -0
- data/lib/monolens/{object → stdlib/object}/extend.rb +10 -5
- data/lib/monolens/{object → stdlib/object}/keys.rb +4 -0
- data/lib/monolens/stdlib/object/merge.rb +56 -0
- data/lib/monolens/{object → stdlib/object}/rename.rb +5 -1
- data/lib/monolens/{object → stdlib/object}/select.rb +9 -0
- data/lib/monolens/{object → stdlib/object}/transform.rb +8 -3
- data/lib/monolens/{object → stdlib/object}/values.rb +9 -4
- data/lib/monolens/stdlib/object.rb +55 -0
- data/lib/monolens/{skip → stdlib/skip}/null.rb +2 -0
- data/lib/monolens/{skip.rb → stdlib/skip.rb} +4 -2
- data/lib/monolens/{str → stdlib/str}/downcase.rb +2 -0
- data/lib/monolens/{str → stdlib/str}/split.rb +5 -1
- data/lib/monolens/{str → stdlib/str}/strip.rb +2 -0
- data/lib/monolens/{str → stdlib/str}/upcase.rb +2 -0
- data/lib/monolens/{str.rb → stdlib/str.rb} +10 -8
- data/lib/monolens/stdlib.rb +7 -0
- data/lib/monolens/type/any.rb +39 -0
- data/lib/monolens/type/array.rb +27 -0
- data/lib/monolens/type/boolean.rb +17 -0
- data/lib/monolens/type/callback.rb +17 -0
- data/lib/monolens/type/coercible.rb +10 -0
- data/lib/monolens/type/diggable.rb +9 -0
- data/lib/monolens/type/emptyable.rb +9 -0
- data/lib/monolens/type/integer.rb +18 -0
- data/lib/monolens/type/lenses.rb +17 -0
- data/lib/monolens/type/map.rb +30 -0
- data/lib/monolens/type/object.rb +17 -0
- data/lib/monolens/type/responding.rb +25 -0
- data/lib/monolens/type/strategy.rb +56 -0
- data/lib/monolens/type/string.rb +18 -0
- data/lib/monolens/type/symbol.rb +20 -0
- data/lib/monolens/type.rb +33 -0
- data/lib/monolens/version.rb +2 -2
- data/lib/monolens.rb +22 -66
- data/spec/fixtures/macro.yml +13 -0
- data/spec/fixtures/recursive.yml +15 -0
- data/spec/monolens/command/literal.yml +2 -0
- data/spec/monolens/command/literal2.yml +2 -0
- data/spec/monolens/command/upcase.lens.yml +4 -0
- data/spec/monolens/lens/test_options.rb +2 -14
- data/spec/monolens/lens/test_signature.rb +38 -0
- data/spec/monolens/{array → stdlib/array}/test_compact.rb +8 -0
- data/spec/monolens/{array → stdlib/array}/test_join.rb +0 -0
- data/spec/monolens/{array → stdlib/array}/test_map.rb +15 -0
- data/spec/monolens/{check → stdlib/check}/test_not_empty.rb +0 -0
- data/spec/monolens/{coerce → stdlib/coerce}/test_date.rb +0 -0
- data/spec/monolens/{coerce → stdlib/coerce}/test_datetime.rb +1 -1
- data/spec/monolens/{coerce → stdlib/coerce}/test_integer.rb +0 -0
- data/spec/monolens/{coerce → stdlib/coerce}/test_string.rb +0 -0
- data/spec/monolens/{core → stdlib/core}/test_dig.rb +0 -0
- data/spec/monolens/stdlib/core/test_literal.rb +73 -0
- data/spec/monolens/{core → stdlib/core}/test_mapping.rb +37 -1
- data/spec/monolens/stdlib/object/test_allbut.rb +31 -0
- data/spec/monolens/{object → stdlib/object}/test_extend.rb +0 -0
- data/spec/monolens/{object → stdlib/object}/test_keys.rb +0 -0
- data/spec/monolens/stdlib/object/test_merge.rb +133 -0
- data/spec/monolens/{object → stdlib/object}/test_rename.rb +0 -0
- data/spec/monolens/{object → stdlib/object}/test_select.rb +0 -0
- data/spec/monolens/{object → stdlib/object}/test_transform.rb +0 -0
- data/spec/monolens/{object → stdlib/object}/test_values.rb +0 -0
- data/spec/monolens/{skip → stdlib/skip}/test_null.rb +0 -0
- data/spec/monolens/{str → stdlib/str}/test_downcase.rb +0 -0
- data/spec/monolens/{str → stdlib/str}/test_split.rb +0 -0
- data/spec/monolens/{str → stdlib/str}/test_strip.rb +0 -0
- data/spec/monolens/{str → stdlib/str}/test_upcase.rb +0 -0
- data/spec/monolens/test_command.rb +145 -0
- data/spec/monolens/test_error_traceability.rb +1 -1
- data/spec/monolens/test_jsonpath.rb +88 -0
- data/spec/monolens/test_lens.rb +1 -1
- data/spec/test_documentation.rb +52 -0
- data/spec/test_monolens.rb +20 -0
- data/tasks/test.rake +1 -1
- metadata +91 -55
- data/lib/monolens/core/literal.rb +0 -11
- data/lib/monolens/object.rb +0 -41
- data/spec/monolens/core/test_literal.rb +0 -13
@@ -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,6 +152,89 @@ 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
|
+
|
104
238
|
context 'when yielding an error' do
|
105
239
|
let(:argv) do
|
106
240
|
[FIXTURES/'map-upcase.lens.yml', FIXTURES/'names-with-null.json']
|
@@ -113,6 +247,17 @@ module Monolens
|
|
113
247
|
end
|
114
248
|
end
|
115
249
|
|
250
|
+
context 'when yielding an error with --on-error=skip' do
|
251
|
+
let(:argv) do
|
252
|
+
['--map', '--on-error=skip', FIXTURES/'upcase.lens.yml', FIXTURES/'names-with-null.json']
|
253
|
+
end
|
254
|
+
|
255
|
+
it 'works as expected' do
|
256
|
+
expect(exit_status).to be_nil
|
257
|
+
expect(reloaded_json).to eql(['BERNARD', 'DAVID'])
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
116
261
|
context 'when yielding an error on a robust lens' do
|
117
262
|
let(:argv) do
|
118
263
|
[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
|
data/spec/monolens/test_lens.rb
CHANGED
@@ -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
|
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
|
data/spec/test_monolens.rb
CHANGED
@@ -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
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monolens
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
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-
|
11
|
+
date: 2022-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -68,7 +68,8 @@ dependencies:
|
|
68
68
|
version: '0'
|
69
69
|
description: Data transformations inspired by Cambria lenses
|
70
70
|
email: blambeau@gmail.com
|
71
|
-
executables:
|
71
|
+
executables:
|
72
|
+
- monolens
|
72
73
|
extensions: []
|
73
74
|
extra_rdoc_files: []
|
74
75
|
files:
|
@@ -78,79 +79,114 @@ files:
|
|
78
79
|
- Rakefile
|
79
80
|
- bin/monolens
|
80
81
|
- 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
82
|
- 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/literal.rb
|
97
|
-
- lib/monolens/core/mapping.rb
|
98
83
|
- lib/monolens/error.rb
|
99
84
|
- lib/monolens/error_handler.rb
|
100
85
|
- lib/monolens/file.rb
|
86
|
+
- lib/monolens/jsonpath.rb
|
101
87
|
- lib/monolens/lens.rb
|
102
88
|
- lib/monolens/lens/fetch_support.rb
|
103
89
|
- lib/monolens/lens/location.rb
|
104
90
|
- lib/monolens/lens/options.rb
|
105
|
-
- lib/monolens/
|
106
|
-
- lib/monolens/
|
107
|
-
- lib/monolens/
|
108
|
-
- lib/monolens/
|
109
|
-
- lib/monolens/
|
110
|
-
- lib/monolens/
|
111
|
-
- lib/monolens/
|
112
|
-
- lib/monolens/
|
113
|
-
- lib/monolens/
|
114
|
-
- lib/monolens/
|
115
|
-
- lib/monolens/
|
116
|
-
- lib/monolens/
|
117
|
-
- lib/monolens/
|
118
|
-
- lib/monolens/
|
91
|
+
- lib/monolens/lens/signature.rb
|
92
|
+
- lib/monolens/lens/signature/missing.rb
|
93
|
+
- lib/monolens/macros.rb
|
94
|
+
- lib/monolens/namespace.rb
|
95
|
+
- lib/monolens/registry.rb
|
96
|
+
- lib/monolens/stdlib.rb
|
97
|
+
- lib/monolens/stdlib/array.rb
|
98
|
+
- lib/monolens/stdlib/array/compact.rb
|
99
|
+
- lib/monolens/stdlib/array/join.rb
|
100
|
+
- lib/monolens/stdlib/array/map.rb
|
101
|
+
- lib/monolens/stdlib/check.rb
|
102
|
+
- lib/monolens/stdlib/check/not_empty.rb
|
103
|
+
- lib/monolens/stdlib/coerce.rb
|
104
|
+
- lib/monolens/stdlib/coerce/date.rb
|
105
|
+
- lib/monolens/stdlib/coerce/date_time.rb
|
106
|
+
- lib/monolens/stdlib/coerce/integer.rb
|
107
|
+
- lib/monolens/stdlib/coerce/string.rb
|
108
|
+
- lib/monolens/stdlib/core.rb
|
109
|
+
- lib/monolens/stdlib/core/chain.rb
|
110
|
+
- lib/monolens/stdlib/core/dig.rb
|
111
|
+
- lib/monolens/stdlib/core/literal.rb
|
112
|
+
- lib/monolens/stdlib/core/mapping.rb
|
113
|
+
- lib/monolens/stdlib/object.rb
|
114
|
+
- lib/monolens/stdlib/object/allbut.rb
|
115
|
+
- lib/monolens/stdlib/object/extend.rb
|
116
|
+
- lib/monolens/stdlib/object/keys.rb
|
117
|
+
- lib/monolens/stdlib/object/merge.rb
|
118
|
+
- lib/monolens/stdlib/object/rename.rb
|
119
|
+
- lib/monolens/stdlib/object/select.rb
|
120
|
+
- lib/monolens/stdlib/object/transform.rb
|
121
|
+
- lib/monolens/stdlib/object/values.rb
|
122
|
+
- lib/monolens/stdlib/skip.rb
|
123
|
+
- lib/monolens/stdlib/skip/null.rb
|
124
|
+
- lib/monolens/stdlib/str.rb
|
125
|
+
- lib/monolens/stdlib/str/downcase.rb
|
126
|
+
- lib/monolens/stdlib/str/split.rb
|
127
|
+
- lib/monolens/stdlib/str/strip.rb
|
128
|
+
- lib/monolens/stdlib/str/upcase.rb
|
129
|
+
- lib/monolens/type.rb
|
130
|
+
- lib/monolens/type/any.rb
|
131
|
+
- lib/monolens/type/array.rb
|
132
|
+
- lib/monolens/type/boolean.rb
|
133
|
+
- lib/monolens/type/callback.rb
|
134
|
+
- lib/monolens/type/coercible.rb
|
135
|
+
- lib/monolens/type/diggable.rb
|
136
|
+
- lib/monolens/type/emptyable.rb
|
137
|
+
- lib/monolens/type/integer.rb
|
138
|
+
- lib/monolens/type/lenses.rb
|
139
|
+
- lib/monolens/type/map.rb
|
140
|
+
- lib/monolens/type/object.rb
|
141
|
+
- lib/monolens/type/responding.rb
|
142
|
+
- lib/monolens/type/strategy.rb
|
143
|
+
- lib/monolens/type/string.rb
|
144
|
+
- lib/monolens/type/symbol.rb
|
119
145
|
- lib/monolens/version.rb
|
120
146
|
- spec/fixtures/coerce.yml
|
147
|
+
- spec/fixtures/macro.yml
|
148
|
+
- spec/fixtures/recursive.yml
|
121
149
|
- spec/fixtures/simple.yml
|
122
150
|
- spec/fixtures/transform.yml
|
123
|
-
- spec/monolens/
|
124
|
-
- spec/monolens/
|
125
|
-
- spec/monolens/array/test_map.rb
|
126
|
-
- spec/monolens/check/test_not_empty.rb
|
127
|
-
- spec/monolens/coerce/test_date.rb
|
128
|
-
- spec/monolens/coerce/test_datetime.rb
|
129
|
-
- spec/monolens/coerce/test_integer.rb
|
130
|
-
- spec/monolens/coerce/test_string.rb
|
151
|
+
- spec/monolens/command/literal.yml
|
152
|
+
- spec/monolens/command/literal2.yml
|
131
153
|
- spec/monolens/command/map-upcase.lens.yml
|
132
154
|
- spec/monolens/command/names-with-null.json
|
133
155
|
- spec/monolens/command/names.json
|
134
156
|
- spec/monolens/command/robust-map-upcase.lens.yml
|
135
|
-
- spec/monolens/
|
136
|
-
- spec/monolens/core/test_literal.rb
|
137
|
-
- spec/monolens/core/test_mapping.rb
|
157
|
+
- spec/monolens/command/upcase.lens.yml
|
138
158
|
- spec/monolens/lens/test_options.rb
|
139
|
-
- spec/monolens/
|
140
|
-
- spec/monolens/
|
141
|
-
- spec/monolens/
|
142
|
-
- spec/monolens/
|
143
|
-
- spec/monolens/
|
144
|
-
- spec/monolens/
|
145
|
-
- spec/monolens/
|
146
|
-
- spec/monolens/
|
147
|
-
- spec/monolens/
|
148
|
-
- spec/monolens/
|
149
|
-
- spec/monolens/
|
159
|
+
- spec/monolens/lens/test_signature.rb
|
160
|
+
- spec/monolens/stdlib/array/test_compact.rb
|
161
|
+
- spec/monolens/stdlib/array/test_join.rb
|
162
|
+
- spec/monolens/stdlib/array/test_map.rb
|
163
|
+
- spec/monolens/stdlib/check/test_not_empty.rb
|
164
|
+
- spec/monolens/stdlib/coerce/test_date.rb
|
165
|
+
- spec/monolens/stdlib/coerce/test_datetime.rb
|
166
|
+
- spec/monolens/stdlib/coerce/test_integer.rb
|
167
|
+
- spec/monolens/stdlib/coerce/test_string.rb
|
168
|
+
- spec/monolens/stdlib/core/test_dig.rb
|
169
|
+
- spec/monolens/stdlib/core/test_literal.rb
|
170
|
+
- spec/monolens/stdlib/core/test_mapping.rb
|
171
|
+
- spec/monolens/stdlib/object/test_allbut.rb
|
172
|
+
- spec/monolens/stdlib/object/test_extend.rb
|
173
|
+
- spec/monolens/stdlib/object/test_keys.rb
|
174
|
+
- spec/monolens/stdlib/object/test_merge.rb
|
175
|
+
- spec/monolens/stdlib/object/test_rename.rb
|
176
|
+
- spec/monolens/stdlib/object/test_select.rb
|
177
|
+
- spec/monolens/stdlib/object/test_transform.rb
|
178
|
+
- spec/monolens/stdlib/object/test_values.rb
|
179
|
+
- spec/monolens/stdlib/skip/test_null.rb
|
180
|
+
- spec/monolens/stdlib/str/test_downcase.rb
|
181
|
+
- spec/monolens/stdlib/str/test_split.rb
|
182
|
+
- spec/monolens/stdlib/str/test_strip.rb
|
183
|
+
- spec/monolens/stdlib/str/test_upcase.rb
|
150
184
|
- spec/monolens/test_command.rb
|
151
185
|
- spec/monolens/test_error_traceability.rb
|
186
|
+
- spec/monolens/test_jsonpath.rb
|
152
187
|
- spec/monolens/test_lens.rb
|
153
188
|
- spec/spec_helper.rb
|
189
|
+
- spec/test_documentation.rb
|
154
190
|
- spec/test_monolens.rb
|
155
191
|
- spec/test_readme.rb
|
156
192
|
- tasks/gem.rake
|
data/lib/monolens/object.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
module Monolens
|
2
|
-
module Object
|
3
|
-
def extend(options)
|
4
|
-
Extend.new(options)
|
5
|
-
end
|
6
|
-
module_function :extend
|
7
|
-
|
8
|
-
def rename(parts)
|
9
|
-
Rename.new(parts)
|
10
|
-
end
|
11
|
-
module_function :rename
|
12
|
-
|
13
|
-
def transform(parts)
|
14
|
-
Transform.new(parts)
|
15
|
-
end
|
16
|
-
module_function :transform
|
17
|
-
|
18
|
-
def keys(lens)
|
19
|
-
Keys.new(lens)
|
20
|
-
end
|
21
|
-
module_function :keys
|
22
|
-
|
23
|
-
def values(lens)
|
24
|
-
Values.new(lens)
|
25
|
-
end
|
26
|
-
module_function :values
|
27
|
-
|
28
|
-
def select(lens)
|
29
|
-
Select.new(lens)
|
30
|
-
end
|
31
|
-
module_function :select
|
32
|
-
|
33
|
-
Monolens.define_namespace 'object', self
|
34
|
-
end
|
35
|
-
end
|
36
|
-
require_relative 'object/rename'
|
37
|
-
require_relative 'object/transform'
|
38
|
-
require_relative 'object/keys'
|
39
|
-
require_relative 'object/values'
|
40
|
-
require_relative 'object/select'
|
41
|
-
require_relative 'object/extend'
|