easol-canvas 3.4.0 → 4.1.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: 2e5275a64698399c6ccd64afd11014f878d10e8807bf74e64c0d48e85a3d8bb9
4
- data.tar.gz: ceee5b6ac86486dbc5c359efe9a25bbe50f798180c6b64eb4b926c51bba45b6c
3
+ metadata.gz: 98be4111cd6e37ca2bae396a4c47cbb0fb66c6c55a744f192190d22dc1aa34db
4
+ data.tar.gz: f2314e25d61f17907613648fbfd75df92757194e11647e92cf382a735b1b5e0f
5
5
  SHA512:
6
- metadata.gz: 4c83c2f825f1564e12d208098a0af2f926352d27e4e7c4b6aa6002d5983d06153bab1650edb7a02b52fcd9f2fb79302653ee58c9d481e8e86ef50d11d80a46c8
7
- data.tar.gz: 6e28e6f1839eb050eecc0ca9ecaff1f8c13b0a0ab19a4d979a7aa4714c3423148f8de97f6aee0957eeaa789773f5b43ffc48b477f4e94d32caad51a7c928562d
6
+ metadata.gz: 7bc304a86f54c1ef6f9733e10832eaecfb5f1b0d83fc4f0672d86c8a7b8fe91575c2c6a4bdfba1395806bd4017b9e6d642fb6521b5f83583455556ba1587b292
7
+ data.tar.gz: c40196d8e6c98ef8015ec1f3aea9f604aa9d9a15ae0a4ef97aa091055502cfb311a3d92805de9208bcf9617fe7d86677ffb038360bcd289efc8e2e54624c007e
@@ -26,6 +26,8 @@ module Canvas
26
26
  string
27
27
  text
28
28
  variant
29
+ package
30
+ date
29
31
  ].freeze
30
32
 
31
33
  # These are types where the value is stored as a primitive type, e.g. string, integer.
@@ -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
@@ -33,6 +33,8 @@ module Canvas
33
33
  "range" => SchemaAttribute::Range,
34
34
  "radio" => SchemaAttribute::Radio,
35
35
  "variant" => SchemaAttribute::Variant,
36
+ "package" => SchemaAttribute::Package,
37
+ "date" => SchemaAttribute::Date,
36
38
  }.freeze
37
39
  RESERVED_NAMES = %w[
38
40
  page
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Canvas
4
+ module Validator
5
+ class SchemaAttribute
6
+ # :documented:
7
+ # Attribute validations specific to package-type variables.
8
+ class Date < Base
9
+ ALLOWED_DEFAULT_VALUES = %w[today].freeze
10
+
11
+ def validate
12
+ super &&
13
+ ensure_default_values_are_valid
14
+ end
15
+
16
+ private
17
+
18
+ def permitted_values_for_default_key
19
+ if attribute["array"]
20
+ Array
21
+ else
22
+ String
23
+ end
24
+ end
25
+
26
+ def ensure_default_values_are_valid
27
+ return true unless attribute.key?("default")
28
+
29
+ if attribute["array"]
30
+ attribute["default"].all? { |value| default_value_is_valid?(value) }
31
+ else
32
+ default_value_is_valid?(attribute["default"])
33
+ end
34
+ end
35
+
36
+ def default_value_is_valid?(value)
37
+ value = value.downcase
38
+ if !ALLOWED_DEFAULT_VALUES.include?(value)
39
+ @errors << "\"default\" for date-type variables must be "\
40
+ "one of: #{ALLOWED_DEFAULT_VALUES.join(', ')}"
41
+ false
42
+ else
43
+ true
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Canvas
4
+ module Validator
5
+ class SchemaAttribute
6
+ # :documented:
7
+ # Attribute validations specific to package-type variables.
8
+ class Package < Base
9
+ ALLOWED_DEFAULT_VALUES = %w[random].freeze
10
+
11
+ def validate
12
+ super &&
13
+ ensure_default_values_are_valid
14
+ end
15
+
16
+ private
17
+
18
+ def permitted_values_for_default_key
19
+ if attribute["array"]
20
+ Array
21
+ else
22
+ String
23
+ end
24
+ end
25
+
26
+ def ensure_default_values_are_valid
27
+ return true unless attribute.key?("default")
28
+
29
+ if attribute["array"]
30
+ attribute["default"].all? { |value| default_value_is_valid?(value) }
31
+ else
32
+ default_value_is_valid?(attribute["default"])
33
+ end
34
+ end
35
+
36
+ def default_value_is_valid?(value)
37
+ value = value.downcase
38
+ if !ALLOWED_DEFAULT_VALUES.include?(value)
39
+ @errors << "\"default\" for package-type variables must be "\
40
+ "one of: #{ALLOWED_DEFAULT_VALUES.join(', ')}"
41
+ false
42
+ else
43
+ true
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Canvas
4
- VERSION = "3.4.0"
4
+ VERSION = "4.1.0"
5
5
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easol-canvas
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Byrne
8
8
  - Ian Mooney
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-03-20 00:00:00.000000000 Z
12
+ date: 2023-04-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -139,9 +139,11 @@ files:
139
139
  - lib/canvas/validators/schema_attribute.rb
140
140
  - lib/canvas/validators/schema_attributes/base.rb
141
141
  - lib/canvas/validators/schema_attributes/color.rb
142
+ - lib/canvas/validators/schema_attributes/date.rb
142
143
  - lib/canvas/validators/schema_attributes/image.rb
143
144
  - lib/canvas/validators/schema_attributes/link.rb
144
145
  - lib/canvas/validators/schema_attributes/number.rb
146
+ - lib/canvas/validators/schema_attributes/package.rb
145
147
  - lib/canvas/validators/schema_attributes/page.rb
146
148
  - lib/canvas/validators/schema_attributes/post.rb
147
149
  - lib/canvas/validators/schema_attributes/product.rb
@@ -156,7 +158,7 @@ homepage: https://rubygems.org/gems/easol-canvas
156
158
  licenses:
157
159
  - MIT
158
160
  metadata: {}
159
- post_install_message:
161
+ post_install_message:
160
162
  rdoc_options: []
161
163
  require_paths:
162
164
  - lib
@@ -172,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
174
  version: '0'
173
175
  requirements: []
174
176
  rubygems_version: 3.3.26
175
- signing_key:
177
+ signing_key:
176
178
  specification_version: 4
177
179
  summary: CLI to help with building themes for Easol
178
180
  test_files: []