dsl_compose 2.5.0 → 2.5.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 +8 -0
- data/README.md +5 -5
- data/lib/dsl_compose/dsl/arguments/argument.rb +2 -2
- data/lib/dsl_compose/dsl/dsl_method.rb +2 -2
- data/lib/dsl_compose/dsl.rb +2 -2
- data/lib/dsl_compose/interpreter/execution/arguments.rb +3 -2
- data/lib/dsl_compose/interpreter/execution/method_calls/method_call.rb +8 -1
- data/lib/dsl_compose/interpreter/execution.rb +8 -1
- data/lib/dsl_compose/interpreter.rb +7 -1
- data/lib/dsl_compose/version.rb +1 -1
- data/lib/dsl_compose.rb +0 -2
- metadata +2 -3
- data/lib/dsl_compose/fix_heredoc_indentation.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d558cb69dae4f6a6ea4e6a2fe996a88ea0a94545e94f68c22c0800732d0745da
|
4
|
+
data.tar.gz: 9527152eda7312f711c9881fffb26cc2feae295d67be646ace5ce9a20f6dc88b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c60f96f11f85c753138ea3a1f4fefe227fdb7ce48191e6dc204380e603916204e62e398ca0813487ed92f15dea9f38596050e5f91484a9ceab604ef11ff828e
|
7
|
+
data.tar.gz: 7eae02a8c4d6fa2e43ab4789ae1399c74e744bbccdfb46e60804f41d7982e11e9187b2f332fe6db53f858b867584f4317b981ca360f982d78fe05346db576f94
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [2.5.1](https://github.com/craigulliott/dsl_compose/compare/v2.5.0...v2.5.1) (2023-08-17)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* defaulting optional boolean values to false instead of nil in the parser ([3a4b4d7](https://github.com/craigulliott/dsl_compose/commit/3a4b4d7df315e60dca0e66af37d77b800dc6be2c))
|
9
|
+
* stripping white space off descriptions ([93ba9d2](https://github.com/craigulliott/dsl_compose/commit/93ba9d21f57a4f58f70f24a44cd58121741da8d0))
|
10
|
+
|
3
11
|
## [2.5.0](https://github.com/craigulliott/dsl_compose/compare/v2.4.0...v2.5.0) (2023-08-01)
|
4
12
|
|
5
13
|
|
data/README.md
CHANGED
@@ -42,7 +42,7 @@ class Foo
|
|
42
42
|
define_dsl :your_dsl do
|
43
43
|
|
44
44
|
# A description of your DSL
|
45
|
-
description
|
45
|
+
description <<~DESCRIPTION
|
46
46
|
Add a description of your DSL here, this description will be
|
47
47
|
used when generating the documentation for your DSL.
|
48
48
|
|
@@ -191,7 +191,7 @@ class MyClientLibrary
|
|
191
191
|
description "Configure the settings for MyClientLibrary"
|
192
192
|
|
193
193
|
add_unique_method :api_key, required: true do
|
194
|
-
description
|
194
|
+
description <<~DESCRIPTION
|
195
195
|
Your API key.
|
196
196
|
|
197
197
|
API keys can be generated from your developer
|
@@ -247,7 +247,7 @@ class MyParser < DSLCompose::Parser
|
|
247
247
|
# which extend the provided base class, but do not have their own children) then
|
248
248
|
# use `for_final_children_of` instead of `for_children_of`
|
249
249
|
for_children_of SomeBaseClass do |child_class:|
|
250
|
-
description
|
250
|
+
description <<~DESCRIPTION
|
251
251
|
You can optionally provide a description of anything specific that your parser
|
252
252
|
does in this block, this description will be used when generating documentation
|
253
253
|
|
@@ -281,7 +281,7 @@ class MyParser < DSLCompose::Parser
|
|
281
281
|
# which were called within this use of your DSL. There is more documentation about
|
282
282
|
# Reader classes below.
|
283
283
|
for_dsl [:dsl1, :dsl2] do |dsl_name:, a_dsl_argument:, reader:|
|
284
|
-
description
|
284
|
+
description <<~DESCRIPTION
|
285
285
|
You can optionally provide a description of anything specific that your parser
|
286
286
|
does in this block, this description will be used when generating documentation.
|
287
287
|
|
@@ -308,7 +308,7 @@ class MyParser < DSLCompose::Parser
|
|
308
308
|
# are provided then the requested dsl argument must be present on all DSLs
|
309
309
|
# otherwise an error will be raised.
|
310
310
|
for_method :some_method_name do |method_name:, a_method_argument:|
|
311
|
-
description
|
311
|
+
description <<~DESCRIPTION
|
312
312
|
You can optionally provide a description of anything specific that your parser
|
313
313
|
does in this block, this description will be used when generating documentation.
|
314
314
|
|
@@ -112,7 +112,7 @@ module DSLCompose
|
|
112
112
|
# `description` must be a string with a length greater than 0.
|
113
113
|
# The `description` can only be set once per Argument
|
114
114
|
def set_description description
|
115
|
-
unless description.is_a?(String) && description.length > 0
|
115
|
+
unless description.is_a?(String) && description.strip.length > 0
|
116
116
|
raise InvalidDescriptionError, "The option description `#{description}` is invalid, it must be of type string and have length greater than 0."
|
117
117
|
end
|
118
118
|
|
@@ -120,7 +120,7 @@ module DSLCompose
|
|
120
120
|
raise DescriptionAlreadyExistsError, "The description has already been set"
|
121
121
|
end
|
122
122
|
|
123
|
-
@description =
|
123
|
+
@description = description.strip
|
124
124
|
end
|
125
125
|
|
126
126
|
# Returns `true` if this DSL has a description, else false.
|
@@ -68,7 +68,7 @@ module DSLCompose
|
|
68
68
|
# `description` must be a string with a length greater than 0.
|
69
69
|
# The `description` can only be set once per DSLMethod
|
70
70
|
def set_description description
|
71
|
-
unless description.is_a?(String) && description.length > 0
|
71
|
+
unless description.is_a?(String) && description.strip.length > 0
|
72
72
|
raise InvalidDescriptionError, "The DSL method description `#{description}` is invalid, it must be of type string and have length greater than 0"
|
73
73
|
end
|
74
74
|
|
@@ -76,7 +76,7 @@ module DSLCompose
|
|
76
76
|
raise DescriptionAlreadyExistsError, "The description has already been set"
|
77
77
|
end
|
78
78
|
|
79
|
-
@description =
|
79
|
+
@description = description.strip
|
80
80
|
end
|
81
81
|
|
82
82
|
# Returns `true` if this DSL has a description, else false.
|
data/lib/dsl_compose/dsl.rb
CHANGED
@@ -74,7 +74,7 @@ module DSLCompose
|
|
74
74
|
# `description` must be a string with a length greater than 0.
|
75
75
|
# The `description` can only be set once per DSL
|
76
76
|
def set_description description
|
77
|
-
unless description.is_a?(String) && description.length > 0
|
77
|
+
unless description.is_a?(String) && description.strip.length > 0
|
78
78
|
raise InvalidDescriptionError, "The DSL description `#{description}` is invalid, it must be of type string and have length greater than 0"
|
79
79
|
end
|
80
80
|
|
@@ -82,7 +82,7 @@ module DSLCompose
|
|
82
82
|
raise DescriptionAlreadyExistsError, "The DSL description has already been set"
|
83
83
|
end
|
84
84
|
|
85
|
-
@description =
|
85
|
+
@description = description.strip
|
86
86
|
end
|
87
87
|
|
88
88
|
# Returns `true` if this DSL has a description, else false.
|
@@ -44,10 +44,11 @@ module DSLCompose
|
|
44
44
|
raise TooManyArgumentsError, "Too many arguments provided"
|
45
45
|
end
|
46
46
|
|
47
|
-
#
|
47
|
+
# Assume all optonal arguments are nil (except booleans, which default to false).
|
48
|
+
# If actual values were provided, then they will be set further below.
|
48
49
|
if arguments.optional_arguments.any?
|
49
50
|
arguments.optional_arguments.each do |optional_argument|
|
50
|
-
@arguments[optional_argument.name] = nil
|
51
|
+
@arguments[optional_argument.name] = (optional_argument.type == :boolean) ? false : nil
|
51
52
|
end
|
52
53
|
end
|
53
54
|
|
@@ -5,6 +5,9 @@ module DSLCompose
|
|
5
5
|
class Execution
|
6
6
|
class MethodCalls
|
7
7
|
class MethodCall
|
8
|
+
class InvalidDescriptionError < StandardError
|
9
|
+
end
|
10
|
+
|
8
11
|
attr_reader :dsl_method
|
9
12
|
attr_reader :arguments
|
10
13
|
|
@@ -26,8 +29,12 @@ module DSLCompose
|
|
26
29
|
# the parser can provide usage notes for how this dsl is being used, these are used to
|
27
30
|
# generate documentation
|
28
31
|
def add_parser_usage_note note
|
32
|
+
unless note.is_a?(String) && note.strip.length > 0
|
33
|
+
raise InvalidDescriptionError, "The parser usage description `#{note}` is invalid, it must be of type string and have length greater than 0"
|
34
|
+
end
|
35
|
+
|
29
36
|
@parser_usage_notes ||= []
|
30
|
-
@parser_usage_notes <<
|
37
|
+
@parser_usage_notes << note.strip
|
31
38
|
end
|
32
39
|
|
33
40
|
# return the list of notes which describe how the parsers are using this DSL
|
@@ -9,6 +9,9 @@ module DSLCompose
|
|
9
9
|
class RequiredMethodNotCalledError < StandardError
|
10
10
|
end
|
11
11
|
|
12
|
+
class InvalidDescriptionError < StandardError
|
13
|
+
end
|
14
|
+
|
12
15
|
attr_reader :dsl
|
13
16
|
attr_reader :klass
|
14
17
|
attr_reader :method_calls
|
@@ -39,8 +42,12 @@ module DSLCompose
|
|
39
42
|
# the parser can provide usage notes for how this dsl is being used, these are used to
|
40
43
|
# generate documentation
|
41
44
|
def add_parser_usage_note note
|
45
|
+
unless note.is_a?(String) && note.strip.length > 0
|
46
|
+
raise InvalidDescriptionError, "The parser usage description `#{note}` is invalid, it must be of type string and have length greater than 0"
|
47
|
+
end
|
48
|
+
|
42
49
|
@parser_usage_notes ||= []
|
43
|
-
@parser_usage_notes <<
|
50
|
+
@parser_usage_notes << note.strip
|
44
51
|
end
|
45
52
|
|
46
53
|
# return the list of notes which describe how the parsers are using this DSL
|
@@ -7,6 +7,9 @@ module DSLCompose
|
|
7
7
|
class DSLExecutionNotFoundError < StandardError
|
8
8
|
end
|
9
9
|
|
10
|
+
class InvalidDescriptionError < StandardError
|
11
|
+
end
|
12
|
+
|
10
13
|
# A dynamic DSL can be used multiple times on the same class, each time the DSL is used
|
11
14
|
# a corresponding execution will be created. The execution contains the resulting configuration
|
12
15
|
# from that particular use of the DSL.
|
@@ -19,9 +22,12 @@ module DSLCompose
|
|
19
22
|
# the parser can provide usage notes for how this dsl is being used, these are used to
|
20
23
|
# generate documentation
|
21
24
|
def add_parser_usage_note child_class, note
|
25
|
+
unless note.is_a?(String) && note.strip.length > 0
|
26
|
+
raise InvalidDescriptionError, "The parser usage description `#{note}` is invalid, it must be of type string and have length greater than 0"
|
27
|
+
end
|
22
28
|
@parser_usage_notes ||= {}
|
23
29
|
@parser_usage_notes[child_class] ||= []
|
24
|
-
@parser_usage_notes[child_class] <<
|
30
|
+
@parser_usage_notes[child_class] << note.strip
|
25
31
|
end
|
26
32
|
|
27
33
|
# return the list of notes which describe how the parsers are using this DSL
|
data/lib/dsl_compose/version.rb
CHANGED
data/lib/dsl_compose.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.5.
|
4
|
+
version: 2.5.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-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: class_spec_helper
|
@@ -62,7 +62,6 @@ 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
|
66
65
|
- lib/dsl_compose/interpreter.rb
|
67
66
|
- lib/dsl_compose/interpreter/execution.rb
|
68
67
|
- lib/dsl_compose/interpreter/execution/arguments.rb
|
@@ -1,21 +0,0 @@
|
|
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 trim empty lines from the start and end of
|
6
|
-
# a block of markdown, it will also fix the indentation of heredoc
|
7
|
-
# strings by removing the leading whitespace from the first line, and
|
8
|
-
# that same amount of white space from every other line
|
9
|
-
def self.fix_heredoc_indentation string
|
10
|
-
# replace all tabs with spaces
|
11
|
-
string = string.gsub(/\t/, " ")
|
12
|
-
# remove empty lines from the start of the string
|
13
|
-
string = string.gsub(/\A( *\n)+/, "")
|
14
|
-
# remove empty lines from the end of the string
|
15
|
-
string = string.gsub(/( *\n)+\Z/, "")
|
16
|
-
# removes the number of leading spaces on the first line, from
|
17
|
-
# all the other lines
|
18
|
-
string.gsub(/^#{string[/\A */]}/, "")
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|