frise 0.5.1 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68f89536d127f91e812a1c23258ad32ca3d4331970c9af0632cb3f95fce06e52
4
- data.tar.gz: 129230d3c50d29a25f4e060bfdf4e839d19aa579607c6bead51acf6237ac9c20
3
+ metadata.gz: 1faacd4d96a4fcdaaa2133b658a422a1c5e232d33592d99429dc57f2e540162b
4
+ data.tar.gz: 2e36a6db49fb71cff79c0a60c255703f41bf08d7e2779c86b4530cc813082cac
5
5
  SHA512:
6
- metadata.gz: 61f5a83ff2ba3e17ae022dbac6639fa3a316c4739685ed3cec8634a9a12789dd280c4373763bdebea85d82821b02856327df0df6fbb423d55affb8010252ec64
7
- data.tar.gz: bc65274a574e25cdbe6142bd7bc2dbe7d6d9275143c211987845dc916156ebe2f0d3ff5739490ea177b67157545b6c5c4aef0a96bbe6dfbaa6f9061c35fcfd73
6
+ metadata.gz: 72b08fa1c24a177b8c8fe1086e2eb7782faa1b9b08346080cec5b609577704375e31631d8bfc1c962c7c7d6f81f9b0af38d6aefe2350c117ac6c7a425479cf3e
7
+ data.tar.gz: 4115d96508ceeebbf472bc845285334c47b70ec3318e567442fbea3720f41dafabfc6b92910f9212eeb3b5473f60488b69c89f57cc1339f63f0b10aa6dc33570
@@ -9,10 +9,15 @@ jobs:
9
9
  strategy:
10
10
  fail-fast: false
11
11
  matrix:
12
- ruby: [ 2.6, 2.7, 3 ]
12
+ ruby:
13
+ - '2.6'
14
+ - '2.7'
15
+ - '3.0'
16
+ - '3.1'
17
+ - '3.2'
13
18
 
14
19
  steps:
15
- - uses: actions/checkout@v2
20
+ - uses: actions/checkout@v3
16
21
  - name: Set up Ruby
17
22
  uses: ruby/setup-ruby@v1
18
23
  with:
@@ -24,8 +29,10 @@ jobs:
24
29
  run: bundle exec rake
25
30
  - name: Coveralls Parallel
26
31
  uses: coverallsapp/github-action@master
32
+ env:
33
+ # We're concatenating the run ID with the run attempt so that each run has a different ID for Coveralls.
34
+ COVERALLS_SERVICE_JOB_ID: '${{ github.run_id }} ${{ github.run_attempt }}'
27
35
  with:
28
- github-token: ${{ secrets.github_token }}
29
36
  flag-name: ${{ matrix.ruby }}
30
37
  parallel: true
31
38
 
@@ -35,6 +42,9 @@ jobs:
35
42
  steps:
36
43
  - name: Coveralls Finished
37
44
  uses: coverallsapp/github-action@master
45
+ env:
46
+ # We're concatenating the run ID with the run attempt so that each run has a different ID for Coveralls.
47
+ COVERALLS_SERVICE_JOB_ID: '${{ github.run_id }} ${{ github.run_attempt }}'
38
48
  with:
39
- github-token: ${{ secrets.github_token }}
40
49
  parallel-finished: true
50
+ carryforward: '2.6,2.7,3.0,3.1,3.2'
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
@@ -9,3 +8,4 @@
9
8
  /tmp/
10
9
 
11
10
  *.iml
11
+ .DS_Store
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ### 0.6.1 (June 13, 2023)
2
+
3
+ - New features
4
+ - New schema type `$constant` for specifying values with a single possible instance
5
+ ([#32](https://github.com/adzerk/frise/pull/32)).
6
+
7
+ ### 0.6.0 (April 7, 2022)
8
+
9
+ - Breaking changes
10
+ - Liquid parsing is now strict ([#29](https://github.com/velocidi/frise/pull/29)).
11
+ - Update liquid gem to `5.3.0` ([#29](https://github.com/velocidi/frise/pull/29)).
12
+
13
+ - New features
14
+ - Add `json` liquid filter ([#28](https://github.com/velocidi/frise/pull/28)).
15
+
1
16
  ### 0.5.1 (March 28, 2022)
2
17
 
3
18
  - Breaking changes
data/Gemfile.lock ADDED
@@ -0,0 +1,71 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ frise (0.6.1.pre)
5
+ liquid (~> 5.3.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ diff-lcs (1.5.0)
12
+ docile (1.4.0)
13
+ liquid (5.3.0)
14
+ parallel (1.23.0)
15
+ parser (3.2.2.3)
16
+ ast (~> 2.4.1)
17
+ racc
18
+ racc (1.7.0)
19
+ rainbow (3.1.1)
20
+ rake (13.0.6)
21
+ regexp_parser (2.8.1)
22
+ rexml (3.2.5)
23
+ rspec (3.12.0)
24
+ rspec-core (~> 3.12.0)
25
+ rspec-expectations (~> 3.12.0)
26
+ rspec-mocks (~> 3.12.0)
27
+ rspec-core (3.12.2)
28
+ rspec-support (~> 3.12.0)
29
+ rspec-expectations (3.12.3)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.12.0)
32
+ rspec-mocks (3.12.5)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.12.0)
35
+ rspec-support (3.12.0)
36
+ rubocop (1.10.0)
37
+ parallel (~> 1.10)
38
+ parser (>= 3.0.0.0)
39
+ rainbow (>= 2.2.2, < 4.0)
40
+ regexp_parser (>= 1.8, < 3.0)
41
+ rexml
42
+ rubocop-ast (>= 1.2.0, < 2.0)
43
+ ruby-progressbar (~> 1.7)
44
+ unicode-display_width (>= 1.4.0, < 3.0)
45
+ rubocop-ast (1.29.0)
46
+ parser (>= 3.2.1.0)
47
+ ruby-progressbar (1.13.0)
48
+ simplecov (0.22.0)
49
+ docile (~> 1.1)
50
+ simplecov-html (~> 0.11)
51
+ simplecov_json_formatter (~> 0.1)
52
+ simplecov-html (0.12.3)
53
+ simplecov-lcov (0.8.0)
54
+ simplecov_json_formatter (0.1.4)
55
+ unicode-display_width (2.4.2)
56
+
57
+ PLATFORMS
58
+ arm64-darwin-22
59
+ x86_64-linux
60
+
61
+ DEPENDENCIES
62
+ bundler (~> 2.0)
63
+ frise!
64
+ rake (~> 13.0)
65
+ rspec (~> 3.9)
66
+ rubocop (~> 1.10.0)
67
+ simplecov (~> 0.18)
68
+ simplecov-lcov (= 0.8.0)
69
+
70
+ BUNDLED WITH
71
+ 2.4.12
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2017-2019 Velocidi [http://www.velocidi.com/]
1
+ Copyright 2017-2023 Kevel [https://www.kevel.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Frise
2
- [![Build Status](https://travis-ci.org/velocidi/frise.svg?branch=master)](https://travis-ci.org/velocidi/frise)
3
- [![Coverage Status](https://coveralls.io/repos/github/velocidi/frise/badge.svg?branch=master)](https://coveralls.io/github/velocidi/frise?branch=master)
2
+ [![Build Status](https://github.com/adzerk/frise/actions/workflows/CI.yml/badge.svg?branch=master)](https://github.com/adzerk/frise/actions/workflows/CI.yml)
3
+ [![Coverage Status](https://coveralls.io/repos/github/adzerk/frise/badge.svg?branch=master)](https://coveralls.io/github/adzerk/frise?branch=master)
4
4
  [![Gem Version](https://badge.fury.io/rb/frise.svg)](https://badge.fury.io/rb/frise)
5
5
 
6
6
  Frise is a library for loading configuration files as native Ruby structures. Besides reading and
data/frise.gemspec CHANGED
@@ -20,12 +20,12 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ['lib']
21
21
  spec.required_ruby_version = '>= 2.6.0'
22
22
 
23
- spec.add_dependency 'liquid', '~> 4.0'
23
+ spec.add_dependency 'liquid', '~> 5.3.0'
24
24
 
25
25
  spec.add_development_dependency 'bundler', '~> 2.0'
26
26
  spec.add_development_dependency 'rake', '~> 13.0'
27
27
  spec.add_development_dependency 'rspec', '~> 3.9'
28
- spec.add_development_dependency 'rubocop', '~> 1.10'
28
+ spec.add_development_dependency 'rubocop', '~> 1.10.0'
29
29
  spec.add_development_dependency 'simplecov', '~> 0.18'
30
30
  spec.add_development_dependency 'simplecov-lcov', '0.8.0'
31
31
  spec.metadata['rubygems_mfa_required'] = 'true'
data/lib/frise/parser.rb CHANGED
@@ -16,7 +16,12 @@ module Frise
16
16
  def parse_as_text(file, symbol_table = nil)
17
17
  return nil unless File.file? file
18
18
  content = File.read(file)
19
- content = Liquid::Template.parse(content).render with_internal_vars(file, symbol_table) if symbol_table
19
+ template = Liquid::Template.parse(content, error_mode: :strict)
20
+ if symbol_table
21
+ content = template.render!(with_internal_vars(file, symbol_table), {
22
+ strict_filters: true
23
+ })
24
+ end
20
25
  content
21
26
  end
22
27
 
@@ -36,7 +36,7 @@ module Frise
36
36
  def get_full_schema(schema)
37
37
  case schema
38
38
  when Hash
39
- default_type = schema[:enum] || schema[:one_of] ? 'Object' : 'Hash'
39
+ default_type = schema[:enum] || schema[:one_of] || schema.key?(:constant) ? 'Object' : 'Hash'
40
40
  { type: default_type }.merge(schema)
41
41
  when Symbol then { type: 'Object', validate: schema }
42
42
  when Array
@@ -114,6 +114,14 @@ module Frise
114
114
  true
115
115
  end
116
116
 
117
+ def validate_constant(full_schema, obj, path)
118
+ if full_schema.key?(:constant) && full_schema[:constant] != obj
119
+ add_validation_error(path, "invalid value #{obj.inspect}. " \
120
+ "The only accepted value is #{full_schema[:constant]}")
121
+ end
122
+ true
123
+ end
124
+
117
125
  def validate_spec_keys(full_schema, obj, path, processed_keys)
118
126
  full_schema.each do |spec_key, spec_value|
119
127
  next if spec_key.is_a?(Symbol)
@@ -149,6 +157,7 @@ module Frise
149
157
  return unless validate_custom(full_schema, obj, path)
150
158
  return unless validate_enum(full_schema, obj, path)
151
159
  return unless validate_one_of(full_schema, obj, path)
160
+ return unless validate_constant(full_schema, obj, path)
152
161
 
153
162
  processed_keys = Set.new
154
163
  return unless validate_spec_keys(full_schema, obj, path, processed_keys)
data/lib/frise/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Frise
4
- VERSION = '0.5.1'
4
+ VERSION = '0.6.1'
5
5
  end
data/lib/frise.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'liquid/liquid'
4
+
3
5
  require 'frise/defaults_loader'
4
6
  require 'frise/loader/lazy'
5
7
  require 'frise/loader'
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+
5
+ # Converts a variable into its JSON representation
6
+ module JsonFilter
7
+ def json(object)
8
+ JSON.dump(object)
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'liquid'
4
+
5
+ require_relative 'json_filter'
6
+
7
+ Liquid::Template.register_filter(JsonFilter)
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.5.1
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Velocidi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-28 00:00:00.000000000 Z
11
+ date: 2023-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: liquid
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: 5.3.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
- version: '4.0'
26
+ version: 5.3.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.10'
75
+ version: 1.10.0
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: '1.10'
82
+ version: 1.10.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: simplecov
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -121,6 +121,7 @@ files:
121
121
  - ".rubocop.yml"
122
122
  - CHANGELOG.md
123
123
  - Gemfile
124
+ - Gemfile.lock
124
125
  - LICENSE.txt
125
126
  - README.md
126
127
  - Rakefile
@@ -132,6 +133,8 @@ files:
132
133
  - lib/frise/parser.rb
133
134
  - lib/frise/validator.rb
134
135
  - lib/frise/version.rb
136
+ - lib/liquid/json_filter.rb
137
+ - lib/liquid/liquid.rb
135
138
  homepage: https://github.com/velocidi/frise
136
139
  licenses:
137
140
  - Apache-2.0
@@ -152,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
155
  - !ruby/object:Gem::Version
153
156
  version: '0'
154
157
  requirements: []
155
- rubygems_version: 3.3.7
158
+ rubygems_version: 3.4.12
156
159
  signing_key:
157
160
  specification_version: 4
158
161
  summary: Ruby config library with schema validation, default values and templating