json_schematize 0.8.0 → 0.10.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.
- checksums.yaml +4 -4
- data/.circleci/config.yml +2 -2
- data/Dockerfile +1 -1
- data/Gemfile.lock +50 -30
- data/json_schematize.gemspec +2 -2
- data/lib/json_schematize/cache/class_methods/client.rb +5 -2
- data/lib/json_schematize/field.rb +11 -2
- data/lib/json_schematize/generator.rb +3 -1
- data/lib/json_schematize/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f142af20c373eb4cc7c13c09311cb6c5ebfd3bd4d8de2f31bad7e162b1c7f38e
|
|
4
|
+
data.tar.gz: 208e364c6afbd566d55b81ebc7f57ea38c96e963afbecd9c2bac79da08710d45
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8341c39c1d7bfd71e7bf42fc5ad85266084a401c464d3a73362d020e61aaeb2fb46563ecf366397c71e6e23a411763407f8dd45fede1164f0b0cccb0f302afa7
|
|
7
|
+
data.tar.gz: 37a700647afa8ad98de45e9563205293ec1a6b7f6c0eaa463fe58cdc98b88d031ed56b7c8f1862f4e3a5ac8bcf9c826803b9c38348bf7b89e30b044f4f031ec7
|
data/.circleci/config.yml
CHANGED
|
@@ -12,10 +12,10 @@ workflows:
|
|
|
12
12
|
- cst/enforce-gem-version-bump
|
|
13
13
|
- cst/rspec-ruby:
|
|
14
14
|
rspec-system-args: "SIMPLE_COV_RUN=true"
|
|
15
|
-
cc-report-collect-ruby: "
|
|
15
|
+
cc-report-collect-ruby: "3.3.6"
|
|
16
16
|
matrix:
|
|
17
17
|
parameters:
|
|
18
|
-
ruby-version: ["2.
|
|
18
|
+
ruby-version: ["3.2.4", "3.3.6"]
|
|
19
19
|
alias: required-matrix-tests
|
|
20
20
|
name: test-ruby<< matrix.ruby-version >>
|
|
21
21
|
- cst/publish-gem:
|
data/Dockerfile
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
FROM ruby:3.
|
|
1
|
+
FROM ruby:3.3.6
|
|
2
2
|
RUN cd /tmp && curl -L --output ghr.tar.gz https://github.com/tcnksm/ghr/releases/download/v0.12.0/ghr_v0.12.0_linux_amd64.tar.gz && \
|
|
3
3
|
tar -xzvf ghr.tar.gz && chmod +x ghr_v0.12.0_linux_amd64/ghr && mv ghr_v0.12.0_linux_amd64/ghr /usr/local/bin/ghr && rm -rf /tmp/*
|
|
4
4
|
|
data/Gemfile.lock
CHANGED
|
@@ -1,59 +1,79 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
json_schematize (0.
|
|
4
|
+
json_schematize (0.10.0)
|
|
5
|
+
class_composer (>= 1.0)
|
|
5
6
|
|
|
6
7
|
GEM
|
|
7
8
|
remote: https://rubygems.org/
|
|
8
9
|
specs:
|
|
9
|
-
activesupport (
|
|
10
|
-
|
|
10
|
+
activesupport (8.0.1)
|
|
11
|
+
base64
|
|
12
|
+
benchmark (>= 0.3)
|
|
13
|
+
bigdecimal
|
|
14
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
15
|
+
connection_pool (>= 2.2.5)
|
|
16
|
+
drb
|
|
11
17
|
i18n (>= 1.6, < 2)
|
|
18
|
+
logger (>= 1.4.2)
|
|
12
19
|
minitest (>= 5.1)
|
|
13
|
-
|
|
20
|
+
securerandom (>= 0.3)
|
|
21
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
|
22
|
+
uri (>= 0.13.1)
|
|
23
|
+
base64 (0.2.0)
|
|
24
|
+
benchmark (0.4.0)
|
|
25
|
+
bigdecimal (3.1.9)
|
|
14
26
|
byebug (11.1.3)
|
|
27
|
+
class_composer (2.1.0)
|
|
15
28
|
coderay (1.1.3)
|
|
16
|
-
concurrent-ruby (1.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
29
|
+
concurrent-ruby (1.3.4)
|
|
30
|
+
connection_pool (2.4.1)
|
|
31
|
+
diff-lcs (1.5.1)
|
|
32
|
+
docile (1.4.1)
|
|
33
|
+
drb (2.2.1)
|
|
34
|
+
faker (3.5.1)
|
|
20
35
|
i18n (>= 1.8.11, < 2)
|
|
21
|
-
i18n (1.
|
|
36
|
+
i18n (1.14.6)
|
|
22
37
|
concurrent-ruby (~> 1.0)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
38
|
+
logger (1.6.4)
|
|
39
|
+
method_source (1.1.0)
|
|
40
|
+
minitest (5.25.4)
|
|
41
|
+
pry (0.14.2)
|
|
26
42
|
coderay (~> 1.1)
|
|
27
43
|
method_source (~> 1.0)
|
|
28
|
-
pry-byebug (3.
|
|
44
|
+
pry-byebug (3.10.1)
|
|
29
45
|
byebug (~> 11.0)
|
|
30
|
-
pry (
|
|
46
|
+
pry (>= 0.13, < 0.15)
|
|
31
47
|
rake (12.3.3)
|
|
32
|
-
rspec (3.
|
|
33
|
-
rspec-core (~> 3.
|
|
34
|
-
rspec-expectations (~> 3.
|
|
35
|
-
rspec-mocks (~> 3.
|
|
36
|
-
rspec-core (3.
|
|
37
|
-
rspec-support (~> 3.
|
|
38
|
-
rspec-expectations (3.
|
|
48
|
+
rspec (3.13.0)
|
|
49
|
+
rspec-core (~> 3.13.0)
|
|
50
|
+
rspec-expectations (~> 3.13.0)
|
|
51
|
+
rspec-mocks (~> 3.13.0)
|
|
52
|
+
rspec-core (3.13.2)
|
|
53
|
+
rspec-support (~> 3.13.0)
|
|
54
|
+
rspec-expectations (3.13.3)
|
|
39
55
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
40
|
-
rspec-support (~> 3.
|
|
41
|
-
rspec-mocks (3.
|
|
56
|
+
rspec-support (~> 3.13.0)
|
|
57
|
+
rspec-mocks (3.13.2)
|
|
42
58
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
43
|
-
rspec-support (~> 3.
|
|
44
|
-
rspec-support (3.
|
|
45
|
-
rspec_junit_formatter (0.
|
|
59
|
+
rspec-support (~> 3.13.0)
|
|
60
|
+
rspec-support (3.13.2)
|
|
61
|
+
rspec_junit_formatter (0.6.0)
|
|
46
62
|
rspec-core (>= 2, < 4, != 2.12.0)
|
|
47
|
-
|
|
63
|
+
securerandom (0.4.1)
|
|
64
|
+
simplecov (0.22.0)
|
|
48
65
|
docile (~> 1.1)
|
|
49
66
|
simplecov-html (~> 0.11)
|
|
50
67
|
simplecov_json_formatter (~> 0.1)
|
|
51
|
-
simplecov-html (0.
|
|
68
|
+
simplecov-html (0.13.1)
|
|
52
69
|
simplecov_json_formatter (0.1.4)
|
|
53
|
-
tzinfo (2.0.
|
|
70
|
+
tzinfo (2.0.6)
|
|
54
71
|
concurrent-ruby (~> 1.0)
|
|
72
|
+
uri (1.0.2)
|
|
55
73
|
|
|
56
74
|
PLATFORMS
|
|
75
|
+
aarch64-linux
|
|
76
|
+
x86_64-darwin-20
|
|
57
77
|
x86_64-linux
|
|
58
78
|
|
|
59
79
|
DEPENDENCIES
|
|
@@ -68,4 +88,4 @@ DEPENDENCIES
|
|
|
68
88
|
simplecov
|
|
69
89
|
|
|
70
90
|
BUNDLED WITH
|
|
71
|
-
2.
|
|
91
|
+
2.4.8
|
data/json_schematize.gemspec
CHANGED
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
|
13
13
|
spec.homepage = "https://github.com/matt-taylor/json_schematize"
|
|
14
14
|
spec.license = "MIT"
|
|
15
15
|
|
|
16
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2
|
|
16
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3.2")
|
|
17
17
|
|
|
18
18
|
spec.metadata = {
|
|
19
19
|
"homepage_uri" => spec.homepage,
|
|
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
|
29
29
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
30
30
|
spec.require_paths = ["lib"]
|
|
31
31
|
|
|
32
|
-
spec.add_dependency "class_composer", "
|
|
32
|
+
spec.add_dependency "class_composer", ">= 1.0"
|
|
33
33
|
|
|
34
34
|
spec.add_development_dependency "pry-byebug"
|
|
35
35
|
spec.add_development_dependency "rake", "~> 12.0"
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
module JsonSchematize::Cache::ClassMethods
|
|
4
4
|
module Client
|
|
5
|
-
|
|
6
5
|
def __deserialize_keys__(key_hash_bytes)
|
|
7
6
|
return [{}, 0] if key_hash_bytes.nil?
|
|
8
7
|
|
|
9
8
|
min_expire = Time.now.to_i
|
|
10
|
-
key_hash =
|
|
9
|
+
key_hash = __marshalize__(key_hash_bytes)
|
|
11
10
|
keys_removed = 0
|
|
12
11
|
key_hash.each do |key, expire|
|
|
13
12
|
next if expire.to_i > min_expire
|
|
@@ -22,6 +21,10 @@ module JsonSchematize::Cache::ClassMethods
|
|
|
22
21
|
[{}, 0]
|
|
23
22
|
end
|
|
24
23
|
|
|
24
|
+
def __marshalize__(key_hash_bytes)
|
|
25
|
+
Marshal.load(key_hash_bytes)
|
|
26
|
+
end
|
|
27
|
+
|
|
25
28
|
def __update_record_keeper__!(expire:, cache_key:, delete_key: false)
|
|
26
29
|
record_of_truth = cached_keys(with_expire: true)
|
|
27
30
|
if delete_key
|
|
@@ -39,7 +39,11 @@ class JsonSchematize::Field
|
|
|
39
39
|
|
|
40
40
|
def acceptable_value?(transformed_value:, raise_on_error:)
|
|
41
41
|
if array_of_types
|
|
42
|
-
|
|
42
|
+
if transformed_value.is_a?(empty_value) && required == false
|
|
43
|
+
boolean = true
|
|
44
|
+
else
|
|
45
|
+
boolean = transformed_value.all? { |val| validate_acceptable_types(val: val) }
|
|
46
|
+
end
|
|
43
47
|
else
|
|
44
48
|
boolean = validate_acceptable_types(val: transformed_value)
|
|
45
49
|
end
|
|
@@ -53,7 +57,11 @@ class JsonSchematize::Field
|
|
|
53
57
|
|
|
54
58
|
def acceptable_value_by_validator?(transformed_value:, raw_value:, raise_on_error:)
|
|
55
59
|
if array_of_types
|
|
56
|
-
|
|
60
|
+
if transformed_value.is_a?(empty_value) && required == false
|
|
61
|
+
boolean = true
|
|
62
|
+
else
|
|
63
|
+
boolean = transformed_value.all? { |val| validator.call(transformed_value, raw_value) }
|
|
64
|
+
end
|
|
57
65
|
else
|
|
58
66
|
boolean = validator.call(transformed_value, raw_value)
|
|
59
67
|
end
|
|
@@ -94,6 +102,7 @@ class JsonSchematize::Field
|
|
|
94
102
|
|
|
95
103
|
def iterate_array_of_types(value:)
|
|
96
104
|
return raw_converter_call(value: value) unless array_of_types
|
|
105
|
+
return empty_value.new if value.nil? && required == false
|
|
97
106
|
|
|
98
107
|
unless value.is_a?(Array)
|
|
99
108
|
raise JsonSchematize::InvalidFieldByArrayOfTypes, ":#{name} expected to be an array based on :array_of_types flag. Given #{value.class}"
|
|
@@ -10,7 +10,9 @@ class JsonSchematize::Generator
|
|
|
10
10
|
|
|
11
11
|
include JsonSchematize::Introspect
|
|
12
12
|
|
|
13
|
-
def self.add_field(name:, type: nil, types: nil, dig_type: nil, dig: nil, validator: nil, required: nil, converter: nil, array_of_types: nil, empty_value: nil)
|
|
13
|
+
def self.add_field(name:, type: nil, types: nil, dig_type: nil, dig: nil, validator: nil, required: nil, converter: nil, array_of_types: nil, empty_value: nil, hash_of_types: nil, hash_of_types_key: "name")
|
|
14
|
+
require "json_schematize/empty_value"
|
|
15
|
+
|
|
14
16
|
field_params = {
|
|
15
17
|
converter: converter || schema_defaults[:converter],
|
|
16
18
|
dig: dig || schema_defaults[:dig],
|
metadata
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: json_schematize
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matt Taylor
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2024-12-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: class_composer
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: '1.0'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - "
|
|
24
|
+
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '1.0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
@@ -132,14 +132,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
132
132
|
requirements:
|
|
133
133
|
- - ">="
|
|
134
134
|
- !ruby/object:Gem::Version
|
|
135
|
-
version: '2
|
|
135
|
+
version: '3.2'
|
|
136
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
requirements:
|
|
138
138
|
- - ">="
|
|
139
139
|
- !ruby/object:Gem::Version
|
|
140
140
|
version: '0'
|
|
141
141
|
requirements: []
|
|
142
|
-
rubygems_version: 3.
|
|
142
|
+
rubygems_version: 3.5.9
|
|
143
143
|
signing_key:
|
|
144
144
|
specification_version: 4
|
|
145
145
|
summary: This gem gives you the ability to turn API results into a standardized schema's
|