marameters 3.8.0 → 3.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.adoc +2 -0
- data/lib/marameters/builder.rb +2 -1
- data/lib/marameters/defaulter.rb +7 -22
- data/lib/marameters/probe.rb +10 -1
- data/lib/marameters.rb +2 -0
- data/marameters.gemspec +2 -2
- data.tar.gz.sig +0 -0
- metadata +5 -5
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72e522d6b0e294687fe361c583d0c35d50287843e927e772ed4ce2c9e99cb122
|
4
|
+
data.tar.gz: 5c70165bfd8b9036982b01dd45926daeeb349b9fcbc880cf330d6635b4511ec9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c43d9e5016ee8436764959892a642ecaac2a22ec66d2439b673f1646e9fc93b9e030f6b07304a6c936db4edd2c4687a268c2569fb73d487f39c3144e962886e2
|
7
|
+
data.tar.gz: 18ab62e24d33a6a03b34e2c01cacb1c6b2b844a245062a0db0e79e0fd66560b2c30b6f28829cc9ed0a2389dc6281bc546ac435692ffd41f466f9bf9591f31418
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.adoc
CHANGED
@@ -139,6 +139,7 @@ probe.positionals? # true
|
|
139
139
|
probe.splats # [:three, :six]
|
140
140
|
probe.splats? # true
|
141
141
|
probe.to_a # [[:req, :one], [:opt, :two], [:rest, :three], [:keyreq, :four], [:key, :five], [:keyrest, :six], [:block, :seven]]
|
142
|
+
probe.to_h # {req: :one, opt: :two, rest: :three, keyreq: :four, key: :five, keyrest: :six, block: :seven}
|
142
143
|
----
|
143
144
|
|
144
145
|
In contrast the above, we can also probe the `#none` method which has no parameters for a completely
|
@@ -165,6 +166,7 @@ probe.positionals? # false
|
|
165
166
|
probe.splats # []
|
166
167
|
probe.splats? # false
|
167
168
|
probe.to_a # []
|
169
|
+
probe.to_h # {}
|
168
170
|
----
|
169
171
|
|
170
172
|
=== Categorizer
|
data/lib/marameters/builder.rb
CHANGED
@@ -7,11 +7,12 @@ module Marameters
|
|
7
7
|
@defaulter = defaulter
|
8
8
|
end
|
9
9
|
|
10
|
-
def call kind, name, default: nil
|
10
|
+
def call kind, name = nil, default: nil
|
11
11
|
case kind
|
12
12
|
when :req then name
|
13
13
|
when :opt then "#{name} = #{defaulter.call default}"
|
14
14
|
when :rest then "*#{name}"
|
15
|
+
when :nokey then "**nil"
|
15
16
|
when :keyreq then "#{name}:"
|
16
17
|
when :key then "#{name}: #{defaulter.call default}"
|
17
18
|
when :keyrest then "**#{name}"
|
data/lib/marameters/defaulter.rb
CHANGED
@@ -2,28 +2,13 @@
|
|
2
2
|
|
3
3
|
module Marameters
|
4
4
|
# Computes a method parameter's default value.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
@passthrough = passthrough
|
13
|
-
end
|
14
|
-
|
15
|
-
def call
|
16
|
-
case value
|
17
|
-
when nil then "nil"
|
18
|
-
when /\A#{Regexp.escape passthrough}/ then value.delete_prefix passthrough
|
19
|
-
when String then value.dump
|
20
|
-
when Symbol then value.inspect
|
21
|
-
else value
|
22
|
-
end
|
5
|
+
Defaulter = lambda do |value, passthrough: "*"|
|
6
|
+
case value
|
7
|
+
when /\A#{Regexp.escape passthrough}/ then value.delete_prefix passthrough
|
8
|
+
when String then value.dump
|
9
|
+
when Symbol then value.inspect
|
10
|
+
when nil then "nil"
|
11
|
+
else value
|
23
12
|
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
attr_reader :value, :passthrough
|
28
13
|
end
|
29
14
|
end
|
data/lib/marameters/probe.rb
CHANGED
@@ -32,7 +32,14 @@ module Marameters
|
|
32
32
|
def empty? = parameters.empty?
|
33
33
|
|
34
34
|
def keyword_slice collection, keys:
|
35
|
-
|
35
|
+
warn "`#{self.class}##{__method__}` is deprecated, use `#keywords_for` instead.",
|
36
|
+
category: :deprecated
|
37
|
+
|
38
|
+
keywords_for(*keys, **collection)
|
39
|
+
end
|
40
|
+
|
41
|
+
def keywords_for(*keys, **attributes)
|
42
|
+
attributes.select { |key| !keys.include?(key) || keywords.include?(key) }
|
36
43
|
end
|
37
44
|
|
38
45
|
def keywords? = keywords.any?
|
@@ -64,6 +71,8 @@ module Marameters
|
|
64
71
|
|
65
72
|
def to_a = parameters
|
66
73
|
|
74
|
+
def to_h = parameters.each.with_object({}) { |(key, name), attributes| attributes[key] = name }
|
75
|
+
|
67
76
|
private
|
68
77
|
|
69
78
|
attr_reader :parameters
|
data/lib/marameters.rb
CHANGED
@@ -10,6 +10,8 @@ end
|
|
10
10
|
|
11
11
|
# Main namespace.
|
12
12
|
module Marameters
|
13
|
+
KINDS = %i[req opt rest nokey keyreq key keyrest block].freeze
|
14
|
+
|
13
15
|
def self.loader registry = Zeitwerk::Registry
|
14
16
|
@loader ||= registry.loaders.find { |loader| loader.tag == File.basename(__FILE__, ".rb") }
|
15
17
|
end
|
data/marameters.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "marameters"
|
5
|
-
spec.version = "3.
|
5
|
+
spec.version = "3.10.0"
|
6
6
|
spec.authors = ["Brooke Kuhlmann"]
|
7
7
|
spec.email = ["brooke@alchemists.io"]
|
8
8
|
spec.homepage = "https://alchemists.io/projects/marameters"
|
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
|
25
25
|
spec.required_ruby_version = ">= 3.3", "<= 3.4"
|
26
26
|
spec.add_dependency "refinements", "~> 12.9"
|
27
|
-
spec.add_dependency "zeitwerk", "~> 2.
|
27
|
+
spec.add_dependency "zeitwerk", "~> 2.7"
|
28
28
|
|
29
29
|
spec.extra_rdoc_files = Dir["README*", "LICENSE*"]
|
30
30
|
spec.files = Dir["*.gemspec", "lib/**/*"]
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marameters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
3n5C8/6Zh9DYTkpcwPSuIfAga6wf4nXc9m6JAw8AuMLaiWN/r/2s4zJsUHYERJEu
|
36
36
|
gZGm4JqtuSg8pYjPeIJxS960owq+SfuC+jxqmRA54BisFCv/0VOJi7tiJVY=
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2024-10-
|
38
|
+
date: 2024-10-18 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: refinements
|
@@ -57,14 +57,14 @@ dependencies:
|
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '2.
|
60
|
+
version: '2.7'
|
61
61
|
type: :runtime
|
62
62
|
prerelease: false
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: '2.
|
67
|
+
version: '2.7'
|
68
68
|
description:
|
69
69
|
email:
|
70
70
|
- brooke@alchemists.io
|
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
|
-
rubygems_version: 3.5.
|
116
|
+
rubygems_version: 3.5.22
|
117
117
|
signing_key:
|
118
118
|
specification_version: 4
|
119
119
|
summary: A dynamic method parameter inspector.
|
metadata.gz.sig
CHANGED
Binary file
|