frise 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -2
- data/.travis.yml +4 -0
- data/CHANGELOG.md +10 -0
- data/LICENSE.txt +1 -1
- data/frise.gemspec +9 -9
- data/lib/frise/loader.rb +9 -11
- data/lib/frise/loader/lazy.rb +6 -2
- data/lib/frise/validator.rb +8 -10
- data/lib/frise/version.rb +1 -1
- metadata +18 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59666a0c683f8357e7da23de68bd0cc07b386299943e772dd40d9d641ac2d8c7
|
4
|
+
data.tar.gz: 6827402a3f207d909845c0fa386f61cd3d32b989206e15d22b58202830406c88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75c11d0c64a9d0a7f37c3b7702ab2000c09d76900c8c58477bc2426ea47ef766b3c03f77c0fd15928fd55a636009fe33f6e2e19efe8f6454945a3a22ea8b86b3
|
7
|
+
data.tar.gz: 582bb37e6e27f4da44aa496321abf66def05ca151218680c776772fc893824f03ab61ed6e11d3c2006853bd627d53f378eb79f3190033d69869a8ee574184177
|
data/.rubocop.yml
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
AllCops:
|
2
2
|
TargetRubyVersion: '2.3'
|
3
|
+
Layout/EmptyLineAfterGuardClause:
|
4
|
+
Enabled: false
|
3
5
|
Metrics:
|
4
6
|
Enabled: false
|
5
|
-
Naming/
|
7
|
+
Naming/BlockParameterName:
|
6
8
|
Enabled: false
|
7
|
-
Naming/
|
9
|
+
Naming/MethodParameterName:
|
8
10
|
Enabled: false
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
### 0.4.0 (November 29, 2019)
|
2
|
+
|
3
|
+
- Breaking changes
|
4
|
+
- Recursive inclusions now respect the hierarchy of configuration files, avoiding inclusions lower
|
5
|
+
in the hiearchy to be resolved before ones higher in the hierarchy
|
6
|
+
([#14](https://github.com/velocidi/frise/pull/14)).
|
7
|
+
- Bug fixes
|
8
|
+
- Fix error messages from validations happening deeper in the config hierarchy, that were wrongly
|
9
|
+
missing the first character in their path ([#16](https://github.com/velocidi/frise/pull/16)).
|
10
|
+
|
1
11
|
### 0.3.0 (April 16, 2018)
|
2
12
|
|
3
13
|
- Breaking changes
|
data/LICENSE.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright 2017
|
1
|
+
Copyright 2017-2019 Velocidi [http://www.velocidi.com/]
|
2
2
|
|
3
3
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
4
4
|
use this file except in compliance with the License. You may obtain a copy of
|
data/frise.gemspec
CHANGED
@@ -7,11 +7,11 @@ require 'frise/version'
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = 'frise'
|
9
9
|
spec.version = Frise::VERSION
|
10
|
-
spec.authors = ['
|
11
|
-
spec.email = ['
|
10
|
+
spec.authors = ['Velocidi']
|
11
|
+
spec.email = ['hello@velocidi.com']
|
12
12
|
|
13
13
|
spec.summary = 'Ruby config library with schema validation, default values and templating'
|
14
|
-
spec.homepage = 'https://github.com/
|
14
|
+
spec.homepage = 'https://github.com/velocidi/frise'
|
15
15
|
spec.license = 'Apache-2.0'
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
@@ -22,10 +22,10 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.add_dependency 'liquid', '~> 4.0'
|
24
24
|
|
25
|
-
spec.add_development_dependency 'bundler', '~>
|
26
|
-
spec.add_development_dependency 'coveralls', '~> 0.8
|
27
|
-
spec.add_development_dependency 'rake', '~>
|
28
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
29
|
-
spec.add_development_dependency 'rubocop', '0.
|
30
|
-
spec.add_development_dependency 'simplecov', '~> 0.
|
25
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
26
|
+
spec.add_development_dependency 'coveralls', '~> 0.8'
|
27
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.9'
|
29
|
+
spec.add_development_dependency 'rubocop', '0.77.0'
|
30
|
+
spec.add_development_dependency 'simplecov', '~> 0.16'
|
31
31
|
end
|
data/lib/frise/loader.rb
CHANGED
@@ -46,7 +46,7 @@ module Frise
|
|
46
46
|
|
47
47
|
private
|
48
48
|
|
49
|
-
def process_includes(config, at_path, root_config, global_vars)
|
49
|
+
def process_includes(config, at_path, root_config, global_vars, include_confs_stack = [])
|
50
50
|
return config unless config.class == Hash
|
51
51
|
|
52
52
|
# process $content_include directives
|
@@ -63,20 +63,18 @@ module Frise
|
|
63
63
|
end
|
64
64
|
|
65
65
|
# process $include directives
|
66
|
-
config,
|
66
|
+
config, next_include_confs = extract_include(config, at_path)
|
67
|
+
include_confs = next_include_confs + include_confs_stack
|
67
68
|
if include_confs.empty?
|
68
69
|
config.map { |k, v| [k, process_includes(v, at_path + [k], root_config, global_vars)] }.to_h
|
69
70
|
else
|
70
71
|
Lazy.new do
|
71
|
-
include_confs.
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
end
|
78
|
-
updated_root_config = merge_at(root_config, at_path, config)
|
79
|
-
config.map { |k, v| [k, process_includes(v, at_path + [k], updated_root_config, global_vars)] }.to_h
|
72
|
+
include_conf = include_confs.first
|
73
|
+
rest_include_confs = include_confs[1..-1]
|
74
|
+
symbol_table = build_symbol_table(root_config, at_path, config, global_vars, include_conf)
|
75
|
+
included_config = Parser.parse(include_conf['file'], symbol_table)
|
76
|
+
config = @defaults_loader.merge_defaults_obj(config, included_config)
|
77
|
+
process_includes(config, at_path, merge_at(root_config, at_path, config), global_vars, rest_include_confs)
|
80
78
|
end
|
81
79
|
end
|
82
80
|
end
|
data/lib/frise/loader/lazy.rb
CHANGED
@@ -12,11 +12,15 @@ module Frise
|
|
12
12
|
@__target_object__ ||= @callable.call
|
13
13
|
end
|
14
14
|
|
15
|
-
# rubocop:disable Style/
|
15
|
+
# rubocop:disable Style/MethodMissingSuper
|
16
16
|
def method_missing(method_name, *args, &block)
|
17
17
|
__target_object__.send(method_name, *args, &block)
|
18
18
|
end
|
19
|
-
# rubocop:enable Style/
|
19
|
+
# rubocop:enable Style/MethodMissingSuper
|
20
|
+
|
21
|
+
def respond_to_missing?(method_name, include_private = false)
|
22
|
+
__target_object__.respond_to?(method_name, include_private)
|
23
|
+
end
|
20
24
|
end
|
21
25
|
end
|
22
26
|
end
|
data/lib/frise/validator.rb
CHANGED
@@ -27,7 +27,7 @@ module Frise
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def add_validation_error(path, msg)
|
30
|
-
logged_path = path.empty? ? '<root>' : path
|
30
|
+
logged_path = path.empty? ? '<root>' : path
|
31
31
|
@errors << "At #{logged_path}: #{msg}"
|
32
32
|
end
|
33
33
|
|
@@ -37,13 +37,13 @@ module Frise
|
|
37
37
|
default_type = schema[:enum] || schema[:one_of] ? 'Object' : 'Hash'
|
38
38
|
{ type: default_type }.merge(schema)
|
39
39
|
when Symbol then { type: 'Object', validate: schema }
|
40
|
-
when Array
|
40
|
+
when Array
|
41
41
|
if schema.size == 1
|
42
42
|
{ type: 'Array', all: schema[0] }
|
43
43
|
else
|
44
44
|
(raise "Invalid schema: #{schema.inspect}")
|
45
45
|
end
|
46
|
-
when String
|
46
|
+
when String
|
47
47
|
if schema.end_with?('?')
|
48
48
|
{ type: schema[0..-2], optional: true }
|
49
49
|
else
|
@@ -83,8 +83,8 @@ module Frise
|
|
83
83
|
if full_schema[:validate]
|
84
84
|
begin
|
85
85
|
@validators.method(full_schema[:validate]).call(@root, obj)
|
86
|
-
rescue StandardError =>
|
87
|
-
add_validation_error(path,
|
86
|
+
rescue StandardError => e
|
87
|
+
add_validation_error(path, e.message)
|
88
88
|
end
|
89
89
|
end
|
90
90
|
true
|
@@ -115,7 +115,7 @@ module Frise
|
|
115
115
|
def validate_spec_keys(full_schema, obj, path, processed_keys)
|
116
116
|
full_schema.each do |spec_key, spec_value|
|
117
117
|
next if spec_key.is_a?(Symbol)
|
118
|
-
validate_object("#{path}.#{spec_key}", obj[spec_key], spec_value)
|
118
|
+
validate_object(path.empty? ? spec_key : "#{path}.#{spec_key}", obj[spec_key], spec_value)
|
119
119
|
processed_keys << spec_key
|
120
120
|
end
|
121
121
|
true
|
@@ -126,13 +126,11 @@ module Frise
|
|
126
126
|
if expected_types.size == 1 && expected_types[0].ancestors.member?(Enumerable)
|
127
127
|
hash = obj.is_a?(Hash) ? obj : Hash[obj.map.with_index { |x, i| [i, x] }]
|
128
128
|
hash.each do |key, value|
|
129
|
-
if full_schema[:all_keys] && !key.is_a?(Symbol)
|
130
|
-
validate_object(path, key, full_schema[:all_keys])
|
131
|
-
end
|
129
|
+
validate_object(path, key, full_schema[:all_keys]) if full_schema[:all_keys] && !key.is_a?(Symbol)
|
132
130
|
|
133
131
|
next if processed_keys.member? key
|
134
132
|
if full_schema[:all]
|
135
|
-
validate_object("#{path}.#{key}", value, full_schema[:all])
|
133
|
+
validate_object(path.empty? ? key : "#{path}.#{key}", value, full_schema[:all])
|
136
134
|
elsif !full_schema[:allow_unknown_keys]
|
137
135
|
add_validation_error(path, "unknown key: #{key}")
|
138
136
|
end
|
data/lib/frise/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Velocidi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: liquid
|
@@ -30,87 +30,87 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '2.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '2.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: coveralls
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.8
|
47
|
+
version: '0.8'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.8
|
54
|
+
version: '0.8'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '13.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '13.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '3.
|
75
|
+
version: '3.9'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '3.
|
82
|
+
version: '3.9'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rubocop
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - '='
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
89
|
+
version: 0.77.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - '='
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
96
|
+
version: 0.77.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: simplecov
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
103
|
+
version: '0.16'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
110
|
+
version: '0.16'
|
111
111
|
description:
|
112
112
|
email:
|
113
|
-
-
|
113
|
+
- hello@velocidi.com
|
114
114
|
executables: []
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
@@ -132,7 +132,7 @@ files:
|
|
132
132
|
- lib/frise/parser.rb
|
133
133
|
- lib/frise/validator.rb
|
134
134
|
- lib/frise/version.rb
|
135
|
-
homepage: https://github.com/
|
135
|
+
homepage: https://github.com/velocidi/frise
|
136
136
|
licenses:
|
137
137
|
- Apache-2.0
|
138
138
|
metadata: {}
|
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
152
|
version: '0'
|
153
153
|
requirements: []
|
154
154
|
rubyforge_project:
|
155
|
-
rubygems_version: 2.7.
|
155
|
+
rubygems_version: 2.7.3
|
156
156
|
signing_key:
|
157
157
|
specification_version: 4
|
158
158
|
summary: Ruby config library with schema validation, default values and templating
|