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 +4 -4
- data/Gemfile.lock +7 -7
- data/lib/strict/interface.rb +11 -5
- data/lib/strict/interfaces/instance.rb +11 -2
- data/lib/strict/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b15e13a3f628809ea9410898b170658979f5e4c5a69b03a1ef4dcccad35e947f
|
4
|
+
data.tar.gz: b37173fddebaa55c744c20230548a80832a38c86e6bb4879f39d54a105fb5ddb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
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.
|
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.
|
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.
|
40
|
+
rubocop-ast (1.23.0)
|
41
41
|
parser (>= 3.1.1.0)
|
42
|
-
rubocop-minitest (0.
|
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.
|
48
|
+
zeitwerk (2.6.4)
|
49
49
|
|
50
50
|
PLATFORMS
|
51
51
|
arm64-darwin-21
|
data/lib/strict/interface.rb
CHANGED
@@ -13,13 +13,19 @@ module Strict
|
|
13
13
|
|
14
14
|
def expose(method_name, &block)
|
15
15
|
sig = sig(&block)
|
16
|
-
parameter_list =
|
17
|
-
|
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}
|
21
|
-
implementation.#{method_name}(#{argument_list}
|
22
|
-
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
|
-
|
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
|
data/lib/strict/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2022-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|