dekorator 1.2.0 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3da5195ec703cf974bb139df0433fec47aa1b5a61a905aa807868f52e0d48a88
4
- data.tar.gz: 7cbcc777caf8dba2c9d205abcd009979be7d9f1a537fba9e7a0358f06c82e502
3
+ metadata.gz: 65b1b1e3eab54d74eb9ac8a975bd21b685cebe43ad26e96c39695731176de03d
4
+ data.tar.gz: 89311b6a6b7c9319994c85e62bee7a58034bd97c3598b30fb3026304f8e317f5
5
5
  SHA512:
6
- metadata.gz: 885470910d0a93c41f21c12d8c367e12d7d216955b9d838a9a5c58cf3bba144025229c33e88f9d956e0daeed3edd901802204b745e49c6620e989a25940eb0f6
7
- data.tar.gz: 3f2e77e1608d254cd92faaadc70ac378859d5094c37e2de573836329217579e38dac4d0b75a252a346a2830655b8d276b644719b8cd0d72f6fd82749f7535756
6
+ metadata.gz: bb081f14a84f51bec57c5a6625cdfed0cffc48d0a8c88a83ab40a828a5a0e5bab4eba62710bd82a22a42e56c0601332da250d8f2c61f2d8af87be2d948fa674d
7
+ data.tar.gz: c7aa2f27e8e85ed0b2d4c615967478a8fe795e9f30be92378c1b6ab29a63c4576c55ef1555f081014e819734e43041a80416a82c5e5386fc666ffc4f7d9bcb36
data/CHANGELOG.md CHANGED
@@ -8,6 +8,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
  ## [Unreleased]
9
9
  Nothing yet
10
10
 
11
+ ## [1.3.0] - 2023-11-06
12
+ ### Added
13
+ - Add Rails 7.1 support ([#49](https://github.com/komposable/dekorator/pull/49))
14
+ ### Removed
15
+ - Add Rails 7.0 on CI tests via Appraisals ([#47](https://github.com/komposable/dekorator/pull/47))
16
+ - Drop Ruby 2.5 and 2.6 support ([#47](https://github.com/komposable/dekorator/pull/47))
17
+ - Remove Coveralls usage ([#47](https://github.com/komposable/dekorator/pull/47))
18
+
19
+ ## [1.2.1] - 2021-10-14
20
+ - Make decorated `Enumerable` not lazy anymore ([#46](https://github.com/komposable/dekorator/pull/46))
21
+
11
22
  ## [1.2.0] - 2021-10-14
12
23
  ### Added
13
24
  - Add Rails 7.0 support ([#43](https://github.com/komposable/dekorator/pull/43))
@@ -46,7 +57,9 @@ Nothing yet
46
57
  - Create `dekorator:install` generator ([a2a36d66](https://github.com/komposable/dekorator/commit/a2a36d66c6de6cb0a00f783794cd29f899bc04b6))
47
58
  - Create `decorator` generator ([a2a36d66](https://github.com/komposable/dekorator/commit/a2a36d66c6de6cb0a00f783794cd29f899bc04b6))
48
59
 
49
- [Unreleased]: https://github.com/komposable/dekorator/compare/v1.2.0...master
60
+ [Unreleased]: https://github.com/komposable/dekorator/compare/v1.3.0...main
61
+ [1.3.0]: https://github.com/komposable/dekorator/compare/v1.2.1...v1.3.0
62
+ [1.2.1]: https://github.com/komposable/dekorator/compare/v1.2.0...v1.2.1
50
63
  [1.2.0]: https://github.com/komposable/dekorator/compare/v1.1.0...v1.2.0
51
64
  [1.1.0]: https://github.com/komposable/dekorator/compare/v1.0.0...v1.1.0
52
65
  [1.0.0]: https://github.com/komposable/dekorator/compare/v1.0.0.pre.1...v1.0.0
data/README.md CHANGED
@@ -3,9 +3,8 @@
3
3
  [![Tests](https://github.com/komposable/dekorator/workflows/Tests/badge.svg)](https://github.com/komposable/dekorator/actions)
4
4
  [![Gem Version](https://badge.fury.io/rb/dekorator.svg)](https://rubygems.org/gems/dekorator)
5
5
  [![Maintainability](https://api.codeclimate.com/v1/badges/f7ab08512ead00da34c0/maintainability)](https://codeclimate.com/github/komposable/dekorator/maintainability)
6
- [![Coverage Status](https://coveralls.io/repos/github/komposable/dekorator/badge.svg)](https://coveralls.io/github/komposable/dekorator)
7
- [![Inch CI](https://inch-ci.org/github/komposable/dekorator.svg?branch=master)](https://inch-ci.org/github/komposable/dekorator)
8
- [![Yardoc](https://img.shields.io/badge/doc-yardoc-blue.svg)](https://www.rubydoc.info/github/komposable/dekorator/master)
6
+ [![Inch CI](https://inch-ci.org/github/komposable/dekorator.svg?branch=main)](https://inch-ci.org/github/komposable/dekorator)
7
+ [![Yardoc](https://img.shields.io/badge/doc-yardoc-blue.svg)](https://www.rubydoc.info/github/komposable/dekorator/main)
9
8
 
10
9
  **Dekorator** is a lightweight library to implement _presenters_ and/or _decorators_ in your Rails app. It has less features than [`draper`](https://github.com/drapergem/draper) and aims at having a lower memory footprint.
11
10
 
@@ -13,8 +12,8 @@ This gem has been inspired by our Rails development practices at [Pantographe](h
13
12
 
14
13
  ## Compatibility
15
14
 
16
- * Ruby 2.5+
17
- * Rails 5.2+
15
+ * Ruby 2.7+
16
+ * Rails 6.0+
18
17
 
19
18
  ## Installation
20
19
 
@@ -47,13 +46,13 @@ This command will generate the following file:
47
46
  ```ruby
48
47
  class UserDecorator < ApplicationDecorator
49
48
  include ActionView::Helpers::TextHelper
50
-
49
+
51
50
  decorates_association :posts
52
-
51
+
53
52
  def full_name
54
53
  [first_name, last_name].join(" ")
55
54
  end
56
-
55
+
57
56
  def biography_summary
58
57
  truncate(biography, length: 170)
59
58
  end
@@ -119,7 +118,7 @@ decorated_user.posts.first # => PostDecorator
119
118
 
120
119
  ### Custom decorator
121
120
 
122
- By default, Dekorator searches for the decorator class by adding `Decorator` at the end.
121
+ By default, Dekorator searches for the decorator class by adding `Decorator` at the end.
123
122
  For `User`, Dekorator looks for the `UserDecorator` class, and for `User::Profile`
124
123
  it looks for `User::ProfileDecorator`.
125
124
 
@@ -156,7 +155,7 @@ decorated_user.posts.first # => ArticleDecorator
156
155
 
157
156
  ### ActiveAdmin
158
157
 
159
- This gem is compatible with [`activeadmin`][activeadmin] ([2.8+](https://github.com/activeadmin/activeadmin/pull/6249)).
158
+ This gem is compatible with [`activeadmin`][activeadmin] ([2.8+](https://github.com/activeadmin/activeadmin/pull/6249)).
160
159
  For `activeadmin` before `2.8`, use `dekorator` `1.0.*`.
161
160
 
162
161
  Simply use `#decorate_with`
@@ -243,4 +242,4 @@ chat rooms and mailing lists is expected to follow the [code of conduct].
243
242
  [devise]: https://github.com/plataformatec/devise/
244
243
  [rubygems.org]: https://rubygems.org
245
244
  [MIT License]: https://opensource.org/licenses/MIT
246
- [code of conduct]: https://github.com/komposable/dekorator/blob/master/CODE_OF_CONDUCT.md
245
+ [code of conduct]: https://github.com/komposable/dekorator/blob/main/CODE_OF_CONDUCT.md
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dekorator
4
- VERSION = "1.2.0".freeze
4
+ VERSION = "1.3.0".freeze
5
5
  end
data/lib/dekorator.rb CHANGED
@@ -73,7 +73,7 @@ module Dekorator
73
73
  with = _guess_decorator(object_or_enumerable) if with.nil? || with == :__guess__
74
74
 
75
75
  if object_or_enumerable.is_a? Enumerable
76
- object_or_enumerable.lazy.map { |object| _decorate(object, with: with) }
76
+ object_or_enumerable.map { |object| _decorate(object, with: with) }
77
77
  else
78
78
  with.new(object_or_enumerable)
79
79
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dekorator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pantographe
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-14 00:00:00.000000000 Z
11
+ date: 2023-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -16,122 +16,60 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.2'
19
+ version: '6.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '7.1'
22
+ version: '7.2'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '5.2'
29
+ version: '6.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '7.1'
32
+ version: '7.2'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: activerecord
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '5.2'
39
+ version: '6.0'
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: '7.1'
42
+ version: '7.2'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: '5.2'
49
+ version: '6.0'
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: '7.1'
52
+ version: '7.2'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: activesupport
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: '5.2'
59
+ version: '6.0'
60
60
  - - "<"
61
61
  - !ruby/object:Gem::Version
62
- version: '7.1'
62
+ version: '7.2'
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: '5.2'
69
+ version: '6.0'
70
70
  - - "<"
71
71
  - !ruby/object:Gem::Version
72
- version: '7.1'
73
- - !ruby/object:Gem::Dependency
74
- name: railties
75
- requirement: !ruby/object:Gem::Requirement
76
- requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- version: '5.2'
80
- - - "<"
81
- - !ruby/object:Gem::Version
82
- version: '7.1'
83
- type: :runtime
84
- prerelease: false
85
- version_requirements: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '5.2'
90
- - - "<"
91
- - !ruby/object:Gem::Version
92
- version: '7.1'
93
- - !ruby/object:Gem::Dependency
94
- name: bundler
95
- requirement: !ruby/object:Gem::Requirement
96
- requirements:
97
- - - "~>"
98
- - !ruby/object:Gem::Version
99
- version: '2.0'
100
- type: :development
101
- prerelease: false
102
- version_requirements: !ruby/object:Gem::Requirement
103
- requirements:
104
- - - "~>"
105
- - !ruby/object:Gem::Version
106
- version: '2.0'
107
- - !ruby/object:Gem::Dependency
108
- name: rake
109
- requirement: !ruby/object:Gem::Requirement
110
- requirements:
111
- - - ">="
112
- - !ruby/object:Gem::Version
113
- version: 12.3.3
114
- type: :development
115
- prerelease: false
116
- version_requirements: !ruby/object:Gem::Requirement
117
- requirements:
118
- - - ">="
119
- - !ruby/object:Gem::Version
120
- version: 12.3.3
121
- - !ruby/object:Gem::Dependency
122
- name: rspec
123
- requirement: !ruby/object:Gem::Requirement
124
- requirements:
125
- - - "~>"
126
- - !ruby/object:Gem::Version
127
- version: '3.0'
128
- type: :development
129
- prerelease: false
130
- version_requirements: !ruby/object:Gem::Requirement
131
- requirements:
132
- - - "~>"
133
- - !ruby/object:Gem::Version
134
- version: '3.0'
72
+ version: '7.2'
135
73
  description: An opinionated way of organizing model-view code in Ruby on Rails, based
136
74
  on decorators
137
75
  email:
@@ -140,16 +78,9 @@ executables: []
140
78
  extensions: []
141
79
  extra_rdoc_files: []
142
80
  files:
143
- - ".codeclimate.yml"
144
- - ".github/workflows/test.yml"
145
81
  - CHANGELOG.md
146
- - CODE_OF_CONDUCT.md
147
82
  - LICENSE.txt
148
83
  - README.md
149
- - Rakefile
150
- - benchmarks/README.md
151
- - benchmarks/benchmark.rb
152
- - dekorator.gemspec
153
84
  - lib/dekorator.rb
154
85
  - lib/dekorator/rails/controller.rb
155
86
  - lib/dekorator/rails/tasks/dekorator.rake
@@ -164,15 +95,16 @@ files:
164
95
  - lib/generators/rspec/templates/decorator_spec.rb
165
96
  - lib/generators/test_unit/decorator_generator.rb
166
97
  - lib/generators/test_unit/templates/decorator_test.rb
167
- homepage: http://komponent.io
98
+ homepage: https://github.com/komposable/dekorator
168
99
  licenses:
169
100
  - MIT
170
101
  metadata:
171
102
  homepage_uri: https://github.com/komposable/dekorator
172
- changelog_uri: https://github.com/komposable/dekorator/blob/master/CHANGELOG.md
103
+ changelog_uri: https://github.com/komposable/dekorator/blob/main/CHANGELOG.md
173
104
  source_code_uri: https://github.com/komposable/dekorator
174
105
  bug_tracker_uri: https://github.com/komposable/dekorator/issues
175
- post_install_message:
106
+ rubygems_mfa_required: 'true'
107
+ post_install_message:
176
108
  rdoc_options: []
177
109
  require_paths:
178
110
  - lib
@@ -180,15 +112,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
180
112
  requirements:
181
113
  - - ">="
182
114
  - !ruby/object:Gem::Version
183
- version: '2.3'
115
+ version: 2.7.0
184
116
  required_rubygems_version: !ruby/object:Gem::Requirement
185
117
  requirements:
186
118
  - - ">="
187
119
  - !ruby/object:Gem::Version
188
120
  version: '0'
189
121
  requirements: []
190
- rubygems_version: 3.2.9
191
- signing_key:
122
+ rubygems_version: 3.4.21
123
+ signing_key:
192
124
  specification_version: 4
193
125
  summary: An opinionated way of organizing model-view code in Ruby on Rails, based
194
126
  on decorators
data/.codeclimate.yml DELETED
@@ -1,4 +0,0 @@
1
- exclude_patterns:
2
- - "benchmarks/**/*"
3
- - "lib/generators/**/*"
4
- - "spec/**/*"
@@ -1,40 +0,0 @@
1
- name: Tests
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- test:
7
- name: Ruby ${{ matrix.versions.ruby }}, Rails ${{ matrix.versions.rails }}
8
- runs-on: ubuntu-latest
9
- strategy:
10
- matrix:
11
- versions:
12
- - { ruby: "2.5", rails: "5.2.x" }
13
- - { ruby: "2.6", rails: "5.2.x" }
14
- - { ruby: "2.7", rails: "5.2.x" }
15
- - { ruby: "2.5", rails: "6.0.x" }
16
- - { ruby: "2.6", rails: "6.0.x" }
17
- - { ruby: "2.7", rails: "6.0.x" }
18
- - { ruby: "3.0", rails: "6.0.x" }
19
- - { ruby: "2.5", rails: "6.1.x" }
20
- - { ruby: "2.6", rails: "6.1.x" }
21
- - { ruby: "2.7", rails: "6.1.x" }
22
- - { ruby: "3.0", rails: "6.1.x" }
23
- - { ruby: "2.7", rails: "head" }
24
- - { ruby: "3.0", rails: "head" }
25
-
26
-
27
- env:
28
- BUNDLE_GEMFILE: gemfiles/rails_${{ matrix.versions.rails }}.gemfile
29
- steps:
30
- - uses: actions/checkout@v2
31
-
32
- - name: Set up Ruby
33
- uses: ruby/setup-ruby@v1
34
- with:
35
- ruby-version: ${{ matrix.versions.ruby }}
36
- bundler-cache: true
37
-
38
- - name: Test with Rake
39
- run: |
40
- bundle exec rake test:all_with_coverage
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at oss@pantographe.studio. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
data/Rakefile DELETED
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rubocop/rake_task"
5
- require "rspec/core/rake_task"
6
- require "coveralls/rake/task"
7
-
8
- namespace :test do
9
- task all: %i[rubocop spec]
10
- task all_with_coverage: %i[all coveralls:push]
11
-
12
- RuboCop::RakeTask.new
13
-
14
- RSpec::Core::RakeTask.new(:spec)
15
-
16
- Coveralls::RakeTask.new
17
- end
18
-
19
- task test: :"test:all"
20
-
21
- task default: :test
data/benchmarks/README.md DELETED
@@ -1,7 +0,0 @@
1
- # Benchmarks
2
-
3
- ## Run benchmarks
4
-
5
- ```sh
6
- $ ruby benchmark.rb
7
- ```
@@ -1,135 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/inline"
4
-
5
- gemfile(true) do
6
- source "https://rubygems.org"
7
-
8
- git_source(:github) { |repo| "https://github.com/#{repo}.git" }
9
-
10
- gem "rails", "6.0.1"
11
- gem "sqlite3"
12
- gem "benchmark-ips"
13
- gem "benchmark-memory"
14
-
15
- gem "dekorator", path: "../", require: false
16
- gem "draper", require: false
17
- end
18
-
19
- require "active_record"
20
- require "logger"
21
-
22
- ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
23
- ActiveRecord::Base.logger = nil # Logger.new(STDOUT)
24
-
25
- ActiveRecord::Schema.define do
26
- create_table :posts, force: true do |t|
27
- t.string :title
28
- t.text :body
29
- end
30
-
31
- create_table :comments, force: true do |t|
32
- t.integer :post_id
33
- t.string :author
34
- t.text :body
35
- end
36
- end
37
-
38
- # Models
39
- class Post < ActiveRecord::Base
40
- has_many :comments
41
-
42
- def summary
43
- @summary ||= body&.truncate(170)
44
- end
45
- end
46
-
47
- class Comment < ActiveRecord::Base
48
- belongs_to :post
49
- end
50
-
51
- # Data
52
- comments = 100.times.map { Comment.new(author: "John D.", body: "Great article") }
53
- 10.times.each { Post.create!(title: "Our first article!", body: "", comments: comments) }
54
-
55
- # Decorators
56
- require "dekorator"
57
-
58
- class PostDecorator < Dekorator::Base
59
- decorates_association :comments
60
-
61
- def summary
62
- @summary ||= body&.truncate(170)
63
- end
64
- end
65
-
66
- class CommentDecorator < Dekorator::Base
67
- end
68
-
69
- require "draper"
70
-
71
- class CommentDraperDecorator < Draper::Decorator
72
- end
73
-
74
- class PostDraperDecorator < Draper::Decorator
75
- decorates_association :comments, with: CommentDraperDecorator
76
-
77
- def summary
78
- @summary ||= object.body&.truncate(170)
79
- end
80
- end
81
-
82
- require "delegate"
83
-
84
- class PostDelegator < SimpleDelegator
85
- def summary
86
- @summary ||= body&.truncate(170)
87
- end
88
-
89
- def comments
90
- @comments = __getobj__.comments.map { |comment| CommentDelegator.new(CommentDelegator) }
91
- end
92
- end
93
-
94
- class CommentDelegator < SimpleDelegator
95
- end
96
-
97
- # Benchmark
98
- SCENARIOS = {
99
- "#summary" => :summary,
100
- "#comments" => :comments,
101
- }
102
-
103
- SCENARIOS.each_pair do |name, method|
104
- puts
105
- puts " #{name} ".center(80, "=")
106
- puts
107
-
108
- model = Post.all
109
-
110
- puts " ips ".center(80, "-")
111
- puts
112
-
113
- Benchmark.ips do |x|
114
- x.report("In model") { model.first.public_send(method) }
115
- x.report("Dekorator") { PostDecorator.decorate(model).first.public_send(method) }
116
- x.report("Dekorator.new") { PostDecorator.decorate(model).first.public_send(method) }
117
- x.report("Draper") { PostDraperDecorator.decorate_collection(model).first.public_send(method) }
118
- x.report("SimpleDelegator") { PostDelegator.new(model.first).public_send(method) }
119
-
120
- x.compare!
121
- end
122
-
123
- puts " memory ".center(80, "-")
124
- puts
125
-
126
- Benchmark.memory do |x|
127
- x.report("In model") { model.first.public_send(method) }
128
- x.report("Dekorator") { PostDecorator.decorate(model).first.public_send(method) }
129
- x.report("Dekorator.new") { PostDecorator.decorate(model).first.public_send(method) }
130
- x.report("Draper") { PostDraperDecorator.decorate_collection(model).first.public_send(method) }
131
- x.report("SimpleDelegator") { PostDelegator.new(model.first).public_send(method) }
132
-
133
- x.compare!
134
- end
135
- end
data/dekorator.gemspec DELETED
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path("lib", __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require "dekorator/version"
6
-
7
- Gem::Specification.new do |spec|
8
- spec.name = "dekorator"
9
- spec.version = Dekorator::VERSION
10
- spec.authors = ["Pantographe"]
11
- spec.email = ["oss@pantographe.studio"]
12
-
13
- spec.summary = "An opinionated way of organizing model-view code in Ruby on Rails, based on decorators"
14
- spec.description = "An opinionated way of organizing model-view code in Ruby on Rails, based on decorators"
15
- spec.homepage = "http://komponent.io"
16
- spec.license = "MIT"
17
-
18
- spec.metadata = {
19
- "homepage_uri" => "https://github.com/komposable/dekorator",
20
- "changelog_uri" => "https://github.com/komposable/dekorator/blob/master/CHANGELOG.md",
21
- "source_code_uri" => "https://github.com/komposable/dekorator",
22
- "bug_tracker_uri" => "https://github.com/komposable/dekorator/issues",
23
- }
24
-
25
- # Specify which files should be added to the gem when it is released.
26
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
28
- `git ls-files -z`.split("\x0")
29
- .reject do |f|
30
- f.match(%r{^(test|spec|features|gemfiles|bin)/}) \
31
- || %w[.editorconfig .gitignore .inch.yml .rspec .rubocop.yml .simplecov .travis.yml
32
- .yardots Appraisals Gemfile Gemfile.lock].include?(f)
33
- end
34
- end
35
-
36
- spec.require_paths = ["lib"]
37
-
38
- spec.required_ruby_version = ">= 2.3"
39
-
40
- spec.add_runtime_dependency "actionview", ">= 5.2", "< 7.1"
41
- spec.add_runtime_dependency "activerecord", ">= 5.2", "< 7.1"
42
- spec.add_runtime_dependency "activesupport", ">= 5.2", "< 7.1"
43
- spec.add_runtime_dependency "railties", ">= 5.2", "< 7.1"
44
-
45
- spec.add_development_dependency "bundler", "~> 2.0"
46
- spec.add_development_dependency "rake", ">= 12.3.3"
47
- spec.add_development_dependency "rspec", "~> 3.0"
48
- end