dsl_compose 1.11.0 → 1.12.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 +4 -3
- data/lib/dsl_compose/interpreter.rb +3 -2
- data/lib/dsl_compose/parser/for_children_of_parser.rb +23 -6
- data/lib/dsl_compose/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a22a3595bbf6990c27628cf872f751939156cc9cda865d6ae05ca9cd6e6ba544
|
4
|
+
data.tar.gz: 79fcd4ddb46ecc10cc1dd84f50515c4bb85067a0b26482d7a6250112b4d44fc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cc5bf277a33d63d0dba6aa3053bfec1b5154d7f337c7e0e6fd0db2e5f429718e12097b640069904e44d95d02d2d576604d571cc45c96687ab8316064b4de3a7
|
7
|
+
data.tar.gz: 52a29affc55dd62fe4abbc965dc22973c1a01ba7acc170e33e8f7191ddf1ab19e4456f288cf69864282bea49afa8ac445ce1c1316053c07a6b4f2ef0ef1ba10a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [1.12.0](https://github.com/craigulliott/dsl_compose/compare/v1.11.0...v1.12.0) (2023-07-13)
|
4
|
+
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
* parsers are now aware of class inheritance, and all classes now assume the DSL configurations of all their ancestors ([#33](https://github.com/craigulliott/dsl_compose/issues/33)) ([6a6cfb1](https://github.com/craigulliott/dsl_compose/commit/6a6cfb1fd9bb44c2ea949888c7b7be14ddc0cef8))
|
9
|
+
|
3
10
|
## [1.11.0](https://github.com/craigulliott/dsl_compose/compare/v1.10.0...v1.11.0) (2023-07-12)
|
4
11
|
|
5
12
|
|
data/README.md
CHANGED
@@ -241,8 +241,7 @@ A parser class can be used to process complicated DSLs. In the example below, a
|
|
241
241
|
# create your own parser by creating a new class which extends DSLCompose::Parser
|
242
242
|
MyParser < DSLCompose::Parser
|
243
243
|
# `for_children_of` will process SomeBaseClass and yield the provided
|
244
|
-
# block once for every class which extends SomeBaseClass
|
245
|
-
# least one of the DSLs that have been defined on it.
|
244
|
+
# block once for every class which extends SomeBaseClass
|
246
245
|
for_children_of SomeBaseClass do |child_class:|
|
247
246
|
# `for_dsl` accepts a DSL name or an array of DSL names and will yield
|
248
247
|
# it's provided block once for each time a DSL of that name has been
|
@@ -253,7 +252,9 @@ MyParser < DSLCompose::Parser
|
|
253
252
|
# You can optionally provide keyword arguments which correspond to any
|
254
253
|
# arguments that were defined for the DSL, if multiple dsl names are provided
|
255
254
|
# then the requested dsl argument must be present on all DSLs otherwise an
|
256
|
-
# error will be raised.
|
255
|
+
# error will be raised. The parser is aware of class inheritance, and will
|
256
|
+
# consider a DSL to have been executed on the actual class it was used, and
|
257
|
+
# any classes which are descendants of that class
|
257
258
|
for_dsl [:dsl1, :dsl2] do |dsl_name:, a_dsl_argument:|
|
258
259
|
# `for_method` accepts a method name or an array of method names and will
|
259
260
|
# yield it's provided block once for each time a method with this name is
|
@@ -40,9 +40,10 @@ module DSLCompose
|
|
40
40
|
@executions.filter { |e| e.dsl.name == dsl_name }
|
41
41
|
end
|
42
42
|
|
43
|
-
# Returns an array of all executions for a given name and class.
|
43
|
+
# Returns an array of all executions for a given name and class. This includes
|
44
|
+
# any ancestors of the provided class
|
44
45
|
def class_dsl_executions klass, dsl_name
|
45
|
-
@executions.filter { |e| e.
|
46
|
+
@executions.filter { |e| e.dsl.name == dsl_name && (e.klass == klass || klass < e.klass) }
|
46
47
|
end
|
47
48
|
|
48
49
|
# removes all executions from the interpreter, this is primarily used from
|
@@ -15,8 +15,26 @@ module DSLCompose
|
|
15
15
|
class NoChildClassError < StandardError
|
16
16
|
end
|
17
17
|
|
18
|
-
# This class will yield to the provided block for each
|
19
|
-
#
|
18
|
+
# This class will yield to the provided block for each descendant
|
19
|
+
# class of the provided base_class
|
20
|
+
#
|
21
|
+
# For example:
|
22
|
+
#
|
23
|
+
# class BaseClass
|
24
|
+
# include DSLCompose::Composer
|
25
|
+
# define_dsl :my_foo_dsl
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# class ChildClass < BaseClass
|
29
|
+
# my_foo_dsl
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# class GrandchildClass < ChildClass
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# parser.for_children_of BaseClass do |child_class:|
|
36
|
+
# # this will yield for ChildClass and GrandchildClass
|
37
|
+
# and
|
20
38
|
def initialize base_class, &block
|
21
39
|
# assert the provided class has the DSLCompose::Composer module installed
|
22
40
|
unless base_class.respond_to? :dsls
|
@@ -38,9 +56,8 @@ module DSLCompose
|
|
38
56
|
end
|
39
57
|
end
|
40
58
|
|
41
|
-
#
|
42
|
-
|
43
|
-
base_class.dsls.executions_by_class.each do |child_class, dsl|
|
59
|
+
# yeild the block for all descendents of the provided base_class
|
60
|
+
ObjectSpace.each_object(Class).select { |klass| klass < base_class }.each do |child_class|
|
44
61
|
args = {}
|
45
62
|
if BlockArguments.accepts_argument?(:child_class, &block)
|
46
63
|
args[:child_class] = child_class
|
@@ -57,7 +74,7 @@ module DSLCompose
|
|
57
74
|
|
58
75
|
# Given a dsl name, or array of dsl names, this method will yield to the
|
59
76
|
# provided block once for each time a dsl with one of the provided names
|
60
|
-
# was used on the correspondng child_class
|
77
|
+
# was used on the correspondng child_class or any of its ancestors.
|
61
78
|
#
|
62
79
|
# The value of child_class and base_class are set from the yield of this
|
63
80
|
# classes initializer, meaning that the use of this method should look
|
data/lib/dsl_compose/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dsl_compose
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.12.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-
|
12
|
-
dependencies:
|
11
|
+
date: 2023-07-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: class_spec_helper
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
description: Ruby gem to add dynamic DSLs to classes. DSLs are added to classes by
|
14
28
|
including the DSLCompose module, and then calling the add_dsl singleton method within
|
15
29
|
the class or a child class.
|