easol-canvas 4.0.0 → 4.2.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: dc609cfddb0df9a458af860e381eda6b754b87c059f3cd5d98e88bfe4d2f0ba1
4
- data.tar.gz: db1a86ed56ebb2dd0ef04c26648a92027fd53be43dd8ec143fcf36cc22c7ead3
3
+ metadata.gz: 337d9ed1f2553df0bf83f182d6c4f2480da0ffcbe55b5f835a421f813a7596a9
4
+ data.tar.gz: 975e0dcbcb9c30fbb9356342933ab5ad454fdc71c9fe92a96e200c1ebfc0c190
5
5
  SHA512:
6
- metadata.gz: 8daf60e7d01290bcbee438acc338ed817ba21cdf9a3b47a4adc2faad0288595cc8fa2c46093ab31c9182bbdc2ab1ec1dd3104484a11534b7044b315263072759
7
- data.tar.gz: d02ec887f74f5c30092500c4c92514f91f1253090fb0fac3b33d4aa6c6cb35c6eee44c82a5df9ed0d9ce7eb5a4a231dbdd5eb8db443c98472a42abb105815423
6
+ metadata.gz: 12584574f5e1b4a4759b1d015b6ce32ed2ac08efbf8e8cf9daa36f833cb96ca5b510a27fd9a002783d207fa7667996e3028e86acb86595c53ca629d2d102afd7
7
+ data.tar.gz: 69058651bbeb483e56e533765e554f3a6d08e40eb3c2188bcb81b35ec7452120cda358ad4ac053e1016c043a69b5beda74b11c6972ecd9e528993168d7fd6766
@@ -39,6 +39,7 @@ module Canvas
39
39
  register_tag("accommodation_availability", ::Liquid::Block)
40
40
  register_tag("cache", ::Liquid::Block)
41
41
  register_tag("currency_switcher", ::Liquid::Tag)
42
+ register_tag("json", ::Liquid::Block)
42
43
  end
43
44
  end
44
45
  end
@@ -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.2.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.2.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-05-22 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: []