json_schematize 0.7.0 → 0.8.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/json_schematize.gemspec +2 -0
- data/lib/json_schematize/configuration.rb +10 -10
- data/lib/json_schematize/errors.rb +15 -0
- data/lib/json_schematize/version.rb +1 -1
- data/lib/json_schematize.rb +1 -13
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddc1b50176fdee42d41912116919c05fdd1c34e17c7932b4e588cb380abfd8f5
|
4
|
+
data.tar.gz: ee85dc09adc5d4505e75d04aa524d43f2aa6859ee82eddf474fbdd471613f885
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21a5a7c6d3e194c1ba1149b3b6e37dfe6da7724ee317f8e2d3856b1b917dbcaedad510a8cce42f3c6340b3a66d5b662dc0cac11ce598916b73ef1c59a6aed739
|
7
|
+
data.tar.gz: '09d5cb8dd10a426f98b8fbbc89ab14cb76800f3c3bdb7acb0bb7d640a9a135453732d533b75703a6b639e19b937b8b32ad77c502f804840fbf3ae49b6ec06f7a'
|
data/json_schematize.gemspec
CHANGED
@@ -29,6 +29,8 @@ 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", "~> 1.0"
|
33
|
+
|
32
34
|
spec.add_development_dependency "pry-byebug"
|
33
35
|
spec.add_development_dependency "rake", "~> 12.0"
|
34
36
|
spec.add_development_dependency "rspec", "~> 3.0"
|
@@ -1,7 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "class_composer"
|
4
|
+
require "json_schematize/errors"
|
5
|
+
|
3
6
|
module JsonSchematize
|
4
7
|
class Configuration
|
8
|
+
include ClassComposer::Generator
|
9
|
+
|
5
10
|
DEFAULT_ONE_MIN = 60 * 60
|
6
11
|
DEFAULT_ONE_HOUR = DEFAULT_ONE_MIN * 60
|
7
12
|
DEFAULT_ONE_DAY = DEFAULT_ONE_HOUR * 24
|
@@ -14,16 +19,11 @@ module JsonSchematize
|
|
14
19
|
cache_update_on_change: true,
|
15
20
|
}
|
16
21
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
@cache_namespace = DEFAULT_CACHE_OPTIONS[:cache_namespace]
|
23
|
-
@cache_stochastic_bust = DEFAULT_CACHE_OPTIONS[:cache_stochastic_bust]
|
24
|
-
@cache_ttl = DEFAULT_CACHE_OPTIONS[:cache_ttl]
|
25
|
-
@cache_update_on_change = DEFAULT_CACHE_OPTIONS[:cache_update_on_change]
|
26
|
-
end
|
22
|
+
add_composer :cache_key, allowed: Proc, default: DEFAULT_CACHE_OPTIONS[:cache_key], validation_error_klass: ::JsonSchematize::ConfigError, invalid_message: -> (val) { _assign_msg_("cache_key", "->(val, cusom_key) { val.hash }", "Default proc to assign cache key") }
|
23
|
+
add_composer :cache_namespace, allowed: [String, Symbol]
|
24
|
+
add_composer :cache_stochastic_bust, allowed: [Float, Integer], default: DEFAULT_CACHE_OPTIONS[:cache_stochastic_bust]
|
25
|
+
add_composer :cache_ttl, allowed: [Float, Integer], default: DEFAULT_CACHE_OPTIONS[:cache_ttl]
|
26
|
+
add_composer :cache_update_on_change, allowed: [TrueClass, FalseClass], default: DEFAULT_CACHE_OPTIONS[:cache_update_on_change]
|
27
27
|
|
28
28
|
def cache_hash
|
29
29
|
DEFAULT_CACHE_OPTIONS.map do |key, value|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JsonSchematize
|
4
|
+
class Error < StandardError; end
|
5
|
+
class ConfigError < Error; end
|
6
|
+
class FieldError < Error; end
|
7
|
+
|
8
|
+
class InvalidField < Error; end
|
9
|
+
class InvalidFieldByValidator < InvalidField; end
|
10
|
+
class InvalidFieldByType < InvalidField; end
|
11
|
+
class InvalidFieldByArrayOfTypes < InvalidField; end
|
12
|
+
|
13
|
+
## Customized class errors
|
14
|
+
class UndefinedBoolean < Error; end
|
15
|
+
end
|
data/lib/json_schematize.rb
CHANGED
@@ -1,26 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "json_schematize/version"
|
4
|
-
|
5
3
|
require "json_schematize/base"
|
6
4
|
require "json_schematize/boolean"
|
7
5
|
require "json_schematize/configuration"
|
8
6
|
require "json_schematize/empty_value"
|
7
|
+
require "json_schematize/errors"
|
9
8
|
require "json_schematize/generator"
|
10
9
|
require "json_schematize/version"
|
11
10
|
|
12
11
|
module JsonSchematize
|
13
|
-
class Error < StandardError; end
|
14
|
-
class ConfigError < StandardError; end
|
15
|
-
class FieldError < Error; end
|
16
|
-
class InvalidField < Error; end
|
17
|
-
class InvalidFieldByValidator < InvalidField; end
|
18
|
-
class InvalidFieldByType < InvalidField; end
|
19
|
-
class InvalidFieldByArrayOfTypes < InvalidField; end
|
20
|
-
|
21
|
-
## Customized class errors
|
22
|
-
class UndefinedBoolean < Error; end
|
23
|
-
|
24
12
|
def self.configure
|
25
13
|
yield configuration if block_given?
|
26
14
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_schematize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.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: 2022-
|
11
|
+
date: 2022-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: class_composer
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: pry-byebug
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,6 +111,7 @@ files:
|
|
97
111
|
- lib/json_schematize/cache/instance_methods.rb
|
98
112
|
- lib/json_schematize/configuration.rb
|
99
113
|
- lib/json_schematize/empty_value.rb
|
114
|
+
- lib/json_schematize/errors.rb
|
100
115
|
- lib/json_schematize/field.rb
|
101
116
|
- lib/json_schematize/field_transformations.rb
|
102
117
|
- lib/json_schematize/field_validators.rb
|