dsl_compose 1.8.0 → 1.9.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: f39f962fc5991e68164ab544ca3cb85b7f538296d393f360fdda683956c883bd
4
- data.tar.gz: d68a46d791c33ac1ed435d9be92490ebbd76b053f13d2ef5a17247caf245b148
3
+ metadata.gz: 7fc1bd78d6f3926b9ee718a6e2191cefd5aecd40fcfbb5de9a8cfbd8c602e65c
4
+ data.tar.gz: 7b9fd87ecf61b71831f56ab9120562cb3fbb3d49424dc7862c31014e6dc96d45
5
5
  SHA512:
6
- metadata.gz: 97b3fdcdd3b2ded2028155a9a767fb9cacf8a0e39b00a3cf8e203290d78a7bdbce9119b0b2b856b82afb61c209e24025c9e94991dfa5abe7383f55efc69446e4
7
- data.tar.gz: 38d4eda779bb41af8300ce7d266307eb8fa58529bca51d9c9dcf1589ed1b11f535d4a0746ea359c18f56ca5aae30a13655d987bc0f3de06bf2bdc6f560701f82
6
+ metadata.gz: d3f750f7d8d5d1d7b2014cd84ad10d656d005e2738b18c8ed89f108656b5f9037a428f6ec1094af5382d9788985f3c205c68f06198c8a18e2dfc01f518203cb6
7
+ data.tar.gz: 12a823a699962ee5426a53ab66517f5acb23bd1fbc6834b219d6209d09ba78a9a9b249a1169497a0a2773287f24abf2d7c065c3f126f702bf4927c13180a15aa
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.9.1](https://github.com/craigulliott/dsl_compose/compare/v1.9.0...v1.9.1) (2023-07-11)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * bug fix where argument class was using wrong type check for start and end with validators ([#25](https://github.com/craigulliott/dsl_compose/issues/25)) ([d16fd35](https://github.com/craigulliott/dsl_compose/commit/d16fd35d0b574eafe6ad9d68d4e7f5884e89c521))
9
+
10
+ ## [1.9.0](https://github.com/craigulliott/dsl_compose/compare/v1.8.0...v1.9.0) (2023-07-11)
11
+
12
+
13
+ ### Features
14
+
15
+ * start_with, not_start_with, end_with and not_end_with validators now accept an array of values to test against ([#23](https://github.com/craigulliott/dsl_compose/issues/23)) ([cddcb4b](https://github.com/craigulliott/dsl_compose/commit/cddcb4b629499e3af0d71cc27f5c2f1dd8ae76d5))
16
+
3
17
  ## [1.8.0](https://github.com/craigulliott/dsl_compose/compare/v1.7.0...v1.8.0) (2023-07-11)
4
18
 
5
19
 
data/README.md CHANGED
@@ -293,16 +293,16 @@ The following validations can be added to the arguments of your DSL methods. Val
293
293
  validate_in ["cat", "dog"]
294
294
 
295
295
  # The argument must start with the following string.
296
- validate_start_with ["foo_"]
296
+ validate_start_with [:foo_]
297
297
 
298
298
  # The argument must not start with the following string.
299
- validate_not_start_with ["foo_"]
299
+ validate_not_start_with [:foo_]
300
300
 
301
301
  # The argument must end with the following string.
302
- validate_end_with ["_foo"]
302
+ validate_end_with [:_foo]
303
303
 
304
304
  # The argument must not end with the following string.
305
- validate_not_end_with ["_foo"]
305
+ validate_not_end_with [:_foo]
306
306
 
307
307
  # The argument must match the provided regex.
308
308
  validate_format /\A[A-Z][a-z]+\Z/
@@ -340,16 +340,16 @@ The following validations can be added to the arguments of your DSL methods. Val
340
340
  validate_in [:cat, :dog]
341
341
 
342
342
  # The argument must start with the following string.
343
- validate_start_with ["foo_"]
343
+ validate_start_with [:foo_]
344
344
 
345
345
  # The argument must not start with the following string.
346
- validate_not_start_with ["foo_"]
346
+ validate_not_start_with [:foo_]
347
347
 
348
348
  # The argument must end with the following string.
349
- validate_end_with ["_foo"]
349
+ validate_end_with [:_foo]
350
350
 
351
351
  # The argument must not end with the following string.
352
- validate_not_end_with ["_foo"]
352
+ validate_not_end_with [:_foo]
353
353
 
354
354
  # The argument must match the provided regex.
355
355
  validate_format /\A[A-Z][a-z]+\Z/
@@ -11,16 +11,27 @@ module DSLCompose
11
11
  class ValidationFailedError < StandardError
12
12
  end
13
13
 
14
- def initialize value
15
- unless value.is_a?(String)
16
- raise InvalidValueError, "The value `#{value}` provided to this validator must be of type String"
14
+ def initialize values
15
+ # if the provided values is a symbol, then convert it to an array
16
+ if values.is_a? Symbol
17
+ values = [values]
17
18
  end
18
19
 
19
- @value = value
20
+ # assert that the provided values is an array
21
+ unless values.is_a? Array
22
+ raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
23
+ end
24
+
25
+ # assert that the provided values is an array of symbols
26
+ unless values.all? { |value| value.is_a? Symbol }
27
+ raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
28
+ end
29
+
30
+ @values = values
20
31
  end
21
32
 
22
33
  def validate! value
23
- raise ValidationFailedError, "The argument is invalid. Expected `#{value}` to end with `#{@value}`" unless value.end_with? @value
34
+ raise ValidationFailedError, "The argument is invalid. Expected `#{value}` to end with `#{@values}`" unless @values.filter { |v| value.end_with? v.to_s }.any?
24
35
  true
25
36
  end
26
37
  end
@@ -11,16 +11,27 @@ module DSLCompose
11
11
  class ValidationFailedError < StandardError
12
12
  end
13
13
 
14
- def initialize value
15
- unless value.is_a?(String)
16
- raise InvalidValueError, "The value `#{value}` provided to this validator must be of type String"
14
+ def initialize values
15
+ # if the provided values is a symbol, then convert it to an array
16
+ if values.is_a? Symbol
17
+ values = [values]
17
18
  end
18
19
 
19
- @value = value
20
+ # assert that the provided values is an array
21
+ unless values.is_a? Array
22
+ raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
23
+ end
24
+
25
+ # assert that the provided values is an array of symbols
26
+ unless values.all? { |value| value.is_a? Symbol }
27
+ raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
28
+ end
29
+
30
+ @values = values
20
31
  end
21
32
 
22
33
  def validate! value
23
- raise ValidationFailedError, "The argument is invalid. Expected `#{value}` to not end with `#{@value}`" if value.end_with? @value
34
+ raise ValidationFailedError, "The argument is invalid. Expected `#{value}` to not end with `#{@values}`" if @values.filter { |v| value.end_with? v.to_s }.any?
24
35
  true
25
36
  end
26
37
  end
@@ -11,16 +11,27 @@ module DSLCompose
11
11
  class ValidationFailedError < StandardError
12
12
  end
13
13
 
14
- def initialize value
15
- unless value.is_a?(String)
16
- raise InvalidValueError, "The value `#{value}` provided to this validator must be of type String"
14
+ def initialize values
15
+ # if the provided values is a symbol, then convert it to an array
16
+ if values.is_a? Symbol
17
+ values = [values]
17
18
  end
18
19
 
19
- @value = value
20
+ # assert that the provided values is an array
21
+ unless values.is_a? Array
22
+ raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
23
+ end
24
+
25
+ # assert that the provided values is an array of symbols
26
+ unless values.all? { |value| value.is_a? Symbol }
27
+ raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
28
+ end
29
+
30
+ @values = values
20
31
  end
21
32
 
22
33
  def validate! value
23
- raise ValidationFailedError, "The argument is invalid. Expected `#{value}` to not start with `#{@value}`" if value.start_with? @value
34
+ raise ValidationFailedError, "The argument is invalid. Expected `#{value}` to not start with `#{@values}`" if @values.filter { |v| value.start_with? v.to_s }.any?
24
35
  true
25
36
  end
26
37
  end
@@ -11,16 +11,27 @@ module DSLCompose
11
11
  class ValidationFailedError < StandardError
12
12
  end
13
13
 
14
- def initialize value
15
- unless value.is_a?(String)
16
- raise InvalidValueError, "The value `#{value}` provided to this validator must be of type String"
14
+ def initialize values
15
+ # if the provided values is a symbol, then convert it to an array
16
+ if values.is_a? Symbol
17
+ values = [values]
17
18
  end
18
19
 
19
- @value = value
20
+ # assert that the provided values is an array
21
+ unless values.is_a? Array
22
+ raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
23
+ end
24
+
25
+ # assert that the provided values is an array of symbols
26
+ unless values.all? { |value| value.is_a? Symbol }
27
+ raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
28
+ end
29
+
30
+ @values = values
20
31
  end
21
32
 
22
33
  def validate! value
23
- raise ValidationFailedError, "The argument is invalid. Expected `#{value}` to start with `#{@value}`" unless value.start_with? @value
34
+ raise ValidationFailedError, "The argument is invalid. Expected `#{value}` to start with `#{@values}`" unless @values.filter { |v| value.start_with? v.to_s }.any?
24
35
  true
25
36
  end
26
37
  end
@@ -260,8 +260,8 @@ module DSLCompose
260
260
  raise ValidationAlreadyExistsError, "The validation `end_with` has already been applied to this method option."
261
261
  end
262
262
 
263
- unless value.is_a? String
264
- raise ValidationInvalidArgumentError, value
263
+ unless value.is_a?(Symbol) || (value.is_a?(Array) && value.all? { |value| value.is_a? Symbol })
264
+ raise ValidationInvalidArgumentError, "The value `#{value}` provided to this validator must be a Symbol or an Array of Symbols"
265
265
  end
266
266
 
267
267
  unless @type == :string || @type == :symbol
@@ -276,8 +276,8 @@ module DSLCompose
276
276
  raise ValidationAlreadyExistsError, "The validation `not_end_with` has already been applied to this method option."
277
277
  end
278
278
 
279
- unless value.is_a? String
280
- raise ValidationInvalidArgumentError, value
279
+ unless value.is_a?(Symbol) || (value.is_a?(Array) && value.all? { |value| value.is_a? Symbol })
280
+ raise ValidationInvalidArgumentError, "The value `#{value}` provided to this validator must be a Symbol or an Array of Symbols"
281
281
  end
282
282
 
283
283
  unless @type == :string || @type == :symbol
@@ -292,8 +292,8 @@ module DSLCompose
292
292
  raise ValidationAlreadyExistsError, "The validation `start_with` has already been applied to this method option."
293
293
  end
294
294
 
295
- unless value.is_a? String
296
- raise ValidationInvalidArgumentError, value
295
+ unless value.is_a?(Symbol) || (value.is_a?(Array) && value.all? { |value| value.is_a? Symbol })
296
+ raise ValidationInvalidArgumentError, "The value `#{value}` provided to this validator must be a Symbol or an Array of Symbols"
297
297
  end
298
298
 
299
299
  unless @type == :string || @type == :symbol
@@ -308,8 +308,8 @@ module DSLCompose
308
308
  raise ValidationAlreadyExistsError, "The validation `not_start_with` has already been applied to this method option."
309
309
  end
310
310
 
311
- unless value.is_a? String
312
- raise ValidationInvalidArgumentError, value
311
+ unless value.is_a?(Symbol) || (value.is_a?(Array) && value.all? { |value| value.is_a? Symbol })
312
+ raise ValidationInvalidArgumentError, "The value `#{value}` provided to this validator must be a Symbol or an Array of Symbols"
313
313
  end
314
314
 
315
315
  unless @type == :string || @type == :symbol
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DSLCompose
4
- VERSION = "1.8.0"
4
+ VERSION = "1.9.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dsl_compose
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig Ulliott