easol-canvas 3.3.1 → 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: 76b5e740ec1e4c86868924b010cbd13101ebd86b46a49bb719ed289bce268e8c
4
- data.tar.gz: 5d79fe71368fb9bdd0f76c85803957291f34c9fd66c68904c68a7cbfede36680
3
+ metadata.gz: 2e5275a64698399c6ccd64afd11014f878d10e8807bf74e64c0d48e85a3d8bb9
4
+ data.tar.gz: ceee5b6ac86486dbc5c359efe9a25bbe50f798180c6b64eb4b926c51bba45b6c
5
5
  SHA512:
6
- metadata.gz: bbde53fa9c5acbc400c899573b823913e39b732693122925eaa553f6e045bbeba3ad67eac2b20cfec69c9b767259fa3a9b7d947f97e62bf9b34d42ea13d4c8bd
7
- data.tar.gz: c7d11808b5dc2b9eb70f8b22b2a89058bd38cb3cde27389a258cc9abcc27c5e3197a1eb2e58d92fc370683b590e59ba79ab5cbc835427b3112f23288b63fe526
6
+ metadata.gz: 4c83c2f825f1564e12d208098a0af2f926352d27e4e7c4b6aa6002d5983d06153bab1650edb7a02b52fcd9f2fb79302653ee58c9d481e8e86ef50d11d80a46c8
7
+ data.tar.gz: 6e28e6f1839eb050eecc0ca9ecaff1f8c13b0a0ab19a4d979a7aa4714c3423148f8de97f6aee0957eeaa789773f5b43ffc48b477f4e94d32caad51a7c928562d
@@ -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.1"
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.1
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-16 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