rdecorator 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c425c04acd69e9138fbf8a90c2dd3d167f4fe457
4
+ data.tar.gz: db37f8759736880211dddf05625c32b6b8b7520c
5
+ SHA512:
6
+ metadata.gz: b81b0b168021bc4dfabd9abf675afa05d97aaa4478cbe258225cf9128d0bc4bb302b99a8fb1149fa894e358b316d4cba01b7168597aeeedd99c6fc8f1cebcf2c
7
+ data.tar.gz: d40b2ec179e7e81d46131df49f0273e7eec77548af1d76ad1d6afa72f10ff1a7b77d08b9f9aa191e59c4a527e7bc632fbe9f3e6674fb7655175b2f1f20506102
@@ -0,0 +1 @@
1
+ service_name: travis-ci
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ .idea/
12
+ *.un~
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
4
+ - 2.2
5
+ - 2.3.0
6
+ - 2.4.0
7
+ script: xvfb-run rspec
8
+ before_install: gem install bundler -v 1.13.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rdecorator.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 Jason Hou
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.
@@ -0,0 +1,63 @@
1
+ # RDecorator
2
+ [![Build Status](https://travis-ci.org/falm/rdecorator.svg?branch=master)](https://travis-ci.org/falm/rdecorator) [![Coverage Status](https://coveralls.io/repos/github/falm/rdecorator/badge.svg?branch=master)](https://coveralls.io/github/falm/rdecorator?branch=master) [![Dependency Status](https://gemnasium.com/badges/github.com/falm/rdecorator.svg)](https://gemnasium.com/github.com/falm/rdecorator) [![Code Climate](https://codeclimate.com/github/falm/rdecorator/badges/gpa.svg)](https://codeclimate.com/github/falm/rdecorator)
3
+
4
+ Rdecorator is an Pyhton like decorator use for AOP pattern programming
5
+
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'rdecorator', github: 'https://github.com/falm/rdecorator.git'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ ## Usage
20
+
21
+ ### Basic
22
+ ```ruby
23
+ class Language
24
+ extend Rdecorator
25
+
26
+ def best(this, args)
27
+ 'best Language' + this.call(args)
28
+ end
29
+
30
+ wrap :best
31
+ def ruby
32
+ 'ruby'
33
+ end
34
+ end
35
+
36
+ Language.new.ruby #=> best Language ruby
37
+
38
+ ```
39
+
40
+ ### Decorator Class
41
+ ```ruby
42
+ class Decorator
43
+
44
+ include Rdecorator
45
+
46
+ def call
47
+ 'say fucking' + @this.call(*@args)
48
+ end
49
+ end
50
+
51
+ class DummyClass
52
+
53
+ decorator Decorator
54
+ def say(hello)
55
+ 'hello'
56
+ end
57
+
58
+ end
59
+ ```
60
+
61
+ ## Contributing
62
+
63
+ Bug reports and pull requests are welcome on GitHub at https://github.com/falm/rdecorator.
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rdecorator"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,48 @@
1
+ require "rdecorator/version"
2
+
3
+ module Rdecorator
4
+
5
+ def initialize(this, *args)
6
+ @this = this
7
+ @args = args
8
+ end
9
+
10
+ def method_added(method_name)
11
+
12
+ unless decorator_methods.empty?
13
+
14
+ decorator_method = decorator_methods.pop
15
+
16
+ new_name = "#{method_name}_without_decorator"
17
+
18
+ alias_method new_name, method_name
19
+
20
+ define_method method_name do |*args|
21
+
22
+ fn = method(new_name)
23
+
24
+ callback = Proc.new {|p = args| fn.call(*p)}
25
+
26
+ if decorator_method.kind_of? Class
27
+ decorator_method.new(fn, *args).call &callback
28
+ else
29
+ method(decorator_method).call fn, *args, &callback
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+
38
+ def wrap(decorator)
39
+ decorator_methods << decorator
40
+ end
41
+
42
+ alias_method :decorator, :wrap
43
+
44
+ def decorator_methods
45
+ @decorator_methods ||= []
46
+ end
47
+
48
+ end
@@ -0,0 +1,3 @@
1
+ module Rdecorator
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rdecorator/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rdecorator"
8
+ spec.version = Rdecorator::VERSION
9
+ spec.authors = ["Jason Hou"]
10
+ spec.email = ["hjj1992@gmail.com"]
11
+
12
+ spec.summary = %q{The decorator design pattern for ruby}
13
+ spec.description = %q{Python like decorator in ruby}
14
+ spec.homepage = "http://github.com/falm/rdecorator"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+ spec.licenses = ["MIT"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.13"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.4"
27
+ spec.add_development_dependency "coveralls", '~> 0.7'
28
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rdecorator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jason Hou
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-02-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.7'
69
+ description: Python like decorator in ruby
70
+ email:
71
+ - hjj1992@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".coveralls.yml"
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - Gemfile
81
+ - LICENSE
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - lib/rdecorator.rb
87
+ - lib/rdecorator/version.rb
88
+ - rdecorator.gemspec
89
+ homepage: http://github.com/falm/rdecorator
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.6.8
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: The decorator design pattern for ruby
113
+ test_files: []