tuxedo_decorate 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile +1 -0
- data/README.md +6 -3
- data/lib/tuxedo/version.rb +1 -1
- data/lib/tuxedo.rb +1 -2
- data/spec/benchmarks/tuxedo_vs_simpledelegator.rb +44 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17ba5db3f56262006be9c6714471023d40461507
|
4
|
+
data.tar.gz: 8498c3544d4f423dca7cb43095caf2c9f06c305d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 055e6519ee3e865a432324ca23e1a2c9edc988564ae2fa96c3c08770c8d09bb0dcb0c4010a62f4f6de01038f6c439a5c6127b4f762b08585ef1f2ac1c98e65db
|
7
|
+
data.tar.gz: ce393d9548283440656c317e97b0e68337090a07547912b2f9f0a92d4f0d6b746b38f20a985fe4f7128291ab2fc37556b6a4723020f707eb79a94f4e51357951
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
## Unreleased
|
3
3
|
- Add your entry here!
|
4
4
|
|
5
|
+
## v0.4.0
|
6
|
+
- Fixes #3: Using `alias_method` instead of `define_method` to improve performance
|
7
|
+
|
5
8
|
## v0.3.0
|
6
9
|
- The born of the changelog
|
7
10
|
- Refactored Tuxedo to not use `AS::Concern`, this allows to support rails 4.0 and up.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Tuxedo Decorate
|
2
2
|
[![Build Status](https://travis-ci.org/playpasshq/tuxedo.svg)](https://travis-ci.org/playpasshq/tuxedo)
|
3
3
|
[![Code Climate](https://codeclimate.com/github/playpasshq/tuxedo/badges/gpa.svg)](https://codeclimate.com/github/playpasshq/tuxedo)
|
4
|
+
[![Test Coverage](https://codeclimate.com/github/playpasshq/tuxedo/badges/coverage.svg)](https://codeclimate.com/github/playpasshq/tuxedo/coverage)
|
4
5
|
[![Inline docs](http://inch-ci.org/github/playpasshq/tuxedo.png)](http://inch-ci.org/github/playpasshq/tuxedo)
|
5
6
|
[![Gem Version](https://badge.fury.io/rb/tuxedo_decorate.svg)](https://badge.fury.io/rb/tuxedo_decorate)
|
6
7
|
|
@@ -216,9 +217,11 @@ After checking out the repo, run `bin/setup` to install dependencies. You can al
|
|
216
217
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
217
218
|
|
218
219
|
## Contributing
|
219
|
-
|
220
|
-
|
221
|
-
|
220
|
+
1. Fork it
|
221
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
222
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
223
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
224
|
+
5. Create new Pull Request
|
222
225
|
|
223
226
|
## License
|
224
227
|
|
data/lib/tuxedo/version.rb
CHANGED
data/lib/tuxedo.rb
CHANGED
@@ -79,10 +79,9 @@ module Tuxedo
|
|
79
79
|
|
80
80
|
# @api private
|
81
81
|
# This setup (after initialize) a new method for accessing the original object
|
82
|
-
# alias_method wont work well with inheritance/includes/extends
|
83
82
|
#
|
84
83
|
def setup_alias_method(name = underscored_name)
|
85
|
-
|
84
|
+
alias_method(name, :object)
|
86
85
|
end
|
87
86
|
end
|
88
87
|
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'benchmark/ips'
|
2
|
+
require 'tuxedo'
|
3
|
+
|
4
|
+
class Country
|
5
|
+
attr_accessor :name, :id
|
6
|
+
end
|
7
|
+
|
8
|
+
class CountryDecorator < SimpleDelegator
|
9
|
+
def fancy_name
|
10
|
+
"fancy" + __getobj__.name
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class CountryPresenter
|
15
|
+
include Tuxedo
|
16
|
+
|
17
|
+
def fancy_name
|
18
|
+
"fancy" + object.name
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class CharlatanProxy
|
23
|
+
include Charlatan.new(:country)
|
24
|
+
def fancy_name
|
25
|
+
"fancy" + country.name
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
country = Country.new
|
30
|
+
country.name = "Tuxedo"
|
31
|
+
country.id = 111
|
32
|
+
|
33
|
+
tuxedo = CountryPresenter.new(country, nil)
|
34
|
+
simple_delegator = CountryDecorator.new(country)
|
35
|
+
charlatan = CharlatanProxy.new(country)
|
36
|
+
|
37
|
+
Benchmark.ips do |x|
|
38
|
+
x.report("simpleDelegator") { simple_delegator.fancy_name }
|
39
|
+
x.report("tuxedo") { tuxedo.fancy_name }
|
40
|
+
x.report("charlatan") { charlatan.fancy_name }
|
41
|
+
|
42
|
+
# Compare the iterations per second of the various reports!
|
43
|
+
x.compare!
|
44
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tuxedo_decorate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Stevens
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-01-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- lib/tuxedo/config.rb
|
85
85
|
- lib/tuxedo/railtie.rb
|
86
86
|
- lib/tuxedo/version.rb
|
87
|
+
- spec/benchmarks/tuxedo_vs_simpledelegator.rb
|
87
88
|
- spec/config_spec.rb
|
88
89
|
- spec/helpers/helpers_spec.rb
|
89
90
|
- spec/spec_helper.rb
|
@@ -112,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
113
|
version: '0'
|
113
114
|
requirements: []
|
114
115
|
rubyforge_project:
|
115
|
-
rubygems_version: 2.
|
116
|
+
rubygems_version: 2.5.1
|
116
117
|
signing_key:
|
117
118
|
specification_version: 4
|
118
119
|
summary: Tuxedo simple presenter logic under 150 LOC
|