easy_decorator 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +56 -0
- data/LICENSE +21 -0
- data/README.md +2 -0
- data/easy_decorator.gemspec +30 -0
- data/lib/easy_decorator.rb +25 -9
- metadata +40 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a51c2c2a637daadfba8be3453ec7af886c5f484c2ec62a065bcc423f6f4d21c
|
4
|
+
data.tar.gz: e747a3b3b141dc49e69da1a7efba88e4752e1c06540037cbda78ebb830199f35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c1b39ac4a156d3ad49d04cbcf494394bcd3f7dbd881c98bc445c30bd3eaccc478c264b2e399ec76eab33bd187d786a437a96c7d9b73cffe8921bcc20795e0f1
|
7
|
+
data.tar.gz: 90904664433a98ff9a275ad5bc1c9beb8ea58cdab973dd3e6da0f80a5b08bf30bb8624752f17e1154ef7f37540941656cff78be4d15ab7fe43d58daab6e89082
|
data/.gitignore
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
# Ignore Byebug command history file.
|
17
|
+
.byebug_history
|
18
|
+
|
19
|
+
## Specific to RubyMotion:
|
20
|
+
.dat*
|
21
|
+
.repl_history
|
22
|
+
build/
|
23
|
+
*.bridgesupport
|
24
|
+
build-iPhoneOS/
|
25
|
+
build-iPhoneSimulator/
|
26
|
+
|
27
|
+
## Specific to RubyMotion (use of CocoaPods):
|
28
|
+
#
|
29
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
30
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
31
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
32
|
+
#
|
33
|
+
# vendor/Pods/
|
34
|
+
|
35
|
+
## Documentation cache and generated files:
|
36
|
+
/.yardoc/
|
37
|
+
/_yardoc/
|
38
|
+
/doc/
|
39
|
+
/rdoc/
|
40
|
+
|
41
|
+
## Environment normalization:
|
42
|
+
/.bundle/
|
43
|
+
/vendor/bundle
|
44
|
+
/lib/bundler/man/
|
45
|
+
|
46
|
+
# for a library or gem, you might want to ignore these files since the code is
|
47
|
+
# intended to run in multiple environments; otherwise, check them in:
|
48
|
+
Gemfile.lock
|
49
|
+
.ruby-version
|
50
|
+
# .ruby-gemset
|
51
|
+
|
52
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
53
|
+
.rvmrc
|
54
|
+
|
55
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
56
|
+
# .rubocop-https?--*
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2020 Josh Crank
|
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,30 @@
|
|
1
|
+
require_relative 'lib/easy_decorator/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.name = 'easy_decorator'
|
5
|
+
gem.version = EasyDecorator::VERSION
|
6
|
+
gem.date = '2020-10-13'
|
7
|
+
gem.authors = ['Josh Crank']
|
8
|
+
gem.email = 'joshuatcrank@gmail.com'
|
9
|
+
|
10
|
+
gem.summary = %q{A method decorator for Ruby.}
|
11
|
+
gem.description = %q{Bring in Python's decorator pattern for Ruby methods.}
|
12
|
+
gem.homepage = 'https://github.com/jtcrank/easy_decorator'
|
13
|
+
gem.license = 'MIT'
|
14
|
+
gem.required_ruby_version = Gem::Requirement.new(">=2.6")
|
15
|
+
|
16
|
+
gem.metadata['homepage_uri'] = gem.homepage
|
17
|
+
gem.metadata['source_code_uri'] = gem.homepage
|
18
|
+
gem.metadata['changelog_uri'] = gem.homepage
|
19
|
+
|
20
|
+
gem.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f|
|
22
|
+
f.match(%r{^(test|spec|features)/})
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
gem.require_paths = ['lib']
|
27
|
+
gem.add_development_dependency 'pry'
|
28
|
+
gem.add_development_dependency 'rspec'
|
29
|
+
|
30
|
+
end
|
data/lib/easy_decorator.rb
CHANGED
@@ -1,15 +1,31 @@
|
|
1
|
+
require 'easy_decorator/errors'
|
2
|
+
|
1
3
|
module EasyDecorator
|
2
|
-
def self.
|
3
|
-
|
4
|
+
def self.included(base_klass)
|
5
|
+
base_klass.extend(ClassMethods)
|
6
|
+
base_klass.instance_variable_set(:@decorated_methods, {})
|
4
7
|
end
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
module ClassMethods
|
10
|
+
def decorate(decorator, decorated)
|
11
|
+
@decorated_methods[decorated] = {
|
12
|
+
decorator: decorator,
|
13
|
+
is_decorated: false
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
def method_added(method_name)
|
18
|
+
decorator = @decorated_methods[method_name]
|
19
|
+
if decorator && !decorator[:is_decorated]
|
20
|
+
decorator[:is_decorated] = true
|
21
|
+
source_method_name = "source_#{method_name}".to_sym
|
22
|
+
alias_method source_method_name, method_name
|
23
|
+
|
24
|
+
define_method method_name do |*args|
|
25
|
+
send(decorator[:decorator], source_method_name, *args)
|
26
|
+
end
|
27
|
+
end
|
13
28
|
end
|
14
29
|
end
|
15
30
|
end
|
31
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_decorator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Crank
|
@@ -9,18 +9,53 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2020-10-13 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pry
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
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'
|
13
41
|
description: Bring in Python's decorator pattern for Ruby methods.
|
14
42
|
email: joshuatcrank@gmail.com
|
15
43
|
executables: []
|
16
44
|
extensions: []
|
17
45
|
extra_rdoc_files: []
|
18
46
|
files:
|
47
|
+
- ".gitignore"
|
48
|
+
- LICENSE
|
49
|
+
- README.md
|
50
|
+
- easy_decorator.gemspec
|
19
51
|
- lib/easy_decorator.rb
|
20
52
|
homepage: https://github.com/jtcrank/easy_decorator
|
21
53
|
licenses:
|
22
54
|
- MIT
|
23
|
-
metadata:
|
55
|
+
metadata:
|
56
|
+
homepage_uri: https://github.com/jtcrank/easy_decorator
|
57
|
+
source_code_uri: https://github.com/jtcrank/easy_decorator
|
58
|
+
changelog_uri: https://github.com/jtcrank/easy_decorator
|
24
59
|
post_install_message:
|
25
60
|
rdoc_options: []
|
26
61
|
require_paths:
|
@@ -29,15 +64,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
29
64
|
requirements:
|
30
65
|
- - ">="
|
31
66
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
67
|
+
version: '2.6'
|
33
68
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
69
|
requirements:
|
35
70
|
- - ">="
|
36
71
|
- !ruby/object:Gem::Version
|
37
72
|
version: '0'
|
38
73
|
requirements: []
|
39
|
-
|
40
|
-
rubygems_version: 2.7.6
|
74
|
+
rubygems_version: 3.0.3
|
41
75
|
signing_key:
|
42
76
|
specification_version: 4
|
43
77
|
summary: A method decorator for Ruby.
|