marameters 3.7.0 → 3.9.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: e0d776cb84e83828805be4664e3058f0883edf63de1db7cd20e2d54fd20c41a0
4
- data.tar.gz: cc2bec924215e0f27d2e5c52d444db4ea7bca4fc32b40699f78d7ba104b78cef
3
+ metadata.gz: 7606dc2ae5b229a62afef737d7e5ced158c9c0cb49cd2ea1dc5dcb90d82e2c72
4
+ data.tar.gz: 055dc360d709822f1cc49157faedde426a6ba6e4f393aa7e0f6adbb0ec10784d
5
5
  SHA512:
6
- metadata.gz: 7a818b35c7aecdc9432eb7b96517c0e629fe9816481179372de29102cf00876aa61d8920fa621e798b47aed25d2d75fddb74d8bcf67a5836497b8f52076238f9
7
- data.tar.gz: 1a875076d47cde1a32375841ba2a15d97dd2c67bfdc717c2fb3b25dc9557e8c84ee8733cdc13259039e5324d08adc3ff667f7c0875c35b37aed510998515f512
6
+ metadata.gz: 4da9a50704be5f6f8380d7e5f47c7296392b0786d64f72600a0931b7717d16318e722350c79efd233d5357be4a68682f067e73bba3197799a6252c7e2416623d
7
+ data.tar.gz: d17300ba62b53036f7eb999dc50f41e847de43caf52fbb3c2561f8c803fbbc50af69c590181c1eb88d84c38d7c5fe291ef4950a7bd4dd370bc907e24974fa9c3
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
@@ -2,28 +2,13 @@
2
2
 
3
3
  module Marameters
4
4
  # Computes a method parameter's default value.
5
- class Defaulter
6
- PASSTHROUGH = "*"
7
-
8
- def self.call(...) = new(...).call
9
-
10
- def initialize value, passthrough: PASSTHROUGH
11
- @value = value
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
@@ -32,7 +32,14 @@ module Marameters
32
32
  def empty? = parameters.empty?
33
33
 
34
34
  def keyword_slice collection, keys:
35
- collection.select { |key| !keys.include?(key) || keywords.include?(key) }
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/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.7.0"
5
+ spec.version = "3.9.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://alchemists.io/projects/marameters"
@@ -23,8 +23,8 @@ Gem::Specification.new do |spec|
23
23
  spec.cert_chain = [Gem.default_cert_path]
24
24
 
25
25
  spec.required_ruby_version = ">= 3.3", "<= 3.4"
26
- spec.add_dependency "refinements", "~> 12.8"
27
- spec.add_dependency "zeitwerk", "~> 2.6"
26
+ spec.add_dependency "refinements", "~> 12.9"
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.7.0
4
+ version: 3.9.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-09-01 00:00:00.000000000 Z
38
+ date: 2024-10-13 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: refinements
@@ -43,28 +43,28 @@ dependencies:
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '12.8'
46
+ version: '12.9'
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '12.8'
53
+ version: '12.9'
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: zeitwerk
56
56
  requirement: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '2.6'
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.6'
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.18
116
+ rubygems_version: 3.5.21
117
117
  signing_key:
118
118
  specification_version: 4
119
119
  summary: A dynamic method parameter inspector.
metadata.gz.sig CHANGED
Binary file