dsl_compose 2.2.1 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/README.md +6 -0
- data/lib/dsl_compose/dsl/arguments/argument.rb +6 -0
- data/lib/dsl_compose/dsl/interpreter.rb +2 -2
- data/lib/dsl_compose/interpreter/execution/arguments.rb +14 -0
- data/lib/dsl_compose/parser/for_children_of_parser/for_dsl_parser.rb +10 -0
- data/lib/dsl_compose/version.rb +1 -1
- 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: 4fab8958e567edd7044bfef529f74c21930c7c1fba06bfd359d905249fc2d17c
|
4
|
+
data.tar.gz: a167ad2aaaf44b226b2884ee0f4d6447444ebe0629453ca5f288430c5198e683
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcd2f5ff1b501cffd445d937f4a96e158250e8e76e48969d54760511dc339dc90e0d7d1d3f4f2ed5a14ffc0eafe037a8833122a0f649c071a8188e1819901bb4
|
7
|
+
data.tar.gz: e1df9014ea4b8a20db709e44284ce320a92808085aee70004a4bac19609fad866f271426e2e86c7ec46919f21795f55c91411b1404f73cfd0349544ef71ee408
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [2.3.0](https://github.com/craigulliott/dsl_compose/compare/v2.2.2...v2.3.0) (2023-07-28)
|
4
|
+
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
* added a method_called? helper method to the DSL parser ([48e68a8](https://github.com/craigulliott/dsl_compose/commit/48e68a8d799e297d3433f3d2a6bccb7a077dd9af))
|
9
|
+
|
10
|
+
## [2.2.2](https://github.com/craigulliott/dsl_compose/compare/v2.2.1...v2.2.2) (2023-07-27)
|
11
|
+
|
12
|
+
|
13
|
+
### Bug Fixes
|
14
|
+
|
15
|
+
* argument type :float was not accepting values and did not have validations ([243eff1](https://github.com/craigulliott/dsl_compose/commit/243eff1d0d0cc48602cc626e8a91cdc45b4f9955))
|
16
|
+
|
3
17
|
## [2.2.1](https://github.com/craigulliott/dsl_compose/compare/v2.2.0...v2.2.1) (2023-07-27)
|
4
18
|
|
5
19
|
|
data/README.md
CHANGED
@@ -286,6 +286,12 @@ class MyParser < DSLCompose::Parser
|
|
286
286
|
other than making calls to `for_method`
|
287
287
|
DESCRIPTION
|
288
288
|
|
289
|
+
# Within a `for_dsl` block you can determine if a specific DSL method was used
|
290
|
+
# with the `method_called?` method. This method will return true if the method was
|
291
|
+
# used, otherwise it will return false. If a method with the provided name does not
|
292
|
+
# exist for the DSL, then an error will be raised.
|
293
|
+
was_some_method_name_used = method_called? :some_method_name
|
294
|
+
|
289
295
|
# `for_method` accepts a method name or an array of method names and will
|
290
296
|
# yield it's provided block once for each time a method with this name is
|
291
297
|
# executed within the DSL.
|
@@ -362,6 +362,12 @@ module DSLCompose
|
|
362
362
|
(length_validation.nil? || length_validation.validate!(value))
|
363
363
|
end
|
364
364
|
|
365
|
+
# returns true if every provided float validation also returns true
|
366
|
+
def validate_float! value
|
367
|
+
# floats are validated with the same set of validators as integers
|
368
|
+
validate_integer! value
|
369
|
+
end
|
370
|
+
|
365
371
|
# returns true if every provided symbol validation also returns true
|
366
372
|
def validate_symbol! value
|
367
373
|
(format_validation.nil? || format_validation.validate!(value)) &&
|
@@ -51,7 +51,7 @@ module DSLCompose
|
|
51
51
|
# adds a new optional argument to the DSLMethod
|
52
52
|
#
|
53
53
|
# name must be a symbol
|
54
|
-
# `type` can be either :integer, :boolean, :float, :string or :
|
54
|
+
# `type` can be either :integer, :boolean, :float, :string, :symbol, :class or :object
|
55
55
|
# `block` contains the argument definition and will be evaluated seperately
|
56
56
|
# by the Argument::Interpreter
|
57
57
|
def optional name, type, array: false, &block
|
@@ -61,7 +61,7 @@ module DSLCompose
|
|
61
61
|
# adds a new required argument to the DSLMethod
|
62
62
|
#
|
63
63
|
# name must be a symbol
|
64
|
-
# `type` can be either :integer, :boolean, :float, :string or :
|
64
|
+
# `type` can be either :integer, :boolean, :float, :string, :symbol, :class or :object
|
65
65
|
# `block` contains the argument definition and will be evaluated seperately
|
66
66
|
# by the Argument::Interpreter
|
67
67
|
def requires name, type, array: false, &block
|
@@ -91,6 +91,13 @@ module DSLCompose
|
|
91
91
|
end
|
92
92
|
optional_argument.validate_integer! value
|
93
93
|
|
94
|
+
when :float
|
95
|
+
# float allows either floats or integers
|
96
|
+
unless value.is_a?(Float) || value.is_a?(Integer)
|
97
|
+
raise InvalidArgumentTypeError, "`#{value}` is not an Float or Integer"
|
98
|
+
end
|
99
|
+
optional_argument.validate_float! value
|
100
|
+
|
94
101
|
when :symbol
|
95
102
|
unless value.is_a? Symbol
|
96
103
|
raise InvalidArgumentTypeError, "`#{value}` is not a Symbol"
|
@@ -175,6 +182,13 @@ module DSLCompose
|
|
175
182
|
end
|
176
183
|
required_argument.validate_integer! value
|
177
184
|
|
185
|
+
when :float
|
186
|
+
# float allows either floats or integers
|
187
|
+
unless value.is_a?(Float) || value.is_a?(Integer)
|
188
|
+
raise InvalidArgumentTypeError, "`#{value}` is not an Float or Integer"
|
189
|
+
end
|
190
|
+
required_argument.validate_float! value
|
191
|
+
|
178
192
|
when :symbol
|
179
193
|
unless value.is_a? Symbol
|
180
194
|
raise InvalidArgumentTypeError, "`#{value}` is not a Symbol"
|
@@ -109,6 +109,16 @@ module DSLCompose
|
|
109
109
|
ForMethodParser.new(@base_class, @child_class, @dsl_execution, method_names, &block)
|
110
110
|
end
|
111
111
|
|
112
|
+
# Given a method name, will return true if the method was called within the current DSL
|
113
|
+
# execution, otherwise it will return false
|
114
|
+
def method_called? method_name
|
115
|
+
# get the dsl method from the current dsl execution, this
|
116
|
+
# will raise an error if the method does not exist
|
117
|
+
dsl_method = @dsl_execution.dsl.dsl_method(method_name)
|
118
|
+
# was this method called within the current DSL execution?
|
119
|
+
@dsl_execution.method_calls.method_called? dsl_method.name
|
120
|
+
end
|
121
|
+
|
112
122
|
# takes a description of what this parser does and stores it against the DSL definition
|
113
123
|
# of the current @child_class, this is used to generate documentation for what the parser
|
114
124
|
# has done with the DSL
|
data/lib/dsl_compose/version.rb
CHANGED
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.3.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-07-
|
11
|
+
date: 2023-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: class_spec_helper
|