method-arguments 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 56b3bf8fa589996b04f3a95f0aff70f6ea449cf0be40588d4344e9de310c8f73
4
+ data.tar.gz: ad8b957fe7c07352deaa1758a0895f8caa3ca85c4229ddff6d9ce29f6f33341c
5
+ SHA512:
6
+ metadata.gz: d48a0365e11cd4e8662657077e903830024f6e9644657f3e2138b1e6bddd1fb7933ba753288986f1057b40e720657295197a7a3f7085524c5ed5ccd8d6d3021a
7
+ data.tar.gz: 0d82e43f50de043ec3b2eb7ea6e5016fbb5cbf638f6c63be308341dc4868bb167062390b82285d21248cc7f1dfdbb6562bfa3a061ae947ae558185ba073b4480
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake'
4
+ gem 'rspec', group: 'test'
5
+ gem 'pry', group: 'development'
data/Gemfile.lock ADDED
@@ -0,0 +1,34 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ coderay (1.1.2)
5
+ diff-lcs (1.3)
6
+ method_source (0.9.2)
7
+ pry (0.12.2)
8
+ coderay (~> 1.1.0)
9
+ method_source (~> 0.9.0)
10
+ rake (12.3.2)
11
+ rspec (3.8.0)
12
+ rspec-core (~> 3.8.0)
13
+ rspec-expectations (~> 3.8.0)
14
+ rspec-mocks (~> 3.8.0)
15
+ rspec-core (3.8.2)
16
+ rspec-support (~> 3.8.0)
17
+ rspec-expectations (3.8.4)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.8.0)
20
+ rspec-mocks (3.8.1)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.8.0)
23
+ rspec-support (3.8.2)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ pry
30
+ rake
31
+ rspec
32
+
33
+ BUNDLED WITH
34
+ 2.0.1
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Hiro Asari
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # method-arguments
2
+ Obtain arguments passed to the current Ruby method and their values in a single call
3
+
4
+ This is most likely to be useful when logging debugging information.
5
+
6
+ ## Usage
7
+
8
+ ```ruby
9
+ require '__arguments__'
10
+
11
+ class Foo
12
+ include Arguments
13
+
14
+ def method1(required_arg, optional_arg="optional", required_kw_arg:, optional_kw_arg: "optional_kw")
15
+ __arguments__(binding)
16
+ end
17
+ end
18
+
19
+ Foo.new.method1("foo", "opt2", required_kw_arg: "required") # => [[:required_arg, "foo"], [:optional_arg, "opt2"], [:required_kw_arg, "required"], [:optional_kw_arg, "optional_kw"]]
20
+ ```
@@ -0,0 +1,6 @@
1
+ module Arguments
2
+ def __arguments__(bdg)
3
+ method_symbol = caller(1,1).first.match(/\`(?<name>[^']*)'/)[:name].to_sym
4
+ self.method(method_symbol).parameters.map { |e| [e[1], bdg.local_variable_get(e[1])] }
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module Arguments
2
+ VERSION = '0.1.0'
3
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: method-arguments
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Hiro Asari
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-09-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: ''
42
+ email:
43
+ - asari.ruby@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - Gemfile
49
+ - Gemfile.lock
50
+ - LICENSE
51
+ - README.md
52
+ - lib/__arguments__.rb
53
+ - lib/__arguments__/version.rb
54
+ homepage: https://github.com/BanzaiMan/ruby-arguments
55
+ licenses:
56
+ - MIT
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '2.2'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubygems_version: 3.0.3
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: Access list of arguments passed to the current method
77
+ test_files: []