easol-canvas 4.17.0 → 4.20.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/lib/canvas/checks/valid_custom_types_check.rb +3 -1
- data/lib/canvas/checks/valid_liquid_check.rb +18 -15
- data/lib/canvas/constants.rb +1 -0
- data/lib/canvas/validators/custom_type.rb +4 -3
- data/lib/canvas/validators/schema_attribute.rb +1 -0
- data/lib/canvas/validators/schema_attributes/modifier.rb +49 -0
- data/lib/canvas/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fa515bf37be7d80d67de3a67e92d6097e17d7298fc436a916acf0ca04687d78c
|
|
4
|
+
data.tar.gz: bbc64745d8df45188a081795995e0c92fc86b99f53beef20a69b72741657dd91
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c91c9b333de32d036428dd9bd0c88840e57ea37c3509bb266440ffa6df89fd50d7161edf155ea40f4e22898a0ff1e0a55e0c9900f03fc67a33e0eebf3dbaed19
|
|
7
|
+
data.tar.gz: 2a8d559a57048b770104a5a3faf5536539c081571f37f44717b2850bd4f9ab7e2975f897f87da1b34014e42d5de7ed11712a9ba90b062a8cb6b3cd6676dafd98
|
|
@@ -6,9 +6,11 @@ module Canvas
|
|
|
6
6
|
# custom types that are defined in the /types directory.
|
|
7
7
|
class ValidCustomTypesCheck < Check
|
|
8
8
|
def run
|
|
9
|
+
custom_types = Canvas::FetchCustomTypes.call
|
|
10
|
+
|
|
9
11
|
custom_type_files.each do |filename|
|
|
10
12
|
schema = extract_json(filename)
|
|
11
|
-
validator = Validator::CustomType.new(schema: schema)
|
|
13
|
+
validator = Validator::CustomType.new(schema: schema, custom_types: custom_types)
|
|
12
14
|
|
|
13
15
|
next if validator.validate
|
|
14
16
|
|
|
@@ -30,27 +30,30 @@ module Canvas
|
|
|
30
30
|
::Liquid::Template.register_tag(name, klass)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
# These are the tags that we define in the Rails app. If we add a
|
|
34
|
-
# in the Rails app, we'll need to register it here.
|
|
33
|
+
# These are the tags that we define in the Rails app. If we add a
|
|
34
|
+
# new custom tag in the Rails app, we'll need to register it here.
|
|
35
35
|
def register_tags!
|
|
36
|
-
|
|
37
|
-
register_tag("product_search", ::Liquid::Block)
|
|
38
|
-
register_tag("easol_badge", ::Liquid::Tag)
|
|
39
|
-
register_tag("accommodation_availability", ::Liquid::Block)
|
|
40
|
-
register_tag("cache", ::Liquid::Block)
|
|
41
|
-
register_tag("currency_switcher", ::Liquid::Tag)
|
|
42
|
-
register_tag("json", ::Liquid::Block)
|
|
43
|
-
register_tag("variant_pricing", ::Liquid::Tag)
|
|
44
|
-
register_tag("dynamic_package_booking_price", ::Liquid::Tag)
|
|
36
|
+
# Single statement non-block tags, no closing tag required.
|
|
45
37
|
register_tag("cart_timer", ::Liquid::Tag)
|
|
46
38
|
register_tag("cart_timer_add_time", ::Liquid::Tag)
|
|
47
|
-
register_tag("
|
|
48
|
-
register_tag("
|
|
49
|
-
register_tag("
|
|
50
|
-
register_tag("package_price", Liquid::Block)
|
|
39
|
+
register_tag("currency_switcher", ::Liquid::Tag)
|
|
40
|
+
register_tag("dynamic_package_booking_price", ::Liquid::Tag)
|
|
41
|
+
register_tag("easol_badge", ::Liquid::Tag)
|
|
51
42
|
register_tag("input", ::Liquid::Tag)
|
|
52
43
|
register_tag("label", ::Liquid::Tag)
|
|
44
|
+
register_tag("variant_pricing", ::Liquid::Tag)
|
|
45
|
+
# Tags wrapping nested content with a closing tag.
|
|
46
|
+
register_tag("accommodation_availability", ::Liquid::Block)
|
|
47
|
+
register_tag("cache", ::Liquid::Block)
|
|
48
|
+
register_tag("experience_slot_calendar", ::Liquid::Block)
|
|
49
|
+
register_tag("experience_slot_search", ::Liquid::Block)
|
|
50
|
+
register_tag("form", ::Liquid::Block)
|
|
51
|
+
register_tag("json", ::Liquid::Block)
|
|
52
|
+
register_tag("package_availability", ::Liquid::Block)
|
|
53
|
+
register_tag("package_price", ::Liquid::Block)
|
|
53
54
|
register_tag("package_step_product_search", ::Liquid::Block)
|
|
55
|
+
register_tag("packages_search_and_calendar", ::Liquid::Block)
|
|
56
|
+
register_tag("product_search", ::Liquid::Block)
|
|
54
57
|
end
|
|
55
58
|
end
|
|
56
59
|
end
|
data/lib/canvas/constants.rb
CHANGED
|
@@ -26,10 +26,11 @@ module Canvas
|
|
|
26
26
|
class CustomType
|
|
27
27
|
REQUIRED_KEYS = %w[key name attributes].freeze
|
|
28
28
|
|
|
29
|
-
attr_reader :schema, :errors
|
|
29
|
+
attr_reader :schema, :errors, :custom_types
|
|
30
30
|
|
|
31
|
-
def initialize(schema:)
|
|
31
|
+
def initialize(schema:, custom_types: [])
|
|
32
32
|
@schema = schema
|
|
33
|
+
@custom_types = custom_types
|
|
33
34
|
@errors = []
|
|
34
35
|
end
|
|
35
36
|
|
|
@@ -127,7 +128,7 @@ module Canvas
|
|
|
127
128
|
schema["attributes"].each do |attribute_schema|
|
|
128
129
|
attr_validator = Validator::SchemaAttribute.new(
|
|
129
130
|
attribute: attribute_schema,
|
|
130
|
-
custom_types:
|
|
131
|
+
custom_types: custom_types
|
|
131
132
|
)
|
|
132
133
|
next if attr_validator.validate
|
|
133
134
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Canvas
|
|
4
|
+
module Validator
|
|
5
|
+
class SchemaAttribute
|
|
6
|
+
# :documented:
|
|
7
|
+
# Attribute validations specific to modifier-type variables.
|
|
8
|
+
# Modifier drops expose name and id properties for use in site builder schemas.
|
|
9
|
+
class Modifier < Base
|
|
10
|
+
ALLOWED_DEFAULT_VALUES = %w[random].freeze
|
|
11
|
+
|
|
12
|
+
def validate
|
|
13
|
+
super &&
|
|
14
|
+
ensure_default_values_are_valid
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def permitted_values_for_default_key
|
|
20
|
+
if attribute["array"]
|
|
21
|
+
Array
|
|
22
|
+
else
|
|
23
|
+
String
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def ensure_default_values_are_valid
|
|
28
|
+
return true unless attribute.key?("default")
|
|
29
|
+
|
|
30
|
+
if attribute["array"]
|
|
31
|
+
attribute["default"].all? { |value| default_value_is_valid?(value) }
|
|
32
|
+
else
|
|
33
|
+
default_value_is_valid?(attribute["default"])
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def default_value_is_valid?(value)
|
|
38
|
+
value = value.downcase
|
|
39
|
+
if !ALLOWED_DEFAULT_VALUES.include?(value)
|
|
40
|
+
@errors << %["default" for modifier-type variables must be one of: #{ALLOWED_DEFAULT_VALUES.join(', ')}]
|
|
41
|
+
false
|
|
42
|
+
else
|
|
43
|
+
true
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
data/lib/canvas/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: easol-canvas
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.20.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kyle Byrne
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2026-01-15 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: thor
|
|
@@ -145,6 +145,7 @@ files:
|
|
|
145
145
|
- lib/canvas/validators/schema_attributes/experience_slot.rb
|
|
146
146
|
- lib/canvas/validators/schema_attributes/image.rb
|
|
147
147
|
- lib/canvas/validators/schema_attributes/link.rb
|
|
148
|
+
- lib/canvas/validators/schema_attributes/modifier.rb
|
|
148
149
|
- lib/canvas/validators/schema_attributes/number.rb
|
|
149
150
|
- lib/canvas/validators/schema_attributes/package.rb
|
|
150
151
|
- lib/canvas/validators/schema_attributes/page.rb
|