easol-canvas 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc609cfddb0df9a458af860e381eda6b754b87c059f3cd5d98e88bfe4d2f0ba1
4
- data.tar.gz: db1a86ed56ebb2dd0ef04c26648a92027fd53be43dd8ec143fcf36cc22c7ead3
3
+ metadata.gz: 98be4111cd6e37ca2bae396a4c47cbb0fb66c6c55a744f192190d22dc1aa34db
4
+ data.tar.gz: f2314e25d61f17907613648fbfd75df92757194e11647e92cf382a735b1b5e0f
5
5
  SHA512:
6
- metadata.gz: 8daf60e7d01290bcbee438acc338ed817ba21cdf9a3b47a4adc2faad0288595cc8fa2c46093ab31c9182bbdc2ab1ec1dd3104484a11534b7044b315263072759
7
- data.tar.gz: d02ec887f74f5c30092500c4c92514f91f1253090fb0fac3b33d4aa6c6cb35c6eee44c82a5df9ed0d9ce7eb5a4a231dbdd5eb8db443c98472a42abb105815423
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.
@@ -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 = "4.0.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: 4.0.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-22 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: []