easol-canvas 3.3.0 → 3.4.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: dba3808e67ba544e61935e149356057b6a757454f3b1dbe2b4da9f85035a8edf
4
- data.tar.gz: f89ba9a8687bf7ef413a19892892ca2c80482482bb8774e5c3e73030c133b220
3
+ metadata.gz: 2e5275a64698399c6ccd64afd11014f878d10e8807bf74e64c0d48e85a3d8bb9
4
+ data.tar.gz: ceee5b6ac86486dbc5c359efe9a25bbe50f798180c6b64eb4b926c51bba45b6c
5
5
  SHA512:
6
- metadata.gz: aca6441038d4dd7ddfed0f8d94e7641131cb4972607f7e313ac1c448218553e003850604df4635c07a0afa6cc796e576fea4250c847eb74aad711ff6e6ff7cc5
7
- data.tar.gz: 1fa803e9cd5d217c6309ec7b20b0719ac7e27cb9bee9cc8713bc88d3961abd47a25e071242dfb151aa630f2b1d882f63a3dded9641b971ec054f9f476a15aed3
6
+ metadata.gz: 4c83c2f825f1564e12d208098a0af2f926352d27e4e7c4b6aa6002d5983d06153bab1650edb7a02b52fcd9f2fb79302653ee58c9d481e8e86ef50d11d80a46c8
7
+ data.tar.gz: 6e28e6f1839eb050eecc0ca9ecaff1f8c13b0a0ab19a4d979a7aa4714c3423148f8de97f6aee0957eeaa789773f5b43ffc48b477f4e94d32caad51a7c928562d
@@ -7,7 +7,7 @@ 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
+ ALLOWED_RESTRICTIONS = %w[experiences accommodations].freeze
11
11
 
12
12
  def validate
13
13
  super &&
@@ -10,7 +10,8 @@ module Canvas
10
10
 
11
11
  def validate
12
12
  super &&
13
- ensure_default_values_are_valid
13
+ ensure_default_values_are_valid &&
14
+ ensure_only_from_values_are_valid
14
15
  end
15
16
 
16
17
  private
@@ -23,6 +24,10 @@ module Canvas
23
24
  end
24
25
  end
25
26
 
27
+ def optional_keys
28
+ super.merge("only_from" => Array)
29
+ end
30
+
26
31
  def ensure_default_values_are_valid
27
32
  return true unless attribute.key?("default")
28
33
 
@@ -36,13 +41,29 @@ module Canvas
36
41
  def default_value_is_valid?(value)
37
42
  value = value.downcase
38
43
  if !ALLOWED_DEFAULT_VALUES.include?(value)
39
- @errors << "\"default\" for variant-type variables must be "\
40
- "one of: #{ALLOWED_DEFAULT_VALUES.join(', ')}"
44
+ @errors << %["default" for variant-type variables must be one of: #{ALLOWED_DEFAULT_VALUES.join(', ')}]
41
45
  false
42
46
  else
43
47
  true
44
48
  end
45
49
  end
50
+
51
+ def ensure_only_from_values_are_valid
52
+ return true unless attribute.key?("only_from")
53
+
54
+ if attribute["only_from"].empty?
55
+ @errors << %["only_from" cannot be empty]
56
+ return false
57
+ end
58
+
59
+ unsupported_entries = attribute["only_from"] - Product::ALLOWED_RESTRICTIONS
60
+ if unsupported_entries.any?
61
+ @errors << %["only_from" for variant-type variables must be one of: #{Product::ALLOWED_RESTRICTIONS.join(', ')}]
62
+ return false
63
+ end
64
+
65
+ true
66
+ end
46
67
  end
47
68
  end
48
69
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Canvas
4
- VERSION = "3.3.0"
4
+ VERSION = "3.4.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.3.0
4
+ version: 3.4.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-03-14 00:00:00.000000000 Z
12
+ date: 2023-03-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -98,7 +98,7 @@ dependencies:
98
98
  description: |
99
99
  Canvas is a command line tool to help with building themes for Easol.
100
100
  It provides tooling to check theme directories for errors and to make sure
101
- they confirm with the Easol theme spec.
101
+ they conform with the Easol theme spec.
102
102
  email: developers@easol.com
103
103
  executables:
104
104
  - canvas