active_decorator 1.4.1 → 1.5.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 +4 -4
- data/.github/workflows/main.yml +48 -5
- data/CHANGELOG.md +8 -1
- data/Gemfile +11 -2
- data/README.md +3 -3
- data/lib/active_decorator/helpers.rb +6 -2
- data/lib/active_decorator/version.rb +1 -1
- data/lib/active_decorator/view_context.rb +30 -5
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24bc5e2bff457e42cf67f9382718c8317b4b208ded7f64d008d4314bd3e58dd0
|
4
|
+
data.tar.gz: c06a655a2d778a46a5b57559b7dc9091960130846b9f4a28f526715a5b7c652f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7535ee72c44901d579416091437f2ffe78ded2dc535a1e442412f7257004d6bb42f2eff340e31fb563a3fd3bdfa6002dc85d81c0ef4dfd32cefddd4d7b046e63
|
7
|
+
data.tar.gz: c6e02769eff8fcd3e53d0e1456554639038d39377d970aba27310cf1c971c0913785c2f2b1a0e4a9e0de3fe3e34d0d4540ff661b44ead9a242321e30e0195dde
|
data/.github/workflows/main.yml
CHANGED
@@ -11,11 +11,42 @@ jobs:
|
|
11
11
|
name: Ruby ${{ matrix.ruby_version }} / Rails ${{ matrix.rails_version }}${{ matrix.api == '1' && ' / API' || '' }}
|
12
12
|
strategy:
|
13
13
|
matrix:
|
14
|
-
ruby_version: [ruby-head, '3.
|
15
|
-
rails_version: [edge, '7.0', '6.1']
|
14
|
+
ruby_version: [ruby-head, '3.4', '3.3', '3.2', '3.1']
|
15
|
+
rails_version: [edge, '8.0', '7.2', '7.1', '7.0', '6.1']
|
16
16
|
api: ['0', '1']
|
17
17
|
|
18
18
|
include:
|
19
|
+
- ruby_version: '3.0'
|
20
|
+
rails_version: '7.1'
|
21
|
+
- ruby_version: '3.0'
|
22
|
+
rails_version: '7.1'
|
23
|
+
api: '1'
|
24
|
+
- ruby_version: '3.0'
|
25
|
+
rails_version: '7.0'
|
26
|
+
- ruby_version: '3.0'
|
27
|
+
rails_version: '7.0'
|
28
|
+
api: '1'
|
29
|
+
- ruby_version: '3.0'
|
30
|
+
rails_version: '6.1'
|
31
|
+
- ruby_version: '3.0'
|
32
|
+
rails_version: '6.1'
|
33
|
+
api: '1'
|
34
|
+
|
35
|
+
- ruby_version: '2.7'
|
36
|
+
rails_version: '7.1'
|
37
|
+
- ruby_version: '2.7'
|
38
|
+
rails_version: '7.1'
|
39
|
+
api: '1'
|
40
|
+
- ruby_version: '2.7'
|
41
|
+
rails_version: '7.0'
|
42
|
+
- ruby_version: '2.7'
|
43
|
+
rails_version: '7.0'
|
44
|
+
api: '1'
|
45
|
+
- ruby_version: '2.7'
|
46
|
+
rails_version: '6.1'
|
47
|
+
- ruby_version: '2.7'
|
48
|
+
rails_version: '6.1'
|
49
|
+
api: '1'
|
19
50
|
- ruby_version: '2.7'
|
20
51
|
rails_version: '6.0'
|
21
52
|
- ruby_version: '2.7'
|
@@ -67,19 +98,31 @@ jobs:
|
|
67
98
|
rails_version: '4.2'
|
68
99
|
bundler_version: '1'
|
69
100
|
|
101
|
+
exclude:
|
102
|
+
- ruby_version: '3.1'
|
103
|
+
rails_version: edge
|
104
|
+
- ruby_version: '3.1'
|
105
|
+
rails_version: edge
|
106
|
+
api: '1'
|
107
|
+
- ruby_version: '3.1'
|
108
|
+
rails_version: '8.0'
|
109
|
+
- ruby_version: '3.1'
|
110
|
+
rails_version: '8.0'
|
111
|
+
api: '1'
|
112
|
+
|
70
113
|
env:
|
71
114
|
RAILS_VERSION: ${{ matrix.rails_version }}
|
72
115
|
API: ${{ matrix.api }}
|
73
116
|
|
74
|
-
runs-on: ubuntu-
|
117
|
+
runs-on: ubuntu-24.04
|
75
118
|
|
76
119
|
steps:
|
77
|
-
- uses: actions/checkout@
|
120
|
+
- uses: actions/checkout@v5
|
78
121
|
|
79
122
|
- uses: ruby/setup-ruby@v1
|
80
123
|
with:
|
81
124
|
ruby-version: ${{ matrix.ruby_version }}
|
82
|
-
rubygems: ${{ matrix.ruby_version < '2.
|
125
|
+
rubygems: ${{ (matrix.ruby_version < '2.7' && 'default') || (matrix.ruby_version < '3' && '3.4.22') || 'latest' }}
|
83
126
|
bundler: ${{ matrix.bundler_version }}
|
84
127
|
bundler-cache: true
|
85
128
|
continue-on-error: ${{ matrix.allow_failures == 'true' }}
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
+
## 1.5.0
|
2
|
+
|
3
|
+
* Don't drop keyword arguments when delegating helper methods via method_missing
|
4
|
+
|
5
|
+
* Use ActiveSupport::CurrentAttributes (if available) for storing ViewContext instead of `Thread.current` for better thread safety
|
6
|
+
|
7
|
+
|
1
8
|
## 1.4.1
|
2
9
|
|
3
|
-
* Support Ruby 3.2 by `File.exists?` => `File.
|
10
|
+
* Support Ruby 3.2 by `File.exists?` => `File.exist?` in generator [@kyoshidajp]
|
4
11
|
|
5
12
|
* A little bit of internal code cleanup
|
6
13
|
|
data/Gemfile
CHANGED
@@ -9,7 +9,11 @@ if ENV['RAILS_VERSION'] == 'edge'
|
|
9
9
|
gem 'rackup'
|
10
10
|
elsif ENV['RAILS_VERSION']
|
11
11
|
gem 'rails', "~> #{ENV['RAILS_VERSION']}.0"
|
12
|
-
|
12
|
+
if ENV['RAILS_VERSION'] <= '5.0'
|
13
|
+
gem 'sqlite3', '< 1.4'
|
14
|
+
elsif (ENV['RAILS_VERSION'] <= '8') || (RUBY_VERSION < '3')
|
15
|
+
gem 'sqlite3', '< 2'
|
16
|
+
end
|
13
17
|
gem 'rackup' if ENV['RAILS_VERSION'] > '7.1'
|
14
18
|
else
|
15
19
|
gem 'rails'
|
@@ -25,6 +29,11 @@ gem 'nokogiri', RUBY_VERSION < '2.1' ? '~> 1.6.0' : '>= 1.7'
|
|
25
29
|
gem 'loofah', RUBY_VERSION < '2.5' ? '< 2.21.0' : '>= 0'
|
26
30
|
gem 'concurrent-ruby', RUBY_VERSION < '2.3' ? '~> 1.1.0' : '>= 1.2'
|
27
31
|
gem 'selenium-webdriver', RUBY_VERSION == '3.0' ? '4.9.0' : '>= 0'
|
28
|
-
gem 'webdrivers' if ENV['RAILS_VERSION'] && ENV['RAILS_VERSION'] >= '6'
|
32
|
+
gem 'webdrivers' if (ENV['RAILS_VERSION'] && ENV['RAILS_VERSION'] >= '6') && (RUBY_VERSION < '3')
|
29
33
|
gem 'net-smtp' if RUBY_VERSION >= '3.1'
|
30
34
|
gem 'jbuilder' unless ENV['API'] == '1'
|
35
|
+
gem 'mutex_m' if RUBY_VERSION >= '3.4'
|
36
|
+
gem 'base64' if RUBY_VERSION >= '3.4'
|
37
|
+
gem 'bigdecimal' if RUBY_VERSION >= '3.4'
|
38
|
+
gem 'logger' if RUBY_VERSION >= '3.5'
|
39
|
+
gem 'benchmark' if RUBY_VERSION >= '3.5'
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# ActiveDecorator [](https://github.com/amatsuda/active_decorator/actions) [](https://codeclimate.com/github/amatsuda/active_decorator)
|
2
2
|
|
3
|
-
A simple and Rubyish view helper for Rails 4, Rails 5, Rails 6, and Rails
|
3
|
+
A simple and Rubyish view helper for Rails 4, Rails 5, Rails 6, Rails 7, and Rails 8. Keep your helpers and views Object-Oriented!
|
4
4
|
|
5
5
|
|
6
6
|
## Features ##
|
@@ -15,9 +15,9 @@ A simple and Rubyish view helper for Rails 4, Rails 5, Rails 6, and Rails 7. Kee
|
|
15
15
|
|
16
16
|
## Supported versions ##
|
17
17
|
|
18
|
-
* Ruby 2.1.x, 2.2.x, 2.3.x, 2.4.x, 2.5.x, 2.6.x, 2.7.x, 3.0.x, 3.1.x, 3.2.x, and 3.
|
18
|
+
* Ruby 2.1.x, 2.2.x, 2.3.x, 2.4.x, 2.5.x, 2.6.x, 2.7.x, 3.0.x, 3.1.x, 3.2.x, 3.3.x, 3.4.x, and 3.5 (trunk)
|
19
19
|
|
20
|
-
* Rails 4.2.x, 5.0, 5.1, 5.2, 6.0, 6.1, 7.0,
|
20
|
+
* Rails 4.2.x, 5.0, 5.1, 5.2, 6.0, 6.1, 7.0, 7.1, 7.2, 8.0, and 8.1 (edge)
|
21
21
|
|
22
22
|
|
23
23
|
## Supported ORMs ##
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# On the fly delegation from the decorator to the decorated object and the helpers.
|
4
4
|
module ActiveDecorator
|
5
5
|
module Helpers
|
6
|
-
def method_missing(method, *args, &block)
|
6
|
+
def method_missing(method, *args, **kwargs, &block)
|
7
7
|
super
|
8
8
|
rescue NoMethodError, NameError => e1
|
9
9
|
# the error is not mine, so just releases it as is.
|
@@ -11,7 +11,11 @@ module ActiveDecorator
|
|
11
11
|
|
12
12
|
if (view_context = ActiveDecorator::ViewContext.current)
|
13
13
|
begin
|
14
|
-
|
14
|
+
if kwargs.any?
|
15
|
+
view_context.send method, *args, **kwargs, &block
|
16
|
+
else
|
17
|
+
view_context.send method, *args, &block
|
18
|
+
end
|
15
19
|
rescue NoMethodError => e2
|
16
20
|
raise e2 if e2.name != method
|
17
21
|
|
@@ -2,7 +2,36 @@
|
|
2
2
|
|
3
3
|
# A module that carries the controllers' view_context to decorators.
|
4
4
|
module ActiveDecorator
|
5
|
-
|
5
|
+
# Use Rails' CurrentAttributes if available (Rails 5.2+)
|
6
|
+
if defined? ActiveSupport::CurrentAttributes
|
7
|
+
class ViewContext < ActiveSupport::CurrentAttributes
|
8
|
+
# Rails 7.2+
|
9
|
+
if method(:attribute).parameters.include? [:key, :default]
|
10
|
+
attribute :view_context_stack, default: []
|
11
|
+
else
|
12
|
+
attribute :view_context_stack
|
13
|
+
|
14
|
+
def view_context_stack
|
15
|
+
attributes[:view_context_stack] ||= []
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
resets do
|
20
|
+
view_context_stack = nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
else
|
24
|
+
# Fallback implementation for Rails < 5.2
|
25
|
+
class ViewContext
|
26
|
+
class << self
|
27
|
+
def view_context_stack
|
28
|
+
Thread.current[:active_decorator_view_contexts] ||= []
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class ViewContext
|
6
35
|
class << self
|
7
36
|
def current
|
8
37
|
view_context_stack.last
|
@@ -16,10 +45,6 @@ module ActiveDecorator
|
|
16
45
|
view_context_stack.pop
|
17
46
|
end
|
18
47
|
|
19
|
-
def view_context_stack
|
20
|
-
Thread.current[:active_decorator_view_contexts] ||= []
|
21
|
-
end
|
22
|
-
|
23
48
|
def run_with(view_context)
|
24
49
|
push view_context
|
25
50
|
yield
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_decorator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira Matsuda
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: activesupport
|
@@ -163,7 +162,6 @@ homepage: https://github.com/amatsuda/active_decorator
|
|
163
162
|
licenses:
|
164
163
|
- MIT
|
165
164
|
metadata: {}
|
166
|
-
post_install_message:
|
167
165
|
rdoc_options: []
|
168
166
|
require_paths:
|
169
167
|
- lib
|
@@ -178,8 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
176
|
- !ruby/object:Gem::Version
|
179
177
|
version: '0'
|
180
178
|
requirements: []
|
181
|
-
rubygems_version: 3.
|
182
|
-
signing_key:
|
179
|
+
rubygems_version: 3.8.0.dev
|
183
180
|
specification_version: 4
|
184
181
|
summary: A simple and Rubyish view helper for Rails
|
185
182
|
test_files: []
|