easol-canvas 3.3.1 → 4.0.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: dc609cfddb0df9a458af860e381eda6b754b87c059f3cd5d98e88bfe4d2f0ba1
4
+ data.tar.gz: db1a86ed56ebb2dd0ef04c26648a92027fd53be43dd8ec143fcf36cc22c7ead3
5
5
  SHA512:
6
- metadata.gz: bbde53fa9c5acbc400c899573b823913e39b732693122925eaa553f6e045bbeba3ad67eac2b20cfec69c9b767259fa3a9b7d947f97e62bf9b34d42ea13d4c8bd
7
- data.tar.gz: c7d11808b5dc2b9eb70f8b22b2a89058bd38cb3cde27389a258cc9abcc27c5e3197a1eb2e58d92fc370683b590e59ba79ab5cbc835427b3112f23288b63fe526
6
+ metadata.gz: 8daf60e7d01290bcbee438acc338ed817ba21cdf9a3b47a4adc2faad0288595cc8fa2c46093ab31c9182bbdc2ab1ec1dd3104484a11534b7044b315263072759
7
+ data.tar.gz: d02ec887f74f5c30092500c4c92514f91f1253090fb0fac3b33d4aa6c6cb35c6eee44c82a5df9ed0d9ce7eb5a4a231dbdd5eb8db443c98472a42abb105815423
@@ -38,6 +38,7 @@ module Canvas
38
38
  ensure_has_required_keys &&
39
39
  ensure_no_unrecognized_keys &&
40
40
  ensure_keys_are_correct_types &&
41
+ ensure_key_is_lowercase &&
41
42
  ensure_key_value_is_not_reserved &&
42
43
  ensure_no_duplicate_attributes &&
43
44
  ensure_attributes_are_valid &&
@@ -92,6 +93,13 @@ module Canvas
92
93
  true
93
94
  end
94
95
 
96
+ def ensure_key_is_lowercase
97
+ return true if schema["key"] == schema["key"].downcase
98
+
99
+ @errors << %("key" #{schema["key"]} must be lowercase)
100
+ false
101
+ end
102
+
95
103
  # Ensuring the value for key doesn't clash with our primitive type keys.
96
104
  # See {Canvas::Constants::PRIMITIVE_TYPES}
97
105
  def ensure_key_value_is_not_reserved
@@ -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 = "4.0.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: 4.0.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-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor