easol-canvas 3.2.1 → 3.3.0

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: 726899d9c85d1468a3aacd62a4487814bb7e0e030b2b583b41602638dfdbc990
4
- data.tar.gz: 520828b9f285fe794d310a713b9ac3997d67d6b4a2a13df05315629d64ca99c9
3
+ metadata.gz: dba3808e67ba544e61935e149356057b6a757454f3b1dbe2b4da9f85035a8edf
4
+ data.tar.gz: f89ba9a8687bf7ef413a19892892ca2c80482482bb8774e5c3e73030c133b220
5
5
  SHA512:
6
- metadata.gz: d5cf148c156c0af19f9004cf9828f506b4951387e037252dadd8a0a0c11cc8abf62b5861f3a33331bbad22ceb32a1dfd9332576e4244cc12d0ef036bb1491e4f
7
- data.tar.gz: 517b2b9519e7ecb3e0bdfcb4e23d906cfb4d3d4b1a712601464beba36680f3502480c2b8cfa74b8aee24376c77479dd66f13b532875f1d32759e5e17e2181ca5
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 << "\"default\" for product-type variables must be "\
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Canvas
4
- VERSION = "3.2.1"
4
+ VERSION = "3.3.0"
5
5
  end
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.2.1
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-01-06 00:00:00.000000000 Z
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.7
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