forwardable-extended 1.0.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
+ SHA1:
3
+ metadata.gz: 02ba0e024964bbc8dd125981a805d601f2d3392e
4
+ data.tar.gz: cac96d2b17ff585c8cfbe6a9b3c5ca4a82e2d747
5
+ SHA512:
6
+ metadata.gz: 4793f596b87fe6e0e5c77f94227ba388ec73fe51debe5c901cf279414cff5c7629236b16f95e699275ec7c9e1b965247425af0e1977da51851717bf5292b7509
7
+ data.tar.gz: cf5b23ee25cb1bd54a8155b18a08b1332af7c3c55fee11fdb6fd80a30c448134fe9c4534a8d7f016bf91ab3137824bfa9c4f4af3d8a58ebfac457bf982386ef8
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2015-2016 Jordon Bedwell - MIT License
3
+ # Encoding: utf-8
4
+
5
+ source "https://rubygems.org"
6
+ gem "rake", :require => false
7
+ gemspec
8
+
9
+ group :test do
10
+ gem "codeclimate-test-reporter", :require => false
11
+ end
12
+
13
+ group :development do
14
+ gem "rspec", :require => false
15
+ gem "rspec-helpers", :require => false
16
+ gem "luna-rspec-formatters", :require => false
17
+ gem "pry", :require => false
18
+ end
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2015-2016 Jordon Bedwell
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the "Software"),
5
+ to deal in the Software without restriction, including without limitation
6
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
7
+ and/or sell copies of the Software, and to permit persons to whom the
8
+ Software is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included
11
+ in all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
18
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
19
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2015-2016 Jordon Bedwell - MIT License
3
+ # Encoding: utf-8
4
+
5
+ $LOAD_PATH.unshift(File.expand_path("../lib", __FILE__))
6
+ require "rspec/core/rake_task"
7
+
8
+ task :default => [:spec]
9
+ RSpec::Core::RakeTask.new :spec
10
+ task :test => :spec
@@ -0,0 +1,9 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2015-2016 Jordon Bedwell - MIT License
3
+ # Encoding: utf-8
4
+
5
+ module Forwardable
6
+ module Extended
7
+ VERSION = "1.0.0"
8
+ end
9
+ end
@@ -0,0 +1,53 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2015-2016 Jordon Bedwell - MIT License
3
+ # Encoding: utf-8
4
+
5
+ require "forwardable/extended/version"
6
+ require "forwardable"
7
+
8
+ module Forwardable
9
+ module Extended
10
+ include Forwardable
11
+
12
+ def def_hash_delegator(hash, *methods, key: nil, bool: false, revbool: false)
13
+ line = __LINE__ - 1
14
+ file = __FILE__
15
+
16
+ [methods].flatten.each do |method|
17
+ prefix = bool || revbool ? "!!#{"!" if revbool}" : ""
18
+ var = key ? %(#{hash}["#{key}"]) : %(#{hash}["#{method}"])
19
+ method = method.to_s + "?" if revbool || bool
20
+
21
+ ruby = <<-STR
22
+ def #{method}
23
+ #{prefix}#{var}
24
+ end
25
+ STR
26
+
27
+ class_eval ruby, file, line
28
+ end
29
+ end
30
+
31
+ def def_ivar_delegator(var, method, bool: false, revbool: false)
32
+ line = __LINE__ - 1
33
+ file = __FILE__
34
+
35
+ prefix = revbool || bool ? "!!#{"!" if revbool}" : ""
36
+ method = method.to_s + "?" if revbool || bool
37
+ ruby = <<-STR
38
+ def #{method}
39
+ #{prefix}#{var}
40
+ end
41
+ STR
42
+
43
+ class_eval ruby, file, line
44
+ end
45
+
46
+ def def_ivar_delegators(vars, methods, **kwd)
47
+ raise ArgumentError, "unequal methods and vars" unless vars.size == methods.size
48
+ methods.zip(vars).each do |method, var|
49
+ def_ivar_delegator var, method, **kwd
50
+ end
51
+ end
52
+ end
53
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: forwardable-extended
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jordon Bedwell
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-09 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Forwardable with hash, and instance variable extensions.
14
+ email:
15
+ - jordon@envygeeks.io
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - Gemfile
21
+ - LICENSE
22
+ - Rakefile
23
+ - lib/forwardable/extended.rb
24
+ - lib/forwardable/extended/version.rb
25
+ homepage: http://github.com/envygeeks/extended-forwardable
26
+ licenses:
27
+ - MIT
28
+ metadata: {}
29
+ post_install_message:
30
+ rdoc_options: []
31
+ require_paths:
32
+ - lib
33
+ required_ruby_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ requirements: []
44
+ rubyforge_project:
45
+ rubygems_version: 2.5.1
46
+ signing_key:
47
+ specification_version: 4
48
+ summary: Forwardable with hash, and instance variable extensions.
49
+ test_files: []