reverse_parameters 0.1.0 → 0.2.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
  SHA1:
3
- metadata.gz: aa58db49022971f0474e8045c170be870c93a9b2
4
- data.tar.gz: 4bd18676e3a56614f6895f4e9750d638beb1a7b2
3
+ metadata.gz: bbdaa436ad1d961969f0c4b2e68b41a4c675243a
4
+ data.tar.gz: ee4044dac199a904488ff433396cafbf498319a2
5
5
  SHA512:
6
- metadata.gz: b799b83b393c0b48548b4dc108f17e3e95e0660b6a6e06abb59e79312e54e80b26c0384bc489c05fc05e40ff20610835d2130fd90f8d636aa1ffa4f5b4350497
7
- data.tar.gz: 8669f5eb1d47e424b29be9cd639ca53846fabb5ba887bcc469d481dabb9ab32b8fb35fa3109d555613f60738106e26cf6fe0a12a3e49b89f3a7f55f0eaa79059
6
+ metadata.gz: 5b2987dba606dd3b323bd5940f1d56a1850e76c0bd50d6c0390dafea903ff7278d61b54433863381d9e8930141a52feb5e8f84b53b9fb6b31cae13c299eadc2e
7
+ data.tar.gz: aad7463471a424e34b8fa91d4bd40e3d48ee8f82d4f8f0dfa12b365f7050425c836434c8cd05ee8767365b66568b5599b114e86d5406aa443632d8339f791b6a
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/zeisler/reverse_parameters.svg)](https://travis-ci.org/zeisler/reverse_parameters)
4
4
  [![Code Climate](https://codeclimate.com/github/zeisler/active_mocker.png)](https://codeclimate.com/github/zeisler/reverse_parameters)
5
+ [![Gem Version](https://badge.fury.io/rb/reverse_parameters.svg)](http://badge.fury.io/rb/reverse_parameters)
5
6
 
6
7
  Recreate ruby method signatures using ruby's method to Proc creation `#method(:method_name).parameters`. Use this to dynamically recreate method parameter interfaces.
7
8
 
@@ -28,17 +29,18 @@ require 'reverse_parameters'
28
29
 
29
30
  def example_method(named_param:)
30
31
  end
31
-
32
- parameters = method(:example_method).parameters
33
- #=> [[:keyreq, :named_param]]
34
32
 
35
33
  # Method arguments are the real values passed to (and received by) the function.
36
- ReverseParameters.arguments(parameters).to_s
34
+ ReverseParameters.new(method(:example_method)).arguments.to_s
37
35
  #=> "named_param: named_param"
38
36
 
39
37
  # Method parameters are the names listed in the function definition.
40
- ReverseParameters.parameters(parameters).to_s
38
+ ReverseParameters.new(method(:example_method)).parameters.to_s
41
39
  #=> "named_param:"
40
+
41
+ # Source Ruby API
42
+ method(:example_method).parameters
43
+ #=> [[:keyreq, :named_param]]
42
44
  ```
43
45
 
44
46
  ## Limitations
@@ -2,6 +2,7 @@ require "reverse_parameters/version"
2
2
 
3
3
  class ReverseParameters
4
4
 
5
+ # @param input [Proc, Array]
5
6
  def initialize(input)
6
7
  if input.respond_to?(:to_proc)
7
8
  @params = input.to_proc.parameters
@@ -13,11 +14,13 @@ class ReverseParameters
13
14
  end
14
15
 
15
16
  # Method parameters are the names listed in the function definition.
17
+ # @return [ReverseParameters::Parameters]
16
18
  def parameters
17
19
  Parameters.new(params)
18
20
  end
19
21
 
20
22
  # Method arguments are the real values passed to (and received by) the function.
23
+ # @return [ReverseParameters::Arguments]
21
24
  def arguments
22
25
  Arguments.new(params)
23
26
  end
@@ -77,6 +80,8 @@ class ReverseParameters
77
80
  name
78
81
  when :rest
79
82
  "*#{name}"
83
+ when :keyrest
84
+ "**#{name}"
80
85
  when :opt
81
86
  "#{name}=nil"
82
87
  when :keyreq
@@ -1,3 +1,3 @@
1
1
  class ReverseParameters
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
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: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dustin Zeisler
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-29 00:00:00.000000000 Z
11
+ date: 2015-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  version: '0'
94
94
  requirements: []
95
95
  rubyforge_project:
96
- rubygems_version: 2.4.6
96
+ rubygems_version: 2.2.5
97
97
  signing_key:
98
98
  specification_version: 4
99
99
  summary: Recreate ruby method signatures.