dsl_compose 2.2.2 → 2.4.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 +13 -2
- data/lib/dsl_compose/parser/for_children_of_parser/for_dsl_parser.rb +15 -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: 43cfe766f3e464ba7f5a22128e7f5155806f92686555aef5f2f06af2b58916af
|
4
|
+
data.tar.gz: 999dc31a662af4684b2956a50c226aa596b345ece609d2b9ace058eea211f924
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78b2add3e95f52ae184abb3d2a30f9218d966a8d44e378b72ea37c5ad2dfd6c3409f7a9cf08e4762d17cf717c2ff35c2f7da4ce5a28d8959eacbcf92c484c0db
|
7
|
+
data.tar.gz: 7d4e1550f001a40d0665c6258eff2cd16d0052f209b1c6741a3252b0623f698345d8344014555153649dd705077dda8cc39d08531bb95bd5df4611cde257c156
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [2.4.0](https://github.com/craigulliott/dsl_compose/compare/v2.3.0...v2.4.0) (2023-07-31)
|
4
|
+
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
* access an ExecutionReader object from within a parser ([53e9c29](https://github.com/craigulliott/dsl_compose/commit/53e9c29073389217d8526c43eec67325587c45b9))
|
9
|
+
|
10
|
+
## [2.3.0](https://github.com/craigulliott/dsl_compose/compare/v2.2.2...v2.3.0) (2023-07-28)
|
11
|
+
|
12
|
+
|
13
|
+
### Features
|
14
|
+
|
15
|
+
* added a method_called? helper method to the DSL parser ([48e68a8](https://github.com/craigulliott/dsl_compose/commit/48e68a8d799e297d3433f3d2a6bccb7a077dd9af))
|
16
|
+
|
3
17
|
## [2.2.2](https://github.com/craigulliott/dsl_compose/compare/v2.2.1...v2.2.2) (2023-07-27)
|
4
18
|
|
5
19
|
|
data/README.md
CHANGED
@@ -274,8 +274,13 @@ class MyParser < DSLCompose::Parser
|
|
274
274
|
# then the requested dsl argument must be present on all DSLs otherwise an
|
275
275
|
# error will be raised. The parser is aware of class inheritance, and will
|
276
276
|
# consider a DSL to have been executed on the actual class it was used, and
|
277
|
-
# any classes which are descendants of that class
|
278
|
-
|
277
|
+
# any classes which are descendants of that class.
|
278
|
+
#
|
279
|
+
# You can also request an ExecutionReader object here by including the
|
280
|
+
# argument `:reader`. The resulting reader object will allow to to access the methods
|
281
|
+
# which were called within this use of your DSL. There is more documentation about
|
282
|
+
# Reader classes below.
|
283
|
+
for_dsl [:dsl1, :dsl2] do |dsl_name:, a_dsl_argument:, reader:|
|
279
284
|
description <<-DESCRIPTION
|
280
285
|
You can optionally provide a description of anything specific that your parser
|
281
286
|
does in this block, this description will be used when generating documentation.
|
@@ -286,6 +291,12 @@ class MyParser < DSLCompose::Parser
|
|
286
291
|
other than making calls to `for_method`
|
287
292
|
DESCRIPTION
|
288
293
|
|
294
|
+
# Within a `for_dsl` block you can determine if a specific DSL method was used
|
295
|
+
# with the `method_called?` method. This method will return true if the method was
|
296
|
+
# used, otherwise it will return false. If a method with the provided name does not
|
297
|
+
# exist for the DSL, then an error will be raised.
|
298
|
+
was_some_method_name_used = method_called? :some_method_name
|
299
|
+
|
289
300
|
# `for_method` accepts a method name or an array of method names and will
|
290
301
|
# yield it's provided block once for each time a method with this name is
|
291
302
|
# executed within the DSL.
|
@@ -67,9 +67,14 @@ module DSLCompose
|
|
67
67
|
# us to use keyword arguments to force a naming convention on these arguments
|
68
68
|
# and to validate their use
|
69
69
|
args = {}
|
70
|
+
# the dsl name (if it's requested)
|
70
71
|
if BlockArguments.accepts_argument?(:dsl_name, &block)
|
71
72
|
args[:dsl_name] = dsl_execution.dsl.name
|
72
73
|
end
|
74
|
+
# an ExecutionReader object to access the exections methods (if it's requested)
|
75
|
+
if BlockArguments.accepts_argument?(:reader, &block)
|
76
|
+
args[:reader] = Reader::ExecutionReader.new(dsl_execution)
|
77
|
+
end
|
73
78
|
# add any arguments that were provided to the DSL
|
74
79
|
dsl_execution.arguments.arguments.each do |name, value|
|
75
80
|
if BlockArguments.accepts_argument?(name, &block)
|
@@ -109,6 +114,16 @@ module DSLCompose
|
|
109
114
|
ForMethodParser.new(@base_class, @child_class, @dsl_execution, method_names, &block)
|
110
115
|
end
|
111
116
|
|
117
|
+
# Given a method name, will return true if the method was called within the current DSL
|
118
|
+
# execution, otherwise it will return false
|
119
|
+
def method_called? method_name
|
120
|
+
# get the dsl method from the current dsl execution, this
|
121
|
+
# will raise an error if the method does not exist
|
122
|
+
dsl_method = @dsl_execution.dsl.dsl_method(method_name)
|
123
|
+
# was this method called within the current DSL execution?
|
124
|
+
@dsl_execution.method_calls.method_called? dsl_method.name
|
125
|
+
end
|
126
|
+
|
112
127
|
# takes a description of what this parser does and stores it against the DSL definition
|
113
128
|
# of the current @child_class, this is used to generate documentation for what the parser
|
114
129
|
# 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.4.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-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: class_spec_helper
|