dsl_compose 1.13.1 → 1.14.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 +7 -0
- data/lib/dsl_compose/dsl/arguments/argument.rb +1 -1
- data/lib/dsl_compose/dsl/dsl_method.rb +1 -1
- data/lib/dsl_compose/dsl.rb +1 -1
- data/lib/dsl_compose/fix_heredoc_indentation.rb +23 -0
- data/lib/dsl_compose/interpreter/execution/method_calls/method_call.rb +13 -0
- data/lib/dsl_compose/interpreter/execution.rb +13 -0
- data/lib/dsl_compose/interpreter.rb +15 -0
- data/lib/dsl_compose/parser/for_children_of_parser/for_dsl_parser/for_method_parser.rb +11 -0
- data/lib/dsl_compose/parser/for_children_of_parser/for_dsl_parser.rb +7 -0
- data/lib/dsl_compose/parser/for_children_of_parser.rb +7 -0
- data/lib/dsl_compose/version.rb +1 -1
- data/lib/dsl_compose.rb +2 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fe38926f435f6f7978468bb08e0b91ebbd6962d5863032a7cb49095856c3c50
|
4
|
+
data.tar.gz: c4523746ddbef25e5c64e8b47ea624393d6efa25f0c6b795a0d69ea7910d2683
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef54cc72949be0609a9bd1feacad07b202c90b183f6be89c6494c19a95944639ccc0cba3986375a16234803aa96f4e90721abc2308fa75e20ace407504bfedce
|
7
|
+
data.tar.gz: 4143b1a1d0d84597da9fa29ef745a9ca0002fc4bc6107a9206b700453f511cdc1e7a0bc6eea16af69e169cc3c220ff43bbbdd5b8603df58704bcc9d51fa5d58b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [1.14.0](https://github.com/craigulliott/dsl_compose/compare/v1.13.1...v1.14.0) (2023-07-19)
|
4
|
+
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
* Parsers can push notes back to the DSLs to explain how each DSL is being used. These notes can be used in generated documentation. ([#39](https://github.com/craigulliott/dsl_compose/issues/39)) ([053fa50](https://github.com/craigulliott/dsl_compose/commit/053fa50bcbc2180b2f788b5a3bba11576804f206))
|
9
|
+
|
3
10
|
## [1.13.1](https://github.com/craigulliott/dsl_compose/compare/v1.13.0...v1.13.1) (2023-07-19)
|
4
11
|
|
5
12
|
|
@@ -120,7 +120,7 @@ module DSLCompose
|
|
120
120
|
raise DescriptionAlreadyExistsError, "The description has already been set"
|
121
121
|
end
|
122
122
|
|
123
|
-
@description = description
|
123
|
+
@description = FixHeredocIndentation.fix_heredoc_indentation description
|
124
124
|
end
|
125
125
|
|
126
126
|
# Returns `true` if this DSL has a description, else false.
|
@@ -76,7 +76,7 @@ module DSLCompose
|
|
76
76
|
raise DescriptionAlreadyExistsError, "The description has already been set"
|
77
77
|
end
|
78
78
|
|
79
|
-
@description = description
|
79
|
+
@description = FixHeredocIndentation.fix_heredoc_indentation description
|
80
80
|
end
|
81
81
|
|
82
82
|
# Returns `true` if this DSL has a description, else false.
|
data/lib/dsl_compose/dsl.rb
CHANGED
@@ -82,7 +82,7 @@ module DSLCompose
|
|
82
82
|
raise DescriptionAlreadyExistsError, "The DSL description has already been set"
|
83
83
|
end
|
84
84
|
|
85
|
-
@description = description
|
85
|
+
@description = FixHeredocIndentation.fix_heredoc_indentation description
|
86
86
|
end
|
87
87
|
|
88
88
|
# Returns `true` if this DSL has a description, else false.
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module DSLCompose
|
2
|
+
# A small helper to fix indentation and clean up whitespace in
|
3
|
+
# strings which were created with rubys heredoc syntax.
|
4
|
+
module FixHeredocIndentation
|
5
|
+
# This method is used to fix the indentation of heredoc strings.
|
6
|
+
# It will remove the leading whitespace from each line of the string
|
7
|
+
# and remove the leading newline from the string.
|
8
|
+
def self.fix_heredoc_indentation string
|
9
|
+
# replace all tabs with spaces
|
10
|
+
string = string.gsub(/\t/, " ")
|
11
|
+
# remove empty lines from the start of the string
|
12
|
+
string = string.gsub(/\A( *\n)+/, "")
|
13
|
+
# remove empty lines from the end of the string
|
14
|
+
string = string.gsub(/( *\n)+\Z/, "")
|
15
|
+
# removes the number of leading spaces on the first line, from
|
16
|
+
# all the other lines
|
17
|
+
string = string.gsub(/^#{string[/\A */]}/, "")
|
18
|
+
# collapse lines which are next to each other onto the same line
|
19
|
+
# because they are really the same paragraph
|
20
|
+
string.gsub(/([^ \n])\n([^ \n])/, '\1 \2')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -22,6 +22,19 @@ module DSLCompose
|
|
22
22
|
arguments: @arguments.to_h
|
23
23
|
}
|
24
24
|
end
|
25
|
+
|
26
|
+
# the parser can provide usage notes for how this dsl is being used, these are used to
|
27
|
+
# generate documentation
|
28
|
+
def add_parser_usage_note note
|
29
|
+
@parser_usage_notes ||= []
|
30
|
+
@parser_usage_notes << DSLCompose::FixHeredocIndentation.fix_heredoc_indentation(note)
|
31
|
+
end
|
32
|
+
|
33
|
+
# return the list of notes which describe how the parsers are using this DSL
|
34
|
+
def parser_usage_notes
|
35
|
+
@parser_usage_notes ||= []
|
36
|
+
@parser_usage_notes
|
37
|
+
end
|
25
38
|
end
|
26
39
|
end
|
27
40
|
end
|
@@ -36,6 +36,19 @@ module DSLCompose
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
# the parser can provide usage notes for how this dsl is being used, these are used to
|
40
|
+
# generate documentation
|
41
|
+
def add_parser_usage_note note
|
42
|
+
@parser_usage_notes ||= []
|
43
|
+
@parser_usage_notes << DSLCompose::FixHeredocIndentation.fix_heredoc_indentation(note)
|
44
|
+
end
|
45
|
+
|
46
|
+
# return the list of notes which describe how the parsers are using this DSL
|
47
|
+
def parser_usage_notes
|
48
|
+
@parser_usage_notes ||= []
|
49
|
+
@parser_usage_notes
|
50
|
+
end
|
51
|
+
|
39
52
|
private
|
40
53
|
|
41
54
|
# catch and process any method calls within the DSL block
|
@@ -13,6 +13,21 @@ module DSLCompose
|
|
13
13
|
@executions = []
|
14
14
|
end
|
15
15
|
|
16
|
+
# the parser can provide usage notes for how this dsl is being used, these are used to
|
17
|
+
# generate documentation
|
18
|
+
def add_parser_usage_note child_class, note
|
19
|
+
@parser_usage_notes ||= {}
|
20
|
+
@parser_usage_notes[child_class] ||= []
|
21
|
+
@parser_usage_notes[child_class] << DSLCompose::FixHeredocIndentation.fix_heredoc_indentation(note)
|
22
|
+
end
|
23
|
+
|
24
|
+
# return the list of notes which describe how the parsers are using this DSL
|
25
|
+
def parser_usage_notes child_class
|
26
|
+
@parser_usage_notes ||= {}
|
27
|
+
@parser_usage_notes[child_class] ||= []
|
28
|
+
@parser_usage_notes[child_class]
|
29
|
+
end
|
30
|
+
|
16
31
|
# Execute/process a dynamically defined DSL on a class.
|
17
32
|
# `klass` is the class in which the DSL is being used, not
|
18
33
|
# the class in which the DSL was defined.
|
@@ -83,11 +83,22 @@ module DSLCompose
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
+
# set the method_call in an instance variable so that method calls to `description`
|
87
|
+
# from within the block will have access to it
|
88
|
+
@method_call = method_call
|
89
|
+
|
86
90
|
# yeild the block in the context of this class
|
87
91
|
instance_exec(**args, &block)
|
88
92
|
end
|
89
93
|
end
|
90
94
|
end
|
95
|
+
|
96
|
+
# takes a description of what this parser does and stores it against the DSL definition
|
97
|
+
# of the current @child_class, this is used to generate documentation for what the parser
|
98
|
+
# has done with the DSL
|
99
|
+
def description description
|
100
|
+
@method_call.add_parser_usage_note description
|
101
|
+
end
|
91
102
|
end
|
92
103
|
end
|
93
104
|
end
|
@@ -108,6 +108,13 @@ module DSLCompose
|
|
108
108
|
def for_method method_names, &block
|
109
109
|
ForMethodParser.new(@base_class, @child_class, @dsl_execution, method_names, &block)
|
110
110
|
end
|
111
|
+
|
112
|
+
# takes a description of what this parser does and stores it against the DSL definition
|
113
|
+
# of the current @child_class, this is used to generate documentation for what the parser
|
114
|
+
# has done with the DSL
|
115
|
+
def description description
|
116
|
+
@dsl_execution.add_parser_usage_note description
|
117
|
+
end
|
111
118
|
end
|
112
119
|
end
|
113
120
|
end
|
@@ -121,6 +121,13 @@ module DSLCompose
|
|
121
121
|
def for_dsl_or_inherited_dsl dsl_names, &block
|
122
122
|
for_dsl dsl_names, on_current_class: true, on_ancestor_class: true, &block
|
123
123
|
end
|
124
|
+
|
125
|
+
# takes a description of what this parser does and stores it against the DSL definition
|
126
|
+
# of the current @child_class, this is used to generate documentation for what the parser
|
127
|
+
# has done with the DSL
|
128
|
+
def description description
|
129
|
+
@base_class.dsls.add_parser_usage_note @child_class, description
|
130
|
+
end
|
124
131
|
end
|
125
132
|
end
|
126
133
|
end
|
data/lib/dsl_compose/version.rb
CHANGED
data/lib/dsl_compose.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dsl_compose
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Craig Ulliott
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- lib/dsl_compose/dsl/dsl_method/interpreter.rb
|
63
63
|
- lib/dsl_compose/dsl/interpreter.rb
|
64
64
|
- lib/dsl_compose/dsls.rb
|
65
|
+
- lib/dsl_compose/fix_heredoc_indentation.rb
|
65
66
|
- lib/dsl_compose/interpreter.rb
|
66
67
|
- lib/dsl_compose/interpreter/execution.rb
|
67
68
|
- lib/dsl_compose/interpreter/execution/arguments.rb
|