reverse_parameters 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +2 -2
- data/lib/reverse_parameters.rb +10 -0
- data/lib/reverse_parameters/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adf1aec736659f20365e3d92f474c03f45031f91
|
4
|
+
data.tar.gz: 8e19ca1e68f7f0679ebd2af4718ecba475d3629a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a831cba1405aaedded16672f2e7f1dc11a1b58964d0a3731a07a20abe13ad7f7bc41663e4655858269c4cae6572ffb6700dbb62710f65c7e208b05c2bbd95ea
|
7
|
+
data.tar.gz: 1bc060fb412311dae8f30545b95118409805d87853e8d68f1cd28eb19dee76cb6b7de975dd5585f9257c78ca9154699394f7b65c4e8798206151074187aaecba
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## 1.1.1 - 2016-07-21
|
2
|
+
|
3
|
+
## Fix
|
4
|
+
- `ReverseParameters::Arguments` has been fixed to correctly make values passable from keyrest and rest args.
|
5
|
+
|
6
|
+
### Enhancement
|
7
|
+
- `ReverseParameters.new` now correctly accepts `UnboundMethod` objects.
|
8
|
+
|
1
9
|
## 1.1.0 - 2016-03-24
|
2
10
|
|
3
11
|
### API Changes
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# ReverseParameters
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/zeisler/reverse_parameters.svg)](https://travis-ci.org/zeisler/reverse_parameters)
|
4
|
-
[![Code Climate](https://codeclimate.com/github/zeisler/
|
4
|
+
[![Code Climate](https://codeclimate.com/github/zeisler/reverse_parameters/badges/gpa.svg)](https://codeclimate.com/github/zeisler/reverse_parameters)
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/reverse_parameters.svg)](http://badge.fury.io/rb/reverse_parameters)
|
6
6
|
|
7
7
|
Recreate ruby method signatures using ruby's method to Proc creation `#method(:method_name).parameters`. Use this to dynamically recreate method parameter interfaces.
|
@@ -53,7 +53,7 @@ def example_method(named_param:)
|
|
53
53
|
end
|
54
54
|
|
55
55
|
# Method arguments are the real values passed to (and received by) the function.
|
56
|
-
method(:example_method).
|
56
|
+
method(:example_method).reverse_parameters.arguments.to_s
|
57
57
|
#=> "named_param: named_param"
|
58
58
|
|
59
59
|
# Method parameters are the names listed in the function definition.
|
data/lib/reverse_parameters.rb
CHANGED
@@ -16,6 +16,8 @@ module ReverseParameters
|
|
16
16
|
@params = input.to_proc.parameters
|
17
17
|
elsif input.respond_to?(:to_ary)
|
18
18
|
@params = input.to_ary
|
19
|
+
elsif input.is_a? UnboundMethod
|
20
|
+
@params = input.parameters
|
19
21
|
else
|
20
22
|
raise ArgumentError.new("Input must be an Array of parameters or a Proc object.")
|
21
23
|
end
|
@@ -64,6 +66,10 @@ module ReverseParameters
|
|
64
66
|
map(&:to_s)
|
65
67
|
end
|
66
68
|
|
69
|
+
def [](value)
|
70
|
+
@collection[value]
|
71
|
+
end
|
72
|
+
|
67
73
|
class Item
|
68
74
|
def initialize(name:, state:, **options)
|
69
75
|
@name = name
|
@@ -85,6 +91,10 @@ module ReverseParameters
|
|
85
91
|
case state
|
86
92
|
when :key, :keyreq
|
87
93
|
"#{name}: #{name}"
|
94
|
+
when :keyrest
|
95
|
+
"**#{name}"
|
96
|
+
when :rest
|
97
|
+
"*#{name}"
|
88
98
|
when :block
|
89
99
|
block(name)
|
90
100
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reverse_parameters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dustin Zeisler
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
version: '0'
|
99
99
|
requirements: []
|
100
100
|
rubyforge_project:
|
101
|
-
rubygems_version: 2.
|
101
|
+
rubygems_version: 2.5.1
|
102
102
|
signing_key:
|
103
103
|
specification_version: 4
|
104
104
|
summary: Recreate ruby method signatures.
|