easol-canvas 3.2.1 → 3.3.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/validators/schema_attributes/product.rb +25 -3
- data/lib/canvas/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dba3808e67ba544e61935e149356057b6a757454f3b1dbe2b4da9f85035a8edf
|
4
|
+
data.tar.gz: f89ba9a8687bf7ef413a19892892ca2c80482482bb8774e5c3e73030c133b220
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aca6441038d4dd7ddfed0f8d94e7641131cb4972607f7e313ac1c448218553e003850604df4635c07a0afa6cc796e576fea4250c847eb74aad711ff6e6ff7cc5
|
7
|
+
data.tar.gz: 1fa803e9cd5d217c6309ec7b20b0719ac7e27cb9bee9cc8713bc88d3961abd47a25e071242dfb151aa630f2b1d882f63a3dded9641b971ec054f9f476a15aed3
|
@@ -7,10 +7,12 @@ module Canvas
|
|
7
7
|
# Attribute validations specific to product-type variables.
|
8
8
|
class Product < Base
|
9
9
|
ALLOWED_DEFAULT_VALUES = %w[random].freeze
|
10
|
+
ALLOWED_RESTRICTIONS = %w[experiences accommodations extras].freeze
|
10
11
|
|
11
12
|
def validate
|
12
13
|
super &&
|
13
|
-
ensure_default_values_are_valid
|
14
|
+
ensure_default_values_are_valid &&
|
15
|
+
ensure_only_values_are_valid
|
14
16
|
end
|
15
17
|
|
16
18
|
private
|
@@ -23,6 +25,10 @@ module Canvas
|
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
28
|
+
def optional_keys
|
29
|
+
super.merge("only" => Array)
|
30
|
+
end
|
31
|
+
|
26
32
|
def ensure_default_values_are_valid
|
27
33
|
return true unless attribute.key?("default")
|
28
34
|
|
@@ -33,11 +39,27 @@ module Canvas
|
|
33
39
|
end
|
34
40
|
end
|
35
41
|
|
42
|
+
def ensure_only_values_are_valid
|
43
|
+
return true unless attribute.key?("only")
|
44
|
+
|
45
|
+
if attribute["only"].empty?
|
46
|
+
@errors << %["only" cannot be empty]
|
47
|
+
return false
|
48
|
+
end
|
49
|
+
|
50
|
+
unsupported_entries = attribute["only"] - ALLOWED_RESTRICTIONS
|
51
|
+
if unsupported_entries.any?
|
52
|
+
@errors << %["only" for product-type variables must be one of: #{ALLOWED_RESTRICTIONS.join(', ')}]
|
53
|
+
return false
|
54
|
+
end
|
55
|
+
|
56
|
+
true
|
57
|
+
end
|
58
|
+
|
36
59
|
def default_value_is_valid?(value)
|
37
60
|
value = value.downcase
|
38
61
|
if !ALLOWED_DEFAULT_VALUES.include?(value)
|
39
|
-
@errors << "
|
40
|
-
"one of: #{ALLOWED_DEFAULT_VALUES.join(', ')}"
|
62
|
+
@errors << %["default" for product-type variables must be one of: #{ALLOWED_DEFAULT_VALUES.join(', ')}]
|
41
63
|
false
|
42
64
|
else
|
43
65
|
true
|
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: 3.
|
4
|
+
version: 3.3.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: 2023-
|
12
|
+
date: 2023-03-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -171,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
171
|
- !ruby/object:Gem::Version
|
172
172
|
version: '0'
|
173
173
|
requirements: []
|
174
|
-
rubygems_version: 3.3.
|
174
|
+
rubygems_version: 3.3.26
|
175
175
|
signing_key:
|
176
176
|
specification_version: 4
|
177
177
|
summary: CLI to help with building themes for Easol
|