attributor 5.2.0 → 5.6
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.
- checksums.yaml +5 -5
- data/.travis.yml +4 -3
- data/CHANGELOG.md +146 -140
- data/attributor.gemspec +4 -5
- data/lib/attributor.rb +16 -2
- data/lib/attributor/attribute.rb +42 -9
- data/lib/attributor/extras/field_selector.rb +4 -0
- data/lib/attributor/families/numeric.rb +19 -6
- data/lib/attributor/families/temporal.rb +16 -9
- data/lib/attributor/hash_dsl_compiler.rb +6 -6
- data/lib/attributor/type.rb +27 -4
- data/lib/attributor/types/bigdecimal.rb +7 -2
- data/lib/attributor/types/boolean.rb +7 -2
- data/lib/attributor/types/class.rb +2 -2
- data/lib/attributor/types/collection.rb +24 -5
- data/lib/attributor/types/container.rb +3 -3
- data/lib/attributor/types/csv.rb +5 -1
- data/lib/attributor/types/date.rb +9 -3
- data/lib/attributor/types/date_time.rb +8 -2
- data/lib/attributor/types/float.rb +4 -3
- data/lib/attributor/types/hash.rb +82 -18
- data/lib/attributor/types/integer.rb +7 -1
- data/lib/attributor/types/model.rb +2 -2
- data/lib/attributor/types/object.rb +5 -0
- data/lib/attributor/types/polymorphic.rb +3 -2
- data/lib/attributor/types/string.rb +20 -1
- data/lib/attributor/types/struct.rb +1 -1
- data/lib/attributor/types/symbol.rb +5 -0
- data/lib/attributor/types/tempfile.rb +4 -0
- data/lib/attributor/types/time.rb +7 -3
- data/lib/attributor/types/uri.rb +9 -1
- data/lib/attributor/version.rb +1 -1
- data/spec/attribute_spec.rb +42 -7
- data/spec/dsl_compiler_spec.rb +7 -7
- data/spec/extras/field_selector/field_selector_spec.rb +9 -0
- data/spec/hash_dsl_compiler_spec.rb +2 -2
- data/spec/support/integers.rb +7 -0
- data/spec/type_spec.rb +1 -1
- data/spec/types/bigdecimal_spec.rb +8 -0
- data/spec/types/boolean_spec.rb +10 -0
- data/spec/types/class_spec.rb +0 -1
- data/spec/types/collection_spec.rb +16 -0
- data/spec/types/date_spec.rb +9 -0
- data/spec/types/date_time_spec.rb +9 -0
- data/spec/types/float_spec.rb +8 -0
- data/spec/types/hash_spec.rb +127 -9
- data/spec/types/integer_spec.rb +10 -1
- data/spec/types/model_spec.rb +14 -3
- data/spec/types/string_spec.rb +10 -0
- data/spec/types/temporal_spec.rb +5 -1
- data/spec/types/time_spec.rb +9 -0
- data/spec/types/uri_spec.rb +9 -0
- metadata +21 -34
data/spec/types/string_spec.rb
CHANGED
@@ -64,4 +64,14 @@ describe Attributor::String do
|
|
64
64
|
end.to raise_error(Attributor::IncompatibleTypeError)
|
65
65
|
end
|
66
66
|
end
|
67
|
+
|
68
|
+
context '.as_json_schema' do
|
69
|
+
subject(:js){ type.as_json_schema(attribute_options: { regexp: /^Foobar$/ }) }
|
70
|
+
it 'adds the right attributes' do
|
71
|
+
expect(js.keys).to include(:type, :'x-type_name')
|
72
|
+
expect(js[:type]).to eq(:string)
|
73
|
+
expect(js[:'x-type_name']).to eq('String')
|
74
|
+
expect(js[:pattern]).to eq('^Foobar$')
|
75
|
+
end
|
76
|
+
end
|
67
77
|
end
|
data/spec/types/temporal_spec.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Attributor::Temporal do
|
4
|
-
subject(:type)
|
4
|
+
subject(:type) do
|
5
|
+
Class.new do
|
6
|
+
include Attributor::Temporal
|
7
|
+
end
|
8
|
+
end
|
5
9
|
|
6
10
|
it 'raises an exception for native_type' do
|
7
11
|
expect { type.native_type }.to raise_error(NotImplementedError)
|
data/spec/types/time_spec.rb
CHANGED
@@ -90,4 +90,13 @@ describe Attributor::Time do
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
end
|
93
|
+
context '.as_json_schema' do
|
94
|
+
subject(:js){ type.as_json_schema }
|
95
|
+
it 'adds the right attributes' do
|
96
|
+
expect(js.keys).to include(:type, :'x-type_name')
|
97
|
+
expect(js[:type]).to eq(:string)
|
98
|
+
expect(js[:format]).to eq(:'time')
|
99
|
+
expect(js[:'x-type_name']).to eq('Time')
|
100
|
+
end
|
101
|
+
end
|
93
102
|
end
|
data/spec/types/uri_spec.rb
CHANGED
@@ -109,4 +109,13 @@ describe Attributor::URI do
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
end
|
112
|
+
context '.as_json_schema' do
|
113
|
+
subject(:js){ type.as_json_schema }
|
114
|
+
it 'adds the right attributes' do
|
115
|
+
expect(js.keys).to include(:type, :'x-type_name')
|
116
|
+
expect(js[:type]).to eq(:string)
|
117
|
+
expect(js[:format]).to eq(:uri)
|
118
|
+
expect(js[:'x-type_name']).to eq('URI')
|
119
|
+
end
|
120
|
+
end
|
112
121
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attributor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: '5.6'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josep M. Blanquer
|
8
8
|
- Dane Jensen
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-11-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hashie
|
@@ -85,16 +85,16 @@ dependencies:
|
|
85
85
|
name: rspec-collection_matchers
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- - "
|
88
|
+
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: '
|
90
|
+
version: '0'
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- - "
|
95
|
+
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: '
|
97
|
+
version: '0'
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: yard
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,20 +109,6 @@ dependencies:
|
|
109
109
|
- - ">="
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
|
-
- !ruby/object:Gem::Dependency
|
113
|
-
name: backports
|
114
|
-
requirement: !ruby/object:Gem::Requirement
|
115
|
-
requirements:
|
116
|
-
- - "~>"
|
117
|
-
- !ruby/object:Gem::Version
|
118
|
-
version: '3'
|
119
|
-
type: :development
|
120
|
-
prerelease: false
|
121
|
-
version_requirements: !ruby/object:Gem::Requirement
|
122
|
-
requirements:
|
123
|
-
- - "~>"
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: '3'
|
126
112
|
- !ruby/object:Gem::Dependency
|
127
113
|
name: yardstick
|
128
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -211,42 +197,42 @@ dependencies:
|
|
211
197
|
name: pry
|
212
198
|
requirement: !ruby/object:Gem::Requirement
|
213
199
|
requirements:
|
214
|
-
- - "
|
200
|
+
- - ">="
|
215
201
|
- !ruby/object:Gem::Version
|
216
202
|
version: '0'
|
217
203
|
type: :development
|
218
204
|
prerelease: false
|
219
205
|
version_requirements: !ruby/object:Gem::Requirement
|
220
206
|
requirements:
|
221
|
-
- - "
|
207
|
+
- - ">="
|
222
208
|
- !ruby/object:Gem::Version
|
223
209
|
version: '0'
|
224
210
|
- !ruby/object:Gem::Dependency
|
225
211
|
name: pry-byebug
|
226
212
|
requirement: !ruby/object:Gem::Requirement
|
227
213
|
requirements:
|
228
|
-
- - "
|
214
|
+
- - ">="
|
229
215
|
- !ruby/object:Gem::Version
|
230
|
-
version: '
|
216
|
+
version: '0'
|
231
217
|
type: :development
|
232
218
|
prerelease: false
|
233
219
|
version_requirements: !ruby/object:Gem::Requirement
|
234
220
|
requirements:
|
235
|
-
- - "
|
221
|
+
- - ">="
|
236
222
|
- !ruby/object:Gem::Version
|
237
|
-
version: '
|
223
|
+
version: '0'
|
238
224
|
- !ruby/object:Gem::Dependency
|
239
225
|
name: pry-stack_explorer
|
240
226
|
requirement: !ruby/object:Gem::Requirement
|
241
227
|
requirements:
|
242
|
-
- - "
|
228
|
+
- - ">="
|
243
229
|
- !ruby/object:Gem::Version
|
244
230
|
version: '0'
|
245
231
|
type: :development
|
246
232
|
prerelease: false
|
247
233
|
version_requirements: !ruby/object:Gem::Requirement
|
248
234
|
requirements:
|
249
|
-
- - "
|
235
|
+
- - ">="
|
250
236
|
- !ruby/object:Gem::Version
|
251
237
|
version: '0'
|
252
238
|
- !ruby/object:Gem::Dependency
|
@@ -305,7 +291,7 @@ dependencies:
|
|
305
291
|
- - ">="
|
306
292
|
- !ruby/object:Gem::Version
|
307
293
|
version: '0'
|
308
|
-
description:
|
294
|
+
description:
|
309
295
|
email:
|
310
296
|
- blanquer@gmail.com
|
311
297
|
- dane.jensen@gmail.com
|
@@ -375,6 +361,7 @@ files:
|
|
375
361
|
- spec/smart_attribute_selector_spec.rb
|
376
362
|
- spec/spec_helper.rb
|
377
363
|
- spec/support/hashes.rb
|
364
|
+
- spec/support/integers.rb
|
378
365
|
- spec/support/models.rb
|
379
366
|
- spec/support/polymorphics.rb
|
380
367
|
- spec/type_spec.rb
|
@@ -405,7 +392,7 @@ homepage: https://github.com/rightscale/attributor
|
|
405
392
|
licenses:
|
406
393
|
- MIT
|
407
394
|
metadata: {}
|
408
|
-
post_install_message:
|
395
|
+
post_install_message:
|
409
396
|
rdoc_options: []
|
410
397
|
require_paths:
|
411
398
|
- lib
|
@@ -420,9 +407,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
420
407
|
- !ruby/object:Gem::Version
|
421
408
|
version: '0'
|
422
409
|
requirements: []
|
423
|
-
|
424
|
-
|
425
|
-
signing_key:
|
410
|
+
rubygems_version: 3.0.3
|
411
|
+
signing_key:
|
426
412
|
specification_version: 4
|
427
413
|
summary: A powerful attribute and type management library for Ruby
|
428
414
|
test_files:
|
@@ -437,6 +423,7 @@ test_files:
|
|
437
423
|
- spec/smart_attribute_selector_spec.rb
|
438
424
|
- spec/spec_helper.rb
|
439
425
|
- spec/support/hashes.rb
|
426
|
+
- spec/support/integers.rb
|
440
427
|
- spec/support/models.rb
|
441
428
|
- spec/support/polymorphics.rb
|
442
429
|
- spec/type_spec.rb
|