dsl_compose 2.13.1 → 2.14.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 +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +18 -5
- data/lib/dsl_compose/class_coerce.rb +2 -0
- data/lib/dsl_compose/dsl/arguments/argument/end_with_validation.rb +6 -6
- data/lib/dsl_compose/dsl/arguments/argument/not_end_with_validation.rb +6 -6
- data/lib/dsl_compose/dsl/arguments/argument/not_start_with_validation.rb +6 -6
- data/lib/dsl_compose/dsl/arguments/argument/start_with_validation.rb +6 -6
- data/lib/dsl_compose/dsl/arguments/argument.rb +18 -15
- data/lib/dsl_compose/version.rb +1 -1
- data/sig/dsl_compose/dsl/arguments/argument/end_with_validation.rbs +1 -1
- data/sig/dsl_compose/dsl/arguments/argument/interpreter.rbs +4 -4
- data/sig/dsl_compose/dsl/arguments/argument/not_end_with_validation.rbs +1 -1
- data/sig/dsl_compose/dsl/arguments/argument/not_start_with_validation.rbs +1 -1
- data/sig/dsl_compose/dsl/arguments/argument/start_with_validation.rbs +1 -1
- data/sig/dsl_compose/dsl/arguments/argument.rbs +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 952d89e2f9b95412aec641b8faa5219512290924b02923819ca3438f8d6d1500
|
4
|
+
data.tar.gz: 3f66573596355a16a9477bd6844d552691ea9dded5525335de8ae4b1ca114cea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc1ed1223977ff6acfa4eb6827180673f69f91449ce060f8a1c99e6756e459f78c22261c46bfcf9359e7ac2fc6ea4aa3ba44f9ed839462e04b7518c3a419e928
|
7
|
+
data.tar.gz: af5c4e85b2d3368a57610af4ef4b580651e12b32896dcd61d270f5c2d1ebdcda2acf4341a83497f965c695ace817d1d46d827b3da5696f306bf2febf9e8ff04e
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [2.14.0](https://github.com/craigulliott/dsl_compose/compare/v2.13.1...v2.14.0) (2023-09-06)
|
4
|
+
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
* adding start_with/end_with and format validators to classes ([d390d15](https://github.com/craigulliott/dsl_compose/commit/d390d15bf2ebec2340815ff0a372a938072efd0e))
|
9
|
+
|
3
10
|
## [2.13.1](https://github.com/craigulliott/dsl_compose/compare/v2.13.0...v2.13.1) (2023-09-05)
|
4
11
|
|
5
12
|
|
data/README.md
CHANGED
@@ -597,16 +597,16 @@ The following validations can be added to the arguments of your DSL methods. Val
|
|
597
597
|
validate_in ["cat", "dog"]
|
598
598
|
|
599
599
|
# The argument must start with the following string.
|
600
|
-
validate_start_with [
|
600
|
+
validate_start_with ["foo_"]
|
601
601
|
|
602
602
|
# The argument must not start with the following string.
|
603
|
-
validate_not_start_with [
|
603
|
+
validate_not_start_with ["foo_"]
|
604
604
|
|
605
605
|
# The argument must end with the following string.
|
606
|
-
validate_end_with [
|
606
|
+
validate_end_with ["_foo"]
|
607
607
|
|
608
608
|
# The argument must not end with the following string.
|
609
|
-
validate_not_end_with [
|
609
|
+
validate_not_end_with ["_foo"]
|
610
610
|
|
611
611
|
# The argument must match the provided regex.
|
612
612
|
validate_format /\A[A-Z][a-z]+\Z/
|
@@ -692,7 +692,20 @@ The following validations can be added to the arguments of your DSL methods. Val
|
|
692
692
|
|
693
693
|
requires :my_first_argument, :class do
|
694
694
|
|
695
|
-
#
|
695
|
+
# The class name must start with the following string.
|
696
|
+
validate_start_with ["foo_"]
|
697
|
+
|
698
|
+
# The class name must not start with the following string.
|
699
|
+
validate_not_start_with ["foo_"]
|
700
|
+
|
701
|
+
# The class name must end with the following string.
|
702
|
+
validate_end_with ["_foo"]
|
703
|
+
|
704
|
+
# The class name must not end with the following string.
|
705
|
+
validate_not_end_with ["_foo"]
|
706
|
+
|
707
|
+
# The class name must match the provided regex.
|
708
|
+
validate_format /\A[A-Z][a-z]+\Z/
|
696
709
|
|
697
710
|
end
|
698
711
|
|
@@ -17,19 +17,19 @@ module DSLCompose
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def add_values values
|
20
|
-
# if the provided values is a
|
21
|
-
if values.is_a?
|
20
|
+
# if the provided values is a single item then convert it to an array
|
21
|
+
if values.is_a?(Symbol) || values.is_a?(String)
|
22
22
|
values = [values]
|
23
23
|
end
|
24
24
|
|
25
25
|
# assert that the provided values is an array
|
26
26
|
unless values.is_a? Array
|
27
|
-
raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
|
27
|
+
raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol/String or an Array of Symbols/Strings"
|
28
28
|
end
|
29
29
|
|
30
|
-
# assert that the provided values is an array of symbols
|
31
|
-
unless values.all? { |value| value.is_a? Symbol }
|
32
|
-
raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
|
30
|
+
# assert that the provided values is an array of symbols/strings
|
31
|
+
unless values.all? { |value| value.is_a? Symbol } || values.all? { |value| value.is_a? String }
|
32
|
+
raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol/String or an Array of Symbols/Strings"
|
33
33
|
end
|
34
34
|
|
35
35
|
@values += values
|
@@ -17,19 +17,19 @@ module DSLCompose
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def add_values values
|
20
|
-
# if the provided values is a
|
21
|
-
if values.is_a?
|
20
|
+
# if the provided values is a single item then convert it to an array
|
21
|
+
if values.is_a?(Symbol) || values.is_a?(String)
|
22
22
|
values = [values]
|
23
23
|
end
|
24
24
|
|
25
25
|
# assert that the provided values is an array
|
26
26
|
unless values.is_a? Array
|
27
|
-
raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
|
27
|
+
raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol/String or an Array of Symbols/Strings"
|
28
28
|
end
|
29
29
|
|
30
|
-
# assert that the provided values is an array of symbols
|
31
|
-
unless values.all? { |value| value.is_a? Symbol }
|
32
|
-
raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
|
30
|
+
# assert that the provided values is an array of symbols/strings
|
31
|
+
unless values.all? { |value| value.is_a? Symbol } || values.all? { |value| value.is_a? String }
|
32
|
+
raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol/String or an Array of Symbols/Strings"
|
33
33
|
end
|
34
34
|
|
35
35
|
@values += values
|
@@ -17,19 +17,19 @@ module DSLCompose
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def add_values values
|
20
|
-
# if the provided values is a
|
21
|
-
if values.is_a?
|
20
|
+
# if the provided values is a single item then convert it to an array
|
21
|
+
if values.is_a?(Symbol) || values.is_a?(String)
|
22
22
|
values = [values]
|
23
23
|
end
|
24
24
|
|
25
25
|
# assert that the provided values is an array
|
26
26
|
unless values.is_a? Array
|
27
|
-
raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
|
27
|
+
raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol/String or an Array of Symbols/Strings"
|
28
28
|
end
|
29
29
|
|
30
|
-
# assert that the provided values is an array of symbols
|
31
|
-
unless values.all? { |value| value.is_a? Symbol }
|
32
|
-
raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
|
30
|
+
# assert that the provided values is an array of symbols/strings
|
31
|
+
unless values.all? { |value| value.is_a? Symbol } || values.all? { |value| value.is_a? String }
|
32
|
+
raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol/String or an Array of Symbols/Strings"
|
33
33
|
end
|
34
34
|
|
35
35
|
@values += values
|
@@ -17,19 +17,19 @@ module DSLCompose
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def add_values values
|
20
|
-
# if the provided values is a
|
21
|
-
if values.is_a?
|
20
|
+
# if the provided values is a single item then convert it to an array
|
21
|
+
if values.is_a?(Symbol) || values.is_a?(String)
|
22
22
|
values = [values]
|
23
23
|
end
|
24
24
|
|
25
25
|
# assert that the provided values is an array
|
26
26
|
unless values.is_a? Array
|
27
|
-
raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
|
27
|
+
raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol/String or an Array of Symbols/Strings"
|
28
28
|
end
|
29
29
|
|
30
|
-
# assert that the provided values is an array of symbols
|
31
|
-
unless values.all? { |value| value.is_a? Symbol }
|
32
|
-
raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol or an Array of Symbols"
|
30
|
+
# assert that the provided values is an array of symbols/strings
|
31
|
+
unless values.all? { |value| value.is_a? Symbol } || values.all? { |value| value.is_a? String }
|
32
|
+
raise ValidationFailedError, "The value `#{values}` provided to this validator must be a Symbol/String or an Array of Symbols/Strings"
|
33
33
|
end
|
34
34
|
|
35
35
|
@values += values
|
@@ -225,7 +225,7 @@ module DSLCompose
|
|
225
225
|
raise ValidationInvalidArgumentError, regexp
|
226
226
|
end
|
227
227
|
|
228
|
-
unless @type == :string || @type == :symbol
|
228
|
+
unless @type == :string || @type == :symbol || @type == :class
|
229
229
|
raise ValidationIncompatibleError, "The validation type #{@type} is not compatible with this argument type"
|
230
230
|
end
|
231
231
|
@format_validation = FormatValidation.new regexp
|
@@ -278,11 +278,11 @@ module DSLCompose
|
|
278
278
|
end
|
279
279
|
|
280
280
|
def validate_end_with value
|
281
|
-
unless value.is_a?(Symbol) || (value.is_a?(Array) && value.all? { |value| value.is_a? Symbol })
|
282
|
-
raise ValidationInvalidArgumentError, "The value `#{value}` provided to this validator must be a Symbol or an Array of Symbols"
|
281
|
+
unless value.is_a?(Symbol) || value.is_a?(String) || (value.is_a?(Array) && value.all? { |value| value.is_a? Symbol }) || (value.is_a?(Array) && value.all? { |value| value.is_a? String })
|
282
|
+
raise ValidationInvalidArgumentError, "The value `#{value}` provided to this validator must be a Symbol/String or an Array of Symbols/Strings"
|
283
283
|
end
|
284
284
|
|
285
|
-
unless @type == :string || @type == :symbol
|
285
|
+
unless @type == :string || @type == :symbol || @type == :class
|
286
286
|
raise ValidationIncompatibleError, "The validation type #{@type} is not compatible with this argument type"
|
287
287
|
end
|
288
288
|
|
@@ -295,11 +295,11 @@ module DSLCompose
|
|
295
295
|
end
|
296
296
|
|
297
297
|
def validate_not_end_with value
|
298
|
-
unless value.is_a?(Symbol) || (value.is_a?(Array) && value.all? { |value| value.is_a? Symbol })
|
299
|
-
raise ValidationInvalidArgumentError, "The value `#{value}` provided to this validator must be a Symbol or an Array of Symbols"
|
298
|
+
unless value.is_a?(Symbol) || value.is_a?(String) || (value.is_a?(Array) && value.all? { |value| value.is_a? Symbol }) || (value.is_a?(Array) && value.all? { |value| value.is_a? String })
|
299
|
+
raise ValidationInvalidArgumentError, "The value `#{value}` provided to this validator must be a Symbol/String or an Array of Symbols/Strings"
|
300
300
|
end
|
301
301
|
|
302
|
-
unless @type == :string || @type == :symbol
|
302
|
+
unless @type == :string || @type == :symbol || @type == :class
|
303
303
|
raise ValidationIncompatibleError, "The validation type #{@type} is not compatible with this argument type"
|
304
304
|
end
|
305
305
|
|
@@ -312,11 +312,11 @@ module DSLCompose
|
|
312
312
|
end
|
313
313
|
|
314
314
|
def validate_start_with value
|
315
|
-
unless value.is_a?(Symbol) || (value.is_a?(Array) && value.all? { |value| value.is_a? Symbol })
|
316
|
-
raise ValidationInvalidArgumentError, "The value `#{value}` provided to this validator must be a Symbol or an Array of Symbols"
|
315
|
+
unless value.is_a?(Symbol) || value.is_a?(String) || (value.is_a?(Array) && value.all? { |value| value.is_a? Symbol }) || (value.is_a?(Array) && value.all? { |value| value.is_a? String })
|
316
|
+
raise ValidationInvalidArgumentError, "The value `#{value}` provided to this validator must be a Symbol/String or an Array of Symbols/Strings"
|
317
317
|
end
|
318
318
|
|
319
|
-
unless @type == :string || @type == :symbol
|
319
|
+
unless @type == :string || @type == :symbol || @type == :class
|
320
320
|
raise ValidationIncompatibleError, "The validation type #{@type} is not compatible with this argument type"
|
321
321
|
end
|
322
322
|
|
@@ -329,11 +329,11 @@ module DSLCompose
|
|
329
329
|
end
|
330
330
|
|
331
331
|
def validate_not_start_with value
|
332
|
-
unless value.is_a?(Symbol) || (value.is_a?(Array) && value.all? { |value| value.is_a? Symbol })
|
333
|
-
raise ValidationInvalidArgumentError, "The value `#{value}` provided to this validator must be a Symbol or an Array of Symbols"
|
332
|
+
unless value.is_a?(Symbol) || value.is_a?(String) || (value.is_a?(Array) && value.all? { |value| value.is_a? Symbol }) || (value.is_a?(Array) && value.all? { |value| value.is_a? String })
|
333
|
+
raise ValidationInvalidArgumentError, "The value `#{value}` provided to this validator must be a Symbol/String or an Array of Symbols/Strings"
|
334
334
|
end
|
335
335
|
|
336
|
-
unless @type == :string || @type == :symbol
|
336
|
+
unless @type == :string || @type == :symbol || @type == :class
|
337
337
|
raise ValidationIncompatibleError, "The validation type #{@type} is not compatible with this argument type"
|
338
338
|
end
|
339
339
|
|
@@ -421,8 +421,11 @@ module DSLCompose
|
|
421
421
|
|
422
422
|
# returns true if every provided class validation also returns true
|
423
423
|
def validate_class! value
|
424
|
-
|
425
|
-
|
424
|
+
(format_validation.nil? || format_validation.validate!(value.class_name)) &&
|
425
|
+
(end_with_validation.nil? || end_with_validation.validate!(value.class_name)) &&
|
426
|
+
(not_end_with_validation.nil? || not_end_with_validation.validate!(value.class_name)) &&
|
427
|
+
(start_with_validation.nil? || start_with_validation.validate!(value.class_name)) &&
|
428
|
+
(not_start_with_validation.nil? || not_start_with_validation.validate!(value.class_name))
|
426
429
|
end
|
427
430
|
|
428
431
|
# returns true if every provided object validation also returns true
|
data/lib/dsl_compose/version.rb
CHANGED
@@ -6,7 +6,7 @@ module DSLCompose
|
|
6
6
|
class EndWithValidation
|
7
7
|
@values: Array[Symbol]
|
8
8
|
|
9
|
-
def initialize: (Symbol | Array[Symbol]) -> void
|
9
|
+
def initialize: (Symbol | Array[Symbol] | String | Array[String]) -> void
|
10
10
|
def validate!: (Symbol | String value) -> true
|
11
11
|
|
12
12
|
class InvalidValueError < StandardError
|
@@ -19,10 +19,10 @@ module DSLCompose
|
|
19
19
|
def validate_length: (?minimum: Numeric?, ?maximum: Numeric?, ?is: Numeric?) -> void
|
20
20
|
def validate_not_in: ([Numeric | Symbol | String] values) -> void
|
21
21
|
def validate_in: ([Numeric | Symbol | String] values) -> void
|
22
|
-
def validate_end_with: (Symbol | Array[Symbol] value) -> void
|
23
|
-
def validate_not_end_with: (Symbol | Array[Symbol] value) -> void
|
24
|
-
def validate_start_with: (Symbol | Array[Symbol] value) -> void
|
25
|
-
def validate_not_start_with: (Symbol | Array[Symbol] value) -> void
|
22
|
+
def validate_end_with: (Symbol | Array[Symbol] | String | Array[String] value) -> void
|
23
|
+
def validate_not_end_with: (Symbol | Array[Symbol] | String | Array[String] value) -> void
|
24
|
+
def validate_start_with: (Symbol | Array[Symbol] | String | Array[String] value) -> void
|
25
|
+
def validate_not_start_with: (Symbol | Array[Symbol] | String | Array[String] value) -> void
|
26
26
|
def validate_format: (Regexp regex) -> void
|
27
27
|
def validate_is_a: (String class_name) -> void
|
28
28
|
end
|
@@ -6,7 +6,7 @@ module DSLCompose
|
|
6
6
|
class NotEndWithValidation
|
7
7
|
@values: Array[Symbol]
|
8
8
|
|
9
|
-
def initialize: (Symbol | Array[Symbol]) -> void
|
9
|
+
def initialize: (Symbol | Array[Symbol] | String | Array[String]) -> void
|
10
10
|
def validate!: (Symbol | String value) -> true
|
11
11
|
|
12
12
|
class InvalidValueError < StandardError
|
@@ -6,7 +6,7 @@ module DSLCompose
|
|
6
6
|
class NotStartWithValidation
|
7
7
|
@values: Array[Symbol]
|
8
8
|
|
9
|
-
def initialize: (Symbol | Array[Symbol]) -> void
|
9
|
+
def initialize: (Symbol | Array[Symbol] | String | Array[String]) -> void
|
10
10
|
def validate!: (Symbol | String value) -> true
|
11
11
|
|
12
12
|
class InvalidValueError < StandardError
|
@@ -6,7 +6,7 @@ module DSLCompose
|
|
6
6
|
class StartWithValidation
|
7
7
|
@values: Array[Symbol]
|
8
8
|
|
9
|
-
def initialize: (Symbol | Array[Symbol]) -> void
|
9
|
+
def initialize: (Symbol | Array[Symbol] | String | Array[String]) -> void
|
10
10
|
def validate!: (Symbol | String value) -> true
|
11
11
|
|
12
12
|
class InvalidValueError < StandardError
|
@@ -42,10 +42,10 @@ module DSLCompose
|
|
42
42
|
def validate_equal_to: (Numeric | Symbol | String value) -> void
|
43
43
|
def validate_in: (Array[Numeric | Symbol | String] values) -> void
|
44
44
|
def validate_not_in: (Array[Numeric | Symbol | String] values) -> void
|
45
|
-
def validate_end_with: (Symbol | Array[Symbol] value) -> void
|
46
|
-
def validate_not_end_with: (Symbol | Array[Symbol] value) -> void
|
47
|
-
def validate_start_with: (Symbol | Array[Symbol] value) -> void
|
48
|
-
def validate_not_start_with: (Symbol | Array[Symbol] value) -> void
|
45
|
+
def validate_end_with: (Symbol | Array[Symbol] | String | Array[String] value) -> void
|
46
|
+
def validate_not_end_with: (Symbol | Array[Symbol] | String | Array[String] value) -> void
|
47
|
+
def validate_start_with: (Symbol | Array[Symbol] | String | Array[String] value) -> void
|
48
|
+
def validate_not_start_with: (Symbol | Array[Symbol] | String | Array[String] value) -> void
|
49
49
|
def validate_length: (?maximum: nil | Numeric, ?minimum: nil | Numeric, ?is: nil | Numeric) -> void
|
50
50
|
def validate_is_a: (String class_name) -> void
|
51
51
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dsl_compose
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Craig Ulliott
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: class_spec_helper
|