strict 1.3.0 → 1.4.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: ae43c882eaf20478716e5770eff835c3c9611b714f20ba98b23418969a40cb8f
4
- data.tar.gz: b003e41e3b5efb4628e40c14dc84e4fdb64e8ab8c457a6299347d921ff4907bd
3
+ metadata.gz: b15e13a3f628809ea9410898b170658979f5e4c5a69b03a1ef4dcccad35e947f
4
+ data.tar.gz: b37173fddebaa55c744c20230548a80832a38c86e6bb4879f39d54a105fb5ddb
5
5
  SHA512:
6
- metadata.gz: c09fa26af6510b02c08c2cb7965f3ccb83703f0d5ca4c8a741516f09810e0069ed46bb69a6b5af0fec8effd105c6c0be49619a42c7ca5debacd5462391ebe9b4
7
- data.tar.gz: 17d077e3ea3ed656a71ff3fed66c057c9f49468bcdbd66b3ea16c1d519a7a2ab2ff28973b4b98507035dce8367ebf5e7665772ced2eaec67e4cf300c6e69d320
6
+ metadata.gz: 25bb591ed6df44c60f6e2c01f977f4fcb881b022e62af11adbcd32e4d15dd83bfbfd34a1f20139aa64b0de0e8447e8cdc9e73d6ff5ac5331ea1ef9cab81f1f7e
7
+ data.tar.gz: 46ddcaa771d227162e762d6bb424382c0efc3451d540340ad70a888842669ad8fb5969af11302d49ff5c5f5334852d44201be20253c399156373d9fd5d4c7ae8
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- strict (1.3.0)
4
+ strict (1.4.0)
5
5
  zeitwerk (~> 2.6)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  ast (2.4.2)
11
- debug (1.6.2)
11
+ debug (1.6.3)
12
12
  irb (>= 1.3.6)
13
13
  reline (>= 0.3.1)
14
14
  gem-release (2.2.2)
@@ -27,25 +27,25 @@ GEM
27
27
  reline (0.3.1)
28
28
  io-console (~> 0.5)
29
29
  rexml (3.2.5)
30
- rubocop (1.36.0)
30
+ rubocop (1.38.0)
31
31
  json (~> 2.3)
32
32
  parallel (~> 1.10)
33
33
  parser (>= 3.1.2.1)
34
34
  rainbow (>= 2.2.2, < 4.0)
35
35
  regexp_parser (>= 1.8, < 3.0)
36
36
  rexml (>= 3.2.5, < 4.0)
37
- rubocop-ast (>= 1.20.1, < 2.0)
37
+ rubocop-ast (>= 1.23.0, < 2.0)
38
38
  ruby-progressbar (~> 1.7)
39
39
  unicode-display_width (>= 1.4.0, < 3.0)
40
- rubocop-ast (1.21.0)
40
+ rubocop-ast (1.23.0)
41
41
  parser (>= 3.1.1.0)
42
- rubocop-minitest (0.22.2)
42
+ rubocop-minitest (0.23.0)
43
43
  rubocop (>= 0.90, < 2.0)
44
44
  rubocop-rake (0.6.0)
45
45
  rubocop (~> 1.0)
46
46
  ruby-progressbar (1.11.0)
47
47
  unicode-display_width (2.3.0)
48
- zeitwerk (2.6.1)
48
+ zeitwerk (2.6.4)
49
49
 
50
50
  PLATFORMS
51
51
  arm64-darwin-21
@@ -13,13 +13,19 @@ module Strict
13
13
 
14
14
  def expose(method_name, &block)
15
15
  sig = sig(&block)
16
- parameter_list = sig.parameters.map { |parameter| "#{parameter.name}:" }.join(", ")
17
- argument_list = sig.parameters.map { |parameter| "#{parameter.name}: #{parameter.name}" }.join(", ")
16
+ parameter_list = [
17
+ *sig.parameters.map { |parameter| "#{parameter.name}:" },
18
+ "&block"
19
+ ].join(", ")
20
+ argument_list = [
21
+ *sig.parameters.map { |parameter| "#{parameter.name}: #{parameter.name}" },
22
+ "&block"
23
+ ].join(", ")
18
24
 
19
25
  module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
20
- def #{method_name}(#{parameter_list}, &block) # def method_name(one:, two:, three:, &block)
21
- implementation.#{method_name}(#{argument_list}, &block) # implementation.method_name(one: one, two: two, three: three, &block)
22
- end # end
26
+ def #{method_name}(#{parameter_list}) # def method_name(one:, two:, three:, &block)
27
+ implementation.#{method_name}(#{argument_list}) # implementation.method_name(one: one, two: two, three: three, &block)
28
+ end # end
23
29
  RUBY
24
30
  end
25
31
  end
@@ -12,7 +12,7 @@ module Strict
12
12
  h[k] = { additional_parameters: [], missing_parameters: [], non_keyword_parameters: [] }
13
13
  end
14
14
 
15
- self.class.strict_instance_methods.each do |method_name, strict_method|
15
+ self.class.strict_instance_methods.each do |method_name, strict_method| # rubocop:disable Metrics/BlockLength
16
16
  unless implementation.respond_to?(method_name)
17
17
  missing_methods ||= []
18
18
  missing_methods << method_name
@@ -21,9 +21,16 @@ module Strict
21
21
 
22
22
  expected_parameters = Set.new(strict_method.parameters.map(&:name))
23
23
  defined_parameters = Set.new
24
+ has_keyword_splat = false
24
25
 
25
26
  implementation.method(method_name).parameters.each do |kind, parameter_name|
26
- next if kind == :block
27
+ case kind
28
+ when :block, :rest
29
+ next
30
+ when :keyrest
31
+ has_keyword_splat = true
32
+ next
33
+ end
27
34
 
28
35
  if expected_parameters.include?(parameter_name)
29
36
  defined_parameters.add(parameter_name)
@@ -33,6 +40,8 @@ module Strict
33
40
  end
34
41
  end
35
42
 
43
+ next if has_keyword_splat
44
+
36
45
  missing_parameters = expected_parameters - defined_parameters
37
46
  invalid_method_definitions[method_name][:missing_parameters] = missing_parameters if missing_parameters.any?
38
47
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Strict
4
- VERSION = "1.3.0"
4
+ VERSION = "1.4.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strict
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Thompson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-18 00:00:00.000000000 Z
11
+ date: 2022-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk