dsl_compose 2.5.2 → 2.6.1
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 +14 -0
- data/lib/dsl_compose/interpreter/execution/arguments.rb +0 -2
- data/lib/dsl_compose/interpreter/execution/method_calls.rb +2 -2
- data/lib/dsl_compose/interpreter/execution.rb +2 -2
- data/lib/dsl_compose/interpreter.rb +2 -2
- data/lib/dsl_compose/parser/for_children_of_parser/for_dsl_parser/for_method_parser.rb +13 -2
- data/lib/dsl_compose/parser/for_children_of_parser/for_dsl_parser.rb +17 -2
- data/lib/dsl_compose/parser/for_children_of_parser.rb +2 -2
- 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: 5ab97e49cd1581273bc3555e75d7610cab0764024f5c87445cf7da2f48af97d4
|
4
|
+
data.tar.gz: bc8e659445fad939868276749ae23c8e5cd3a44d7afb45989d4cd5dac4b487a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e7e18eec99d3b458d1a03e5a9feff3aad70696318d706bf17064646ceeb152d45f4b0b954aef83cb5edcf501502d76821a44c2da58f88d60a91cba31ae18c70
|
7
|
+
data.tar.gz: 8412d42847af88966b8e523ccda0c37f2724d71c319b244cb1a1f206694899b0cad65e5aaf48d9252e597dd9c1afc8ae50f3bc13e6d4b0459669340f7d242dbb
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [2.6.1](https://github.com/craigulliott/dsl_compose/compare/v2.6.0...v2.6.1) (2023-08-29)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* renaming `description` to `add_documentation` for dynamically creating documentation from within parsers ([3e24194](https://github.com/craigulliott/dsl_compose/commit/3e2419492e61d94ea7d3c1f34ef4990fc0f6682a))
|
9
|
+
|
10
|
+
## [2.6.0](https://github.com/craigulliott/dsl_compose/compare/v2.5.2...v2.6.0) (2023-08-23)
|
11
|
+
|
12
|
+
|
13
|
+
### Features
|
14
|
+
|
15
|
+
* optionally request an object containing all the dsl and dsl method args from within the parser ([8abfd64](https://github.com/craigulliott/dsl_compose/commit/8abfd64131e37f620a9443466028c5a81b6f5377))
|
16
|
+
|
3
17
|
## [2.5.2](https://github.com/craigulliott/dsl_compose/compare/v2.5.1...v2.5.2) (2023-08-17)
|
4
18
|
|
5
19
|
|
@@ -148,7 +148,6 @@ module DSLCompose
|
|
148
148
|
else
|
149
149
|
optional_arg_value
|
150
150
|
end
|
151
|
-
|
152
151
|
rescue => e
|
153
152
|
raise e, "Error processing optional argument #{optional_argument_name}: #{e.message}", e.backtrace
|
154
153
|
end
|
@@ -239,7 +238,6 @@ module DSLCompose
|
|
239
238
|
else
|
240
239
|
required_arg_value
|
241
240
|
end
|
242
|
-
|
243
241
|
rescue => e
|
244
242
|
raise e, "Error processing required argument #{argument_name}: #{e.message}", e.backtrace
|
245
243
|
end
|
@@ -14,12 +14,12 @@ module DSLCompose
|
|
14
14
|
@method_calls.filter { |mc| mc.method_name == method_name }.any?
|
15
15
|
end
|
16
16
|
|
17
|
-
def add_method_call
|
17
|
+
def add_method_call(dsl_method, ...)
|
18
18
|
# make sure we always have a variable which can be used in the exception message
|
19
19
|
dsl_method_name = nil
|
20
20
|
dsl_method_name = dsl_method.name
|
21
21
|
|
22
|
-
method_call = MethodCall.new(dsl_method,
|
22
|
+
method_call = MethodCall.new(dsl_method, ...)
|
23
23
|
@method_calls << method_call
|
24
24
|
method_call
|
25
25
|
rescue => e
|
@@ -59,7 +59,7 @@ module DSLCompose
|
|
59
59
|
private
|
60
60
|
|
61
61
|
# catch and process any method calls within the DSL block
|
62
|
-
def method_missing
|
62
|
+
def method_missing(method_name, ...)
|
63
63
|
# if the method does not exist, then this will raise a MethodDoesNotExistError
|
64
64
|
dsl_method = @dsl.dsl_method method_name
|
65
65
|
|
@@ -68,7 +68,7 @@ module DSLCompose
|
|
68
68
|
raise MethodIsUniqueError, "This method `#{method_name}` is unique and can only be called once within this DSL"
|
69
69
|
end
|
70
70
|
|
71
|
-
@method_calls.add_method_call
|
71
|
+
@method_calls.add_method_call(dsl_method, ...)
|
72
72
|
end
|
73
73
|
|
74
74
|
def respond_to_missing?(method_name, *args)
|
@@ -40,14 +40,14 @@ module DSLCompose
|
|
40
40
|
# Execute/process a dynamically defined DSL on a class.
|
41
41
|
# `klass` is the class in which the DSL is being used, not
|
42
42
|
# the class in which the DSL was defined.
|
43
|
-
def execute_dsl
|
43
|
+
def execute_dsl(klass, dsl, ...)
|
44
44
|
# make sure we have these variables for the exception message below
|
45
45
|
class_name = nil
|
46
46
|
class_name = klass.name
|
47
47
|
dsl_name = nil
|
48
48
|
dsl_name = dsl.name
|
49
49
|
|
50
|
-
execution = Execution.new(klass, dsl,
|
50
|
+
execution = Execution.new(klass, dsl, ...)
|
51
51
|
@executions << execution
|
52
52
|
execution
|
53
53
|
rescue => e
|
@@ -83,6 +83,17 @@ module DSLCompose
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
+
# a hash representation of all the method arguments, if requested
|
87
|
+
if BlockArguments.accepts_argument?(:method_arguments, &block)
|
88
|
+
args[:method_arguments] = {}
|
89
|
+
# process each argument, because we might need to coerce it
|
90
|
+
method_call.arguments.arguments.each do |name, value|
|
91
|
+
# if this value is a ClassCoerce object, then convert it from its original
|
92
|
+
# string value to a class
|
93
|
+
args[:method_arguments][name] = value.is_a?(ClassCoerce) ? value.to_class : value
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
86
97
|
# set the method_call in an instance variable so that method calls to `description`
|
87
98
|
# from within the block will have access to it
|
88
99
|
@method_call = method_call
|
@@ -96,8 +107,8 @@ module DSLCompose
|
|
96
107
|
# takes a description of what this parser does and stores it against the DSL definition
|
97
108
|
# of the current @child_class, this is used to generate documentation for what the parser
|
98
109
|
# has done with the DSL
|
99
|
-
def
|
100
|
-
@method_call.add_parser_usage_note
|
110
|
+
def add_documentation documentation
|
111
|
+
@method_call.add_parser_usage_note documentation
|
101
112
|
end
|
102
113
|
end
|
103
114
|
end
|
@@ -67,14 +67,28 @@ 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
|
+
|
70
71
|
# the dsl name (if it's requested)
|
71
72
|
if BlockArguments.accepts_argument?(:dsl_name, &block)
|
72
73
|
args[:dsl_name] = dsl_execution.dsl.name
|
73
74
|
end
|
75
|
+
|
76
|
+
# a hash representation of all the dsl arguments, if requested
|
77
|
+
if BlockArguments.accepts_argument?(:dsl_arguments, &block)
|
78
|
+
args[:dsl_arguments] = {}
|
79
|
+
# process each argument, because we might need to coerce it
|
80
|
+
dsl_execution.arguments.arguments.each do |name, value|
|
81
|
+
# if this value is a ClassCoerce object, then convert it from its original
|
82
|
+
# string value to a class
|
83
|
+
args[:dsl_arguments][name] = value.is_a?(ClassCoerce) ? value.to_class : value
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
74
87
|
# an ExecutionReader object to access the exections methods (if it's requested)
|
75
88
|
if BlockArguments.accepts_argument?(:reader, &block)
|
76
89
|
args[:reader] = Reader::ExecutionReader.new(dsl_execution)
|
77
90
|
end
|
91
|
+
|
78
92
|
# add any arguments that were provided to the DSL
|
79
93
|
dsl_execution.arguments.arguments.each do |name, value|
|
80
94
|
if BlockArguments.accepts_argument?(name, &block)
|
@@ -83,6 +97,7 @@ module DSLCompose
|
|
83
97
|
args[name] = value.is_a?(ClassCoerce) ? value.to_class : value
|
84
98
|
end
|
85
99
|
end
|
100
|
+
|
86
101
|
# set the dsl_execution in an instance variable so that method calls to `for_method`
|
87
102
|
# from within the block will have access to it
|
88
103
|
@dsl_execution = dsl_execution
|
@@ -127,8 +142,8 @@ module DSLCompose
|
|
127
142
|
# takes a description of what this parser does and stores it against the DSL definition
|
128
143
|
# of the current @child_class, this is used to generate documentation for what the parser
|
129
144
|
# has done with the DSL
|
130
|
-
def
|
131
|
-
@dsl_execution.add_parser_usage_note
|
145
|
+
def add_documentation documentation
|
146
|
+
@dsl_execution.add_parser_usage_note documentation
|
132
147
|
end
|
133
148
|
end
|
134
149
|
end
|
@@ -125,8 +125,8 @@ module DSLCompose
|
|
125
125
|
# takes a description of what this parser does and stores it against the DSL definition
|
126
126
|
# of the current @child_class, this is used to generate documentation for what the parser
|
127
127
|
# has done with the DSL
|
128
|
-
def
|
129
|
-
@base_class.dsls.add_parser_usage_note @child_class,
|
128
|
+
def add_documentation documentation
|
129
|
+
@base_class.dsls.add_parser_usage_note @child_class, documentation
|
130
130
|
end
|
131
131
|
end
|
132
132
|
end
|
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.6.1
|
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-08-
|
11
|
+
date: 2023-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: class_spec_helper
|