easol-canvas 4.4.2 → 4.6.1

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: 59292be54d5354e61c3e0396ac6db3b458edebad0cb8486cea365d6710d7f189
4
- data.tar.gz: b9b2a2ad1b82d425194d0a6a7d33f7381d4a579598e35d1f58d338956acc7f0e
3
+ metadata.gz: 6251539703843a039facee52ca633b179faed7060789ba0b01b5c39b24d78074
4
+ data.tar.gz: 8e16897ef9a6ff7455c472720eaf060a261cd917fb05659f374117e5f3156a85
5
5
  SHA512:
6
- metadata.gz: 39f6a1200c9555233971b2ad89c9371d3b0b55c9de7c8bb8ca520ac7654a3a8fae06982f706cd368563feec3b8351ce0ebf315bc910b75ee17777e61a892db77
7
- data.tar.gz: 8c2421e2ace15c05a10f2160dd5229bfd9d3a32964ee30764ed6421d26f0ab77644452a1bfb99e4f5eafeeef3fe12caad47c594a2e6e7ee770551bb91373789f
6
+ metadata.gz: 6692904d28a5a921424ea2ca8c277dc796f636d70b0c60347d883de57f66e42aaf04819885173b7a331eb90b9548eca28052cc690c29226fe39612afa2865c16
7
+ data.tar.gz: b45b707fa6bc0d767ffbf0af45767e189ba7ac28ad3639e244a1634fff64f55ea4cf3aec91b87cd904396b57f71e2db0f8649a9b4b5f02e176396d2ffc19099e
@@ -28,6 +28,8 @@ module Canvas
28
28
  variant
29
29
  package
30
30
  date
31
+ experience_date
32
+ experience_slot
31
33
  ].freeze
32
34
 
33
35
  # These are types where the value is stored as a primitive type, e.g. string, integer.
@@ -35,6 +35,8 @@ module Canvas
35
35
  "variant" => SchemaAttribute::Variant,
36
36
  "package" => SchemaAttribute::Package,
37
37
  "date" => SchemaAttribute::Date,
38
+ "experience_date" => SchemaAttribute::ExperienceDate,
39
+ "experience_slot" => SchemaAttribute::ExperienceSlot,
38
40
  }.freeze
39
41
  RESERVED_NAMES = %w[
40
42
  page
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Canvas
4
+ module Validator
5
+ class SchemaAttribute
6
+ # :documented:
7
+ # Attribute validations specific to the experience_date variables.
8
+ class ExperienceDate < Base
9
+ ALLOWED_DEFAULT_VALUES = %w[next_upcoming].freeze
10
+
11
+ def validate
12
+ super && ensure_default_values_are_valid
13
+ end
14
+
15
+ private
16
+
17
+ def permitted_values_for_default_key
18
+ if attribute["array"]
19
+ Array
20
+ else
21
+ String
22
+ end
23
+ end
24
+
25
+ def ensure_default_values_are_valid
26
+ return true unless attribute.key?("default")
27
+
28
+ if attribute["array"]
29
+ attribute["default"].all? { |value| default_value_is_valid?(value) }
30
+ else
31
+ default_value_is_valid?(attribute["default"])
32
+ end
33
+ end
34
+
35
+ def default_value_is_valid?(value)
36
+ value = value.downcase
37
+ if !ALLOWED_DEFAULT_VALUES.include?(value)
38
+ @errors << %["default" for experience_date variables must be one of: #{ALLOWED_DEFAULT_VALUES.join(', ')}]
39
+ false
40
+ else
41
+ true
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Canvas
4
+ module Validator
5
+ class SchemaAttribute
6
+ # :documented:
7
+ # Attribute validations specific to the experience_slot variables.
8
+ class ExperienceSlot < Base
9
+ ALLOWED_DEFAULT_VALUES = %w[next_upcoming].freeze
10
+
11
+ def validate
12
+ super && ensure_default_values_are_valid
13
+ end
14
+
15
+ private
16
+
17
+ def permitted_values_for_default_key
18
+ if attribute["array"]
19
+ Array
20
+ else
21
+ String
22
+ end
23
+ end
24
+
25
+ def ensure_default_values_are_valid
26
+ return true unless attribute.key?("default")
27
+
28
+ if attribute["array"]
29
+ attribute["default"].all? { |value| default_value_is_valid?(value) }
30
+ else
31
+ default_value_is_valid?(attribute["default"])
32
+ end
33
+ end
34
+
35
+ def default_value_is_valid?(value)
36
+ value = value.downcase
37
+ if !ALLOWED_DEFAULT_VALUES.include?(value)
38
+ @errors << %["default" for experience_slot variables must be one of: #{ALLOWED_DEFAULT_VALUES.join(', ')}]
39
+ false
40
+ else
41
+ true
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Canvas
4
- VERSION = "4.4.2"
4
+ VERSION = "4.6.1"
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: 4.4.2
4
+ version: 4.6.1
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-08-30 00:00:00.000000000 Z
12
+ date: 2023-12-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -140,6 +140,8 @@ files:
140
140
  - lib/canvas/validators/schema_attributes/base.rb
141
141
  - lib/canvas/validators/schema_attributes/color.rb
142
142
  - lib/canvas/validators/schema_attributes/date.rb
143
+ - lib/canvas/validators/schema_attributes/experience_date.rb
144
+ - lib/canvas/validators/schema_attributes/experience_slot.rb
143
145
  - lib/canvas/validators/schema_attributes/image.rb
144
146
  - lib/canvas/validators/schema_attributes/link.rb
145
147
  - lib/canvas/validators/schema_attributes/number.rb