args_to_attrs 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
  SHA256:
3
- metadata.gz: a96c6432fb49be9f8a2d91993fa73bf2a0e523d5af768a296096793472f2e784
4
- data.tar.gz: a1f27bc79aefd4893a43fff02fbb513dcd7ccdfef11d07a8514e5fb4335cedd8
3
+ metadata.gz: 79de08d7ce08fee99bea6b51994f82c9c5a302d69f80d24d1a48eeceeb39a34d
4
+ data.tar.gz: 05e1776deb2e322cc819b009c960c56695064850a7b389f8172da02b49d7ab87
5
5
  SHA512:
6
- metadata.gz: 1b61a71d67d01c8e129841d0d340e67cb93bbe29d314f27daeaf2a9dddb6fd40f1cefc231ccf763fc45ea1160c57477b4d532b5cc5aef49d8937960d95010174
7
- data.tar.gz: 85f1321be21b38d87701b7fb4fc755ea7f1fc36bffe78d4fcca770dea93dc73b6a89c21bdb38d31d686119bf0f489329dba1062c00332d5f5796bb311219f0d6
6
+ metadata.gz: a724a1d91391b762e164e7eae68cf005b8791ad25d3bfd5530ef965dca48427680ebec12e88c0354f72c234ac8a1ced2e798ad4fcaeeda327c00daad9d5600be
7
+ data.tar.gz: 50ce9c629ba0add15efa843a197f67ba180e62d6192e6dcf90aa96168e8f55d56340ab6eb9d5c522192188d48fbb55349072db1c0ad4948638fb189e53c44a43
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  .vscode
2
+ .rspec_status
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.2.0 - 2022-03-13
4
+
5
+ Specs added
6
+
3
7
  ## 0.1.0 - 2022-03-13
4
8
 
5
9
  Initial implementation
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Gem's dependencies are specified in .gemspec file
4
+ gemspec
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ArgsToAttrs
4
4
 
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
 
7
7
  end
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
- receiver.method(self.eval('__method__')).parameters.each do |kind, name|
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.1.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