dsl_compose 2.2.0 → 2.2.2

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: 409bc8ce86ea967b4a22f675ea029b609a9bb925d8b35255dd4f0a010049f115
4
- data.tar.gz: e8d99aa8be417b6c670978dc5cf4461be8ca65dc4316b27ee840b63d82128738
3
+ metadata.gz: 1b5f53afb63b68aac27995b0fee8dceb7c0f5649a171f187bf95c85ebe29215e
4
+ data.tar.gz: 9ee378a6a342684339a0ff2472ed0aa37fb4d3a5e3e3f71f9eb9b87d5f013b37
5
5
  SHA512:
6
- metadata.gz: a57708bdfb09d3d35cfa3b3e6a76ffa931bcf71c34c14ece5b8737079f6660fefc9596ab5d079cfbf7fed3f733896212b60f81f23a02504dccbcd89a110e01c1
7
- data.tar.gz: d87d67e5e6a1f22d49d0b8bb0642f97755f004684d8c0fa7ca1850ba3ce64e46dc016f3ab5fb21edd068e221734d2bae52c09e92f59135f94b0fabd7ac7d3356
6
+ metadata.gz: 6f9494f1e9054d83bff8601aa6bf2c7e6fc887af2a7c3f762649d32d71116fa0c9856f1d94811df32246f7cf345eafdb06987946da9524832d2a8c9e366f4284
7
+ data.tar.gz: 42f04fe0ee1e3341716a446fd3747ba7bce072d921dcb2cf62ebe3a8d4e7112336ec3b5d42cd87c56076cbbaf36f29ccfe3925f1e1f13776d4d5a38f244f1b9f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.2.2](https://github.com/craigulliott/dsl_compose/compare/v2.2.1...v2.2.2) (2023-07-27)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * argument type :float was not accepting values and did not have validations ([243eff1](https://github.com/craigulliott/dsl_compose/commit/243eff1d0d0cc48602cc626e8a91cdc45b4f9955))
9
+
10
+ ## [2.2.1](https://github.com/craigulliott/dsl_compose/compare/v2.2.0...v2.2.1) (2023-07-27)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * last_execution was raising error instead of returning nil when no executions were found ([bedef1e](https://github.com/craigulliott/dsl_compose/commit/bedef1ec606801a4507ce77c39a33d14cb79818f))
16
+
3
17
  ## [2.2.0](https://github.com/craigulliott/dsl_compose/compare/v2.1.1...v2.2.0) (2023-07-27)
4
18
 
5
19
 
@@ -362,6 +362,12 @@ module DSLCompose
362
362
  (length_validation.nil? || length_validation.validate!(value))
363
363
  end
364
364
 
365
+ # returns true if every provided float validation also returns true
366
+ def validate_float! value
367
+ # floats are validated with the same set of validators as integers
368
+ validate_integer! value
369
+ end
370
+
365
371
  # returns true if every provided symbol validation also returns true
366
372
  def validate_symbol! value
367
373
  (format_validation.nil? || format_validation.validate!(value)) &&
@@ -51,7 +51,7 @@ module DSLCompose
51
51
  # adds a new optional argument to the DSLMethod
52
52
  #
53
53
  # name must be a symbol
54
- # `type` can be either :integer, :boolean, :float, :string or :symbol
54
+ # `type` can be either :integer, :boolean, :float, :string, :symbol, :class or :object
55
55
  # `block` contains the argument definition and will be evaluated seperately
56
56
  # by the Argument::Interpreter
57
57
  def optional name, type, array: false, &block
@@ -61,7 +61,7 @@ module DSLCompose
61
61
  # adds a new required argument to the DSLMethod
62
62
  #
63
63
  # name must be a symbol
64
- # `type` can be either :integer, :boolean, :float, :string or :symbol
64
+ # `type` can be either :integer, :boolean, :float, :string, :symbol, :class or :object
65
65
  # `block` contains the argument definition and will be evaluated seperately
66
66
  # by the Argument::Interpreter
67
67
  def requires name, type, array: false, &block
@@ -91,6 +91,13 @@ module DSLCompose
91
91
  end
92
92
  optional_argument.validate_integer! value
93
93
 
94
+ when :float
95
+ # float allows either floats or integers
96
+ unless value.is_a?(Float) || value.is_a?(Integer)
97
+ raise InvalidArgumentTypeError, "`#{value}` is not an Float or Integer"
98
+ end
99
+ optional_argument.validate_float! value
100
+
94
101
  when :symbol
95
102
  unless value.is_a? Symbol
96
103
  raise InvalidArgumentTypeError, "`#{value}` is not a Symbol"
@@ -175,6 +182,13 @@ module DSLCompose
175
182
  end
176
183
  required_argument.validate_integer! value
177
184
 
185
+ when :float
186
+ # float allows either floats or integers
187
+ unless value.is_a?(Float) || value.is_a?(Integer)
188
+ raise InvalidArgumentTypeError, "`#{value}` is not an Float or Integer"
189
+ end
190
+ required_argument.validate_float! value
191
+
178
192
  when :symbol
179
193
  unless value.is_a? Symbol
180
194
  raise InvalidArgumentTypeError, "`#{value}` is not a Symbol"
@@ -66,22 +66,23 @@ module DSLCompose
66
66
  # Returns an ExecutionReader class which exposes a simple API to access the
67
67
  # arguments, methods and method arguments provided when using this DSL.
68
68
  #
69
- # If the dsl has been executed once or more on the provided class, then
70
- # the last (most recent) execution will be returned. If the DSL was not
69
+ # If the dsl has been executed once or more on the provided class, then a reader
70
+ # for the last (most recent) execution will be returned. If the DSL was not
71
71
  # executed on the provided class, then we traverse up the classes ancestors
72
72
  # and look for the last time it was executed on each ancestor.
73
73
  # If no execution of the DSL is found, then nil will be returned
74
74
  def last_execution
75
- ExecutionReader.new(@dsl_defining_class.dsls.get_last_dsl_execution(@klass, @dsl_name))
75
+ execution = @dsl_defining_class.dsls.get_last_dsl_execution(@klass, @dsl_name)
76
+ if execution.nil?
77
+ nil
78
+ else
79
+ ExecutionReader.new execution
80
+ end
76
81
  end
77
82
 
78
83
  # A wrapper for last_execution which raises an error if no execution exists
79
84
  def last_execution!
80
- execution = @dsl_defining_class.dsls.get_last_dsl_execution(@klass, @dsl_name)
81
- if execution.nil?
82
- raise NoDSLExecutionFound, "No execution of the `#{@dsl_name}` dsl was found on `#{@klass}` or any of its ancestors"
83
- end
84
- ExecutionReader.new execution
85
+ last_execution || (raise NoDSLExecutionFound, "No execution of the `#{@dsl_name}` dsl was found on `#{@klass}` or any of its ancestors")
85
86
  end
86
87
 
87
88
  # Returns an array of ExecutionReaders to represent each time the DSL was used
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DSLCompose
4
- VERSION = "2.2.0"
4
+ VERSION = "2.2.2"
5
5
  end
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: 2.2.0
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig Ulliott