page_title_helper 5.0.0 → 6.0.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 +12 -0
- data/lib/page_title_helper/version.rb +1 -1
- data/lib/page_title_helper.rb +29 -11
- data/page_title_helper.gemspec +10 -9
- data/test/multiple_formats_test.rb +3 -2
- data/test/page_title_helper_test.rb +3 -1
- metadata +35 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5526377f52ae74a93d1dd45729c0278258db52f32e5e38e37ec9baed06a33a6d
|
4
|
+
data.tar.gz: bd18c28d5e3f5bfe0b0d2138d305d4af987293088dd7ac3c362db127ef903cbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1fe1095a08095559012b02daceda00de0152bf1f4dd531a719acbdabac958f5a0e2722950119bf0091783c2592a0c90720dbfaaf9f2f98d26e07012b400f347
|
7
|
+
data.tar.gz: 18c030e2df24abbe72cbfbecb39b3ee373b7a4723aeb1b03c3ab2d55a7a27bcec56bc3c4d5618ebc862e202f56369e672ec106af9fbf6039fbec4d26104f1b4a
|
data/CHANGELOG.md
CHANGED
@@ -20,6 +20,18 @@ about why a change log is important.
|
|
20
20
|
|
21
21
|
### Security
|
22
22
|
|
23
|
+
## 6.0.0
|
24
|
+
|
25
|
+
### Added
|
26
|
+
- Add support for Rails 7.0 (#131)
|
27
|
+
- Add support for Ruby 3.1 (#143)
|
28
|
+
|
29
|
+
### Removed
|
30
|
+
- Drop support for Ruby 2.5 and 2.6 (#127, #145)
|
31
|
+
|
32
|
+
### Fixed
|
33
|
+
- Avoid modifying a frozen array in Ruby 3 (#135)
|
34
|
+
|
23
35
|
## 5.0.0
|
24
36
|
|
25
37
|
### Added
|
data/lib/page_title_helper.rb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
# Copyright:: Copyright (c) 2009 Lukas Westermann (Zurich, Switzerland)
|
8
8
|
# Licence:: MIT-Licence (https://www.opensource.org/licenses/mit-license.php)
|
9
9
|
#
|
10
|
-
# See documentation for +page_title+ for usage examples and more
|
10
|
+
# See documentation for +page_title+ for usage examples and more information.
|
11
11
|
require 'active_support'
|
12
12
|
|
13
13
|
# PageTitleHelper
|
@@ -25,7 +25,7 @@ module PageTitleHelper
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def app(env)
|
28
|
-
env[:app] || I18n.
|
28
|
+
env[:app] || I18n.t('app.name', default: File.basename(Rails.root).humanize)
|
29
29
|
end
|
30
30
|
|
31
31
|
def title(env)
|
@@ -69,18 +69,13 @@ module PageTitleHelper
|
|
69
69
|
options[:format] ||= :title # handles :format => false
|
70
70
|
options.assert_valid_keys(:app, :default, :format)
|
71
71
|
|
72
|
-
|
73
|
-
title = @_page_title ||= page_title_from_translation(options[:default])
|
74
|
-
title, options[:format] = *(title << options[:format]) if title.is_a?(Array)
|
72
|
+
format, real_title = build_title_and_format(options)
|
75
73
|
|
76
74
|
# handle format aliases
|
77
|
-
format =
|
78
|
-
if PageTitleHelper.formats.include?(format)
|
79
|
-
format = PageTitleHelper.formats[format]
|
80
|
-
end
|
75
|
+
format = PageTitleHelper.formats[format] if PageTitleHelper.formats.include?(format)
|
81
76
|
|
82
77
|
# construct basic env to pass around
|
83
|
-
env = { title:
|
78
|
+
env = { title: real_title, app: options[:app], options: options, view: self }
|
84
79
|
|
85
80
|
# interpolate format
|
86
81
|
Interpolations.interpolate(format, env)
|
@@ -100,7 +95,30 @@ module PageTitleHelper
|
|
100
95
|
keys << :"#{base}.title"
|
101
96
|
keys << default
|
102
97
|
|
103
|
-
I18n.
|
98
|
+
I18n.t(keys.shift, default: keys)
|
99
|
+
end
|
100
|
+
|
101
|
+
private
|
102
|
+
|
103
|
+
##
|
104
|
+
# Read the page title and splits it into 'real' title and the customized
|
105
|
+
# format.
|
106
|
+
#
|
107
|
+
# @param {Hash} options
|
108
|
+
#
|
109
|
+
# @return {Array}
|
110
|
+
#
|
111
|
+
def build_title_and_format(options)
|
112
|
+
raw_title = @_page_title ||= page_title_from_translation(options[:default])
|
113
|
+
if raw_title.is_a?(Array)
|
114
|
+
title_and_format = raw_title + [options[:format]]
|
115
|
+
real_title, format = *title_and_format
|
116
|
+
else
|
117
|
+
real_title = raw_title
|
118
|
+
format = options[:format]
|
119
|
+
end
|
120
|
+
|
121
|
+
[format, real_title]
|
104
122
|
end
|
105
123
|
end
|
106
124
|
|
data/page_title_helper.gemspec
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
$:.push File.expand_path('../lib', __FILE__)
|
1
|
+
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
3
2
|
require 'page_title_helper/version'
|
4
3
|
|
5
4
|
Gem::Specification.new do |s|
|
@@ -9,22 +8,24 @@ Gem::Specification.new do |s|
|
|
9
8
|
s.summary = 'Simple, internationalized and DRY page titles and headings for Rails.'
|
10
9
|
s.description = 'Simple, internationalized and DRY page titles and headings for Rails.'
|
11
10
|
|
12
|
-
s.required_ruby_version = '>= 2.
|
11
|
+
s.required_ruby_version = '>= 2.7.0'
|
13
12
|
|
14
13
|
s.authors = ['Lukas Westermann']
|
15
14
|
s.email = ['lukas.westermann@gmail.com']
|
16
15
|
s.homepage = 'https://github.com/lwe/page_title_helper'
|
17
16
|
|
18
|
-
s.files = %w
|
17
|
+
s.files = %w[Gemfile LICENSE README.md CODE_OF_CONDUCT.md CHANGELOG.md Rakefile
|
18
|
+
page_title_helper.gemspec] + Dir['**/*.{rb,yml}']
|
19
19
|
s.test_files = s.files.grep(%r{^(test|spec)/})
|
20
20
|
s.require_path = 'lib'
|
21
21
|
|
22
22
|
s.license = 'MIT'
|
23
23
|
|
24
|
-
s.add_dependency 'rails', '>= 5.2.0', '<
|
24
|
+
s.add_dependency 'rails', '>= 5.2.0', '< 7.1'
|
25
25
|
|
26
|
-
s.add_development_dependency 'rake', '
|
27
|
-
s.add_development_dependency '
|
28
|
-
s.add_development_dependency 'rubocop', '~>
|
29
|
-
s.add_development_dependency 'rubocop-
|
26
|
+
s.add_development_dependency 'rake', '~> 13.0.6'
|
27
|
+
s.add_development_dependency 'rubocop', '~> 1.26.1'
|
28
|
+
s.add_development_dependency 'rubocop-rails', '~> 2.14.2'
|
29
|
+
s.add_development_dependency 'rubocop-rake', '~> 0.6.0'
|
30
|
+
s.add_development_dependency 'shoulda', '~> 4.0.0'
|
30
31
|
end
|
@@ -47,7 +47,8 @@ class MultipleFormatsTest < ActiveSupport::TestCase
|
|
47
47
|
|
48
48
|
should 'override locally supplied :format arguments' do
|
49
49
|
assert_equal('Something', @view.page_title { ['Something', '* * * :title * * *'] })
|
50
|
-
|
50
|
+
# yeah, using x-tra ugly titles :)
|
51
|
+
assert_equal '* * * Something * * *', @view.page_title(format: '-= :title =-')
|
51
52
|
end
|
52
53
|
end
|
53
54
|
end
|
@@ -60,7 +61,7 @@ class MultipleFormatsTest < ActiveSupport::TestCase
|
|
60
61
|
@view = TestView.new
|
61
62
|
end
|
62
63
|
|
63
|
-
should 'allow to
|
64
|
+
should 'allow to override format through YAML' do
|
64
65
|
@view.controller! 'pages', 'features'
|
65
66
|
assert_equal 'Wohaapp > Feature comparison', @view.page_title
|
66
67
|
end
|
@@ -32,7 +32,9 @@ class PageTitleHelperTest < ActiveSupport::TestCase
|
|
32
32
|
PageTitleHelper.interpolates(:foobar_test) { |_env| 'foobar_test' }
|
33
33
|
PageTitleHelper.interpolates(:title_foobar) { |_env| 'title_foobar' }
|
34
34
|
|
35
|
-
assert_equal 'title_foobar / foobar_test / foobar / foobar_x',
|
35
|
+
assert_equal 'title_foobar / foobar_test / foobar / foobar_x',
|
36
|
+
PageTitleHelper::Interpolations.interpolate(':title_foobar / :foobar_test / :foobar / :foobar_x',
|
37
|
+
{})
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: page_title_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas Westermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 5.2.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '7.1'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,63 +29,77 @@ dependencies:
|
|
29
29
|
version: 5.2.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '7.1'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rake
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "
|
37
|
+
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
39
|
+
version: 13.0.6
|
40
40
|
type: :development
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- - "
|
44
|
+
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
46
|
+
version: 13.0.6
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
48
|
+
name: rubocop
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- - "
|
51
|
+
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
53
|
+
version: 1.26.1
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- - "
|
58
|
+
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
60
|
+
version: 1.26.1
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
|
-
name: rubocop
|
62
|
+
name: rubocop-rails
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
67
|
+
version: 2.14.2
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
74
|
+
version: 2.14.2
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
|
-
name: rubocop-
|
76
|
+
name: rubocop-rake
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 0.6.0
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 0.6.0
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: shoulda
|
77
91
|
requirement: !ruby/object:Gem::Requirement
|
78
92
|
requirements:
|
79
93
|
- - "~>"
|
80
94
|
- !ruby/object:Gem::Version
|
81
|
-
version:
|
95
|
+
version: 4.0.0
|
82
96
|
type: :development
|
83
97
|
prerelease: false
|
84
98
|
version_requirements: !ruby/object:Gem::Requirement
|
85
99
|
requirements:
|
86
100
|
- - "~>"
|
87
101
|
- !ruby/object:Gem::Version
|
88
|
-
version:
|
102
|
+
version: 4.0.0
|
89
103
|
description: Simple, internationalized and DRY page titles and headings for Rails.
|
90
104
|
email:
|
91
105
|
- lukas.westermann@gmail.com
|
@@ -119,14 +133,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
119
133
|
requirements:
|
120
134
|
- - ">="
|
121
135
|
- !ruby/object:Gem::Version
|
122
|
-
version: 2.
|
136
|
+
version: 2.7.0
|
123
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
138
|
requirements:
|
125
139
|
- - ">="
|
126
140
|
- !ruby/object:Gem::Version
|
127
141
|
version: '0'
|
128
142
|
requirements: []
|
129
|
-
rubygems_version: 3.2.
|
143
|
+
rubygems_version: 3.2.32
|
130
144
|
signing_key:
|
131
145
|
specification_version: 4
|
132
146
|
summary: Simple, internationalized and DRY page titles and headings for Rails.
|