args_to_attrs 0.1.0 → 0.2.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 +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +68 -0
- data/lib/args_to_attrs/version.rb +1 -1
- data/lib/args_to_attrs.rb +8 -5
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 79de08d7ce08fee99bea6b51994f82c9c5a302d69f80d24d1a48eeceeb39a34d
|
|
4
|
+
data.tar.gz: 05e1776deb2e322cc819b009c960c56695064850a7b389f8172da02b49d7ab87
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a724a1d91391b762e164e7eae68cf005b8791ad25d3bfd5530ef965dca48427680ebec12e88c0354f72c234ac8a1ced2e798ad4fcaeeda327c00daad9d5600be
|
|
7
|
+
data.tar.gz: 50ce9c629ba0add15efa843a197f67ba180e62d6192e6dcf90aa96168e8f55d56340ab6eb9d5c522192188d48fbb55349072db1c0ad4948638fb189e53c44a43
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
args_to_attrs (0.1.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
coderay (1.1.3)
|
|
10
|
+
diff-lcs (1.5.0)
|
|
11
|
+
ffi (1.15.5)
|
|
12
|
+
formatador (1.1.0)
|
|
13
|
+
guard (2.18.0)
|
|
14
|
+
formatador (>= 0.2.4)
|
|
15
|
+
listen (>= 2.7, < 4.0)
|
|
16
|
+
lumberjack (>= 1.0.12, < 2.0)
|
|
17
|
+
nenv (~> 0.1)
|
|
18
|
+
notiffany (~> 0.0)
|
|
19
|
+
pry (>= 0.13.0)
|
|
20
|
+
shellany (~> 0.0)
|
|
21
|
+
thor (>= 0.18.1)
|
|
22
|
+
guard-compat (1.2.1)
|
|
23
|
+
guard-rspec (4.7.3)
|
|
24
|
+
guard (~> 2.1)
|
|
25
|
+
guard-compat (~> 1.1)
|
|
26
|
+
rspec (>= 2.99.0, < 4.0)
|
|
27
|
+
listen (3.7.1)
|
|
28
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
29
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
|
30
|
+
lumberjack (1.2.8)
|
|
31
|
+
method_source (1.0.0)
|
|
32
|
+
nenv (0.3.0)
|
|
33
|
+
notiffany (0.1.3)
|
|
34
|
+
nenv (~> 0.1)
|
|
35
|
+
shellany (~> 0.0)
|
|
36
|
+
pry (0.14.1)
|
|
37
|
+
coderay (~> 1.1)
|
|
38
|
+
method_source (~> 1.0)
|
|
39
|
+
rb-fsevent (0.11.1)
|
|
40
|
+
rb-inotify (0.10.1)
|
|
41
|
+
ffi (~> 1.0)
|
|
42
|
+
rspec (3.11.0)
|
|
43
|
+
rspec-core (~> 3.11.0)
|
|
44
|
+
rspec-expectations (~> 3.11.0)
|
|
45
|
+
rspec-mocks (~> 3.11.0)
|
|
46
|
+
rspec-core (3.11.0)
|
|
47
|
+
rspec-support (~> 3.11.0)
|
|
48
|
+
rspec-expectations (3.11.0)
|
|
49
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
50
|
+
rspec-support (~> 3.11.0)
|
|
51
|
+
rspec-mocks (3.11.0)
|
|
52
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
53
|
+
rspec-support (~> 3.11.0)
|
|
54
|
+
rspec-support (3.11.0)
|
|
55
|
+
shellany (0.0.1)
|
|
56
|
+
thor (1.2.1)
|
|
57
|
+
|
|
58
|
+
PLATFORMS
|
|
59
|
+
ruby
|
|
60
|
+
|
|
61
|
+
DEPENDENCIES
|
|
62
|
+
args_to_attrs!
|
|
63
|
+
guard-rspec (~> 4.7)
|
|
64
|
+
pry
|
|
65
|
+
rspec (~> 3.2)
|
|
66
|
+
|
|
67
|
+
BUNDLED WITH
|
|
68
|
+
2.1.4
|
data/lib/args_to_attrs.rb
CHANGED
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
module ArgsToAttrs
|
|
4
4
|
|
|
5
|
+
ArgumentForwardingNotSupportedError = Class.new(StandardError)
|
|
6
|
+
|
|
7
|
+
OutOfMethodError = Class.new(StandardError)
|
|
8
|
+
|
|
5
9
|
module InstanceMethods
|
|
6
10
|
def args_to_attrs!(expand_keyrest: false)
|
|
7
11
|
arguments = Array.new
|
|
8
12
|
rest_keyword_args = {}
|
|
9
|
-
|
|
13
|
+
method_name = self.eval('__method__') or raise OutOfMethodError
|
|
14
|
+
receiver.method(method_name).parameters.each do |kind, name|
|
|
10
15
|
case kind
|
|
11
16
|
when :key, :keyreq, :req, :opt
|
|
12
17
|
arguments << name
|
|
@@ -14,6 +19,8 @@ module ArgsToAttrs
|
|
|
14
19
|
next unless expand_keyrest
|
|
15
20
|
rest_keyword_args = self.local_variable_get(name)
|
|
16
21
|
arguments = arguments.union(rest_keyword_args.keys)
|
|
22
|
+
when :rest
|
|
23
|
+
fail ArgumentForwardingNotSupportedError if name == :*
|
|
17
24
|
end
|
|
18
25
|
end
|
|
19
26
|
assignment_order = block_given? ? yield(arguments.to_a) : arguments
|
|
@@ -29,10 +36,6 @@ module ArgsToAttrs
|
|
|
29
36
|
end
|
|
30
37
|
end
|
|
31
38
|
true
|
|
32
|
-
rescue NameError => e
|
|
33
|
-
raise e unless e.message =~ /wrong local variable name/
|
|
34
|
-
|
|
35
|
-
raise "Argument forwarding is not supported"
|
|
36
39
|
end
|
|
37
40
|
end
|
|
38
41
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: args_to_attrs
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vladimir Gorodulin
|
|
@@ -61,6 +61,8 @@ extra_rdoc_files: []
|
|
|
61
61
|
files:
|
|
62
62
|
- ".gitignore"
|
|
63
63
|
- CHANGELOG.md
|
|
64
|
+
- Gemfile
|
|
65
|
+
- Gemfile.lock
|
|
64
66
|
- LICENSE
|
|
65
67
|
- args_to_attrs.gemspec
|
|
66
68
|
- lib/args_to_attrs.rb
|