dsl_compose 2.5.1 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d558cb69dae4f6a6ea4e6a2fe996a88ea0a94545e94f68c22c0800732d0745da
4
- data.tar.gz: 9527152eda7312f711c9881fffb26cc2feae295d67be646ace5ce9a20f6dc88b
3
+ metadata.gz: '048f2e5d2e94df09db474b6134cacb580dde9a88a751e2e0697d72234be0132e'
4
+ data.tar.gz: b336eb45f722b2fbafb0f12f43d760ad1de2287eb9beffc27227d020daf5cc43
5
5
  SHA512:
6
- metadata.gz: 5c60f96f11f85c753138ea3a1f4fefe227fdb7ce48191e6dc204380e603916204e62e398ca0813487ed92f15dea9f38596050e5f91484a9ceab604ef11ff828e
7
- data.tar.gz: 7eae02a8c4d6fa2e43ab4789ae1399c74e744bbccdfb46e60804f41d7982e11e9187b2f332fe6db53f858b867584f4317b981ca360f982d78fe05346db576f94
6
+ metadata.gz: 412d7f101db06e26ad871a359d7d063a0086b0b2b3e8be2e96cd3b87e69ec1eb7f813c770326779e9b16c166433700b6751ecf9e8b35e568313f8350ed31fd30
7
+ data.tar.gz: 551f08b45107d633abbcdc008fd13e971c41c317e17ce07e86f0035b2d1ee1ef9ddb6e23b2c1505239279d7f90c1940f22b1d111542ecc51a253b588bb101823
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.6.0](https://github.com/craigulliott/dsl_compose/compare/v2.5.2...v2.6.0) (2023-08-23)
4
+
5
+
6
+ ### Features
7
+
8
+ * 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))
9
+
10
+ ## [2.5.2](https://github.com/craigulliott/dsl_compose/compare/v2.5.1...v2.5.2) (2023-08-17)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * optional array arguments default to empty arrays rather than nil ([8a74ad6](https://github.com/craigulliott/dsl_compose/commit/8a74ad671f5d74c3ab7deb6f09c2cfa7c3557d1c))
16
+
3
17
  ## [2.5.1](https://github.com/craigulliott/dsl_compose/compare/v2.5.0...v2.5.1) (2023-08-17)
4
18
 
5
19
 
@@ -48,7 +48,15 @@ module DSLCompose
48
48
  # If actual values were provided, then they will be set further below.
49
49
  if arguments.optional_arguments.any?
50
50
  arguments.optional_arguments.each do |optional_argument|
51
- @arguments[optional_argument.name] = (optional_argument.type == :boolean) ? false : nil
51
+ # assume it is nil
52
+ @arguments[optional_argument.name] = nil
53
+ # unless the argument is an array or a boolean, in which case it defaults
54
+ # to an empty array or false
55
+ if optional_argument.array
56
+ @arguments[optional_argument.name] = []
57
+ elsif optional_argument.type == :boolean
58
+ @arguments[optional_argument.name] = false
59
+ end
52
60
  end
53
61
  end
54
62
 
@@ -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
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DSLCompose
4
- VERSION = "2.5.1"
4
+ VERSION = "2.6.0"
5
5
  end
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.1
4
+ version: 2.6.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-08-17 00:00:00.000000000 Z
11
+ date: 2023-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: class_spec_helper