meta-tags 2.19.0 → 2.21.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -59,7 +59,11 @@ module MetaTags
59
59
  normalized_meta_tags[:site] = meta_tags[:site]
60
60
  title = meta_tags.extract_full_title
61
61
  normalized_meta_tags[:full_title] = title
62
- tags << ContentTag.new(:title, content: title) if title.present?
62
+ default_attributes = MetaTags.config.title_tag_attributes || {}
63
+
64
+ if title.present?
65
+ tags << ContentTag.new(:title, {content: title}.with_defaults(default_attributes))
66
+ end
63
67
  end
64
68
 
65
69
  # Renders icon(s) tag.
@@ -88,7 +92,7 @@ module MetaTags
88
92
  # @see TextNormalizer
89
93
  #
90
94
  def render_with_normalization(tags, name)
91
- value = TextNormalizer.public_send("normalize_#{name}", meta_tags.extract(name))
95
+ value = TextNormalizer.public_send(:"normalize_#{name}", meta_tags.extract(name))
92
96
  normalized_meta_tags[name] = value
93
97
  tags << Tag.new(:meta, name: name, content: value) if value.present?
94
98
  end
@@ -134,16 +134,15 @@ module MetaTags
134
134
  #
135
135
  # @param [String] string input strings.
136
136
  # @param [Integer,nil] limit characters number to truncate to.
137
- # @param [String] natural_separator natural separator to truncate at.
138
137
  # @return [String] truncated string.
139
138
  #
140
- def truncate(string, limit = nil, natural_separator = " ")
139
+ def truncate(string, limit = nil)
141
140
  return string if limit.to_i == 0
142
141
 
143
142
  helpers.truncate(
144
143
  string,
145
144
  length: limit,
146
- separator: natural_separator,
145
+ separator: MetaTags.config.truncate_on_natural_separator,
147
146
  omission: "",
148
147
  escape: true
149
148
  )
@@ -154,10 +153,9 @@ module MetaTags
154
153
  # @param [Array<String>] string_array input strings.
155
154
  # @param [Integer,nil] limit characters number to truncate to.
156
155
  # @param [String] separator separator that will be used to join array later.
157
- # @param [String] natural_separator natural separator to truncate at.
158
156
  # @return [Array<String>] truncated array of strings.
159
157
  #
160
- def truncate_array(string_array, limit = nil, separator = "", natural_separator = " ")
158
+ def truncate_array(string_array, limit = nil, separator = "")
161
159
  return string_array if limit.nil? || limit <= 0
162
160
 
163
161
  length = 0
@@ -167,7 +165,7 @@ module MetaTags
167
165
  limit_left = calculate_limit_left(limit, length, result, separator)
168
166
 
169
167
  if string.length > limit_left
170
- result << truncate(string, limit_left, natural_separator)
168
+ result << truncate(string, limit_left)
171
169
  break string_array
172
170
  end
173
171
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module MetaTags
4
4
  # Gem version.
5
- VERSION = "2.19.0"
5
+ VERSION = "2.21.0"
6
6
  public_constant :VERSION
7
7
  end
data/meta-tags.gemspec CHANGED
@@ -15,26 +15,26 @@ Gem::Specification.new do |spec|
15
15
  spec.homepage = "https://github.com/kpumuk/meta-tags"
16
16
  spec.license = "MIT"
17
17
  spec.platform = Gem::Platform::RUBY
18
- spec.required_ruby_version = ">= 2.7.0"
18
+ spec.required_ruby_version = ">= 3.0.0"
19
19
 
20
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(\.|(bin|test|spec|features)/)}) }
20
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(\.|Gemfile|Appraisals|Steepfile|(bin|spec|gemfiles)/)}) }
21
21
  spec.bindir = "exe"
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ["lib"]
24
24
 
25
- spec.add_runtime_dependency "actionpack", ">= 3.2.0", "< 7.2"
25
+ spec.add_runtime_dependency "actionpack", ">= 6.0.0", "< 7.2"
26
26
 
27
27
  spec.add_development_dependency "railties", ">= 3.2.0", "< 7.2"
28
28
  spec.add_development_dependency "rake", "~> 13.0"
29
- spec.add_development_dependency "rspec", "~> 3.12.0"
29
+ spec.add_development_dependency "rspec", "~> 3.13.0"
30
30
  spec.add_development_dependency "rspec-html-matchers", "~> 0.10.0"
31
31
  spec.add_development_dependency "appraisal", "~> 2.5.0"
32
32
  spec.add_development_dependency "simplecov", "~> 0.22.0"
33
33
  # Code style
34
- spec.add_development_dependency "standard", "~> 1.29"
35
- spec.add_development_dependency "rubocop-rails", "~> 2.20.2"
34
+ spec.add_development_dependency "standard", "~> 1.31"
35
+ spec.add_development_dependency "rubocop-rails", "~> 2.24.0"
36
36
  spec.add_development_dependency "rubocop-rake", "~> 0.6.0"
37
- spec.add_development_dependency "rubocop-rspec", "~> 2.23.0"
37
+ spec.add_development_dependency "rubocop-rspec", "~> 2.29.1"
38
38
  # Format RSpec output for CircleCI
39
39
  spec.add_development_dependency "rspec_junit_formatter", "~> 0.6.0"
40
40
 
@@ -1,6 +1,7 @@
1
1
  class ::Hash[unchecked out K, unchecked out V]
2
2
  def with_indifferent_access: () -> ActiveSupport::HashWithIndifferentAccess[K, V]
3
3
  def deep_merge!: (instance | ActiveSupport::HashWithIndifferentAccess[K, V] other) -> self
4
+ def with_defaults: (instance | ActiveSupport::HashWithIndifferentAccess[K, V] other) -> self
4
5
  end
5
6
 
6
7
  class ::Object
@@ -1,7 +1,14 @@
1
1
  module MetaTags
2
2
  class Configuration
3
+ type html_tag_key = String | Symbol
4
+ type html_tag_value = Hash[html_tag_key, html_tag_value] | html_tag_content
5
+ type html_tag_content = String? | Symbol | (_Stringish & Object)
6
+
7
+
3
8
  attr_accessor title_limit: Integer?
4
9
  attr_accessor truncate_site_title_first: bool
10
+ attr_accessor truncate_on_natural_separator: String?|Regexp
11
+ attr_accessor title_tag_attributes: Hash[html_tag_key, html_tag_value]?
5
12
  attr_accessor description_limit: Integer
6
13
  attr_accessor keywords_limit: Integer
7
14
  attr_accessor keywords_separator: String
@@ -21,9 +21,9 @@ module MetaTags
21
21
 
22
22
  def cleanup_strings: (keywords? strings, ?strip: bool strip) -> Array[String]
23
23
 
24
- def truncate: (String string, ?Integer? limit, ?String natural_separator) -> String
24
+ def truncate: (String string, ?Integer? limit) -> String
25
25
 
26
- def truncate_array: (Array[String] string_array, ?Integer? limit, ?String separator, ?String natural_separator) -> Array[String]
26
+ def truncate_array: (Array[String] string_array, ?Integer? limit, ?String separator) -> Array[String]
27
27
 
28
28
  private
29
29
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meta-tags
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.19.0
4
+ version: 2.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmytro Shteflyuk
@@ -30,7 +30,7 @@ cert_chain:
30
30
  ovz1LEphwrX/6v635mteXvl+OKWrNo1Q78sU364BgY5MvJMxFytmUrKMgO6RAiIM
31
31
  N9+lhJiLa7+h0LrvPPDZRhV8ze0=
32
32
  -----END CERTIFICATE-----
33
- date: 2023-10-05 00:00:00.000000000 Z
33
+ date: 2024-04-11 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: actionpack
@@ -38,7 +38,7 @@ dependencies:
38
38
  requirements:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: 3.2.0
41
+ version: 6.0.0
42
42
  - - "<"
43
43
  - !ruby/object:Gem::Version
44
44
  version: '7.2'
@@ -48,7 +48,7 @@ dependencies:
48
48
  requirements:
49
49
  - - ">="
50
50
  - !ruby/object:Gem::Version
51
- version: 3.2.0
51
+ version: 6.0.0
52
52
  - - "<"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '7.2'
@@ -92,14 +92,14 @@ dependencies:
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: 3.12.0
95
+ version: 3.13.0
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: 3.12.0
102
+ version: 3.13.0
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: rspec-html-matchers
105
105
  requirement: !ruby/object:Gem::Requirement
@@ -148,28 +148,28 @@ dependencies:
148
148
  requirements:
149
149
  - - "~>"
150
150
  - !ruby/object:Gem::Version
151
- version: '1.29'
151
+ version: '1.31'
152
152
  type: :development
153
153
  prerelease: false
154
154
  version_requirements: !ruby/object:Gem::Requirement
155
155
  requirements:
156
156
  - - "~>"
157
157
  - !ruby/object:Gem::Version
158
- version: '1.29'
158
+ version: '1.31'
159
159
  - !ruby/object:Gem::Dependency
160
160
  name: rubocop-rails
161
161
  requirement: !ruby/object:Gem::Requirement
162
162
  requirements:
163
163
  - - "~>"
164
164
  - !ruby/object:Gem::Version
165
- version: 2.20.2
165
+ version: 2.24.0
166
166
  type: :development
167
167
  prerelease: false
168
168
  version_requirements: !ruby/object:Gem::Requirement
169
169
  requirements:
170
170
  - - "~>"
171
171
  - !ruby/object:Gem::Version
172
- version: 2.20.2
172
+ version: 2.24.0
173
173
  - !ruby/object:Gem::Dependency
174
174
  name: rubocop-rake
175
175
  requirement: !ruby/object:Gem::Requirement
@@ -190,14 +190,14 @@ dependencies:
190
190
  requirements:
191
191
  - - "~>"
192
192
  - !ruby/object:Gem::Version
193
- version: 2.23.0
193
+ version: 2.29.1
194
194
  type: :development
195
195
  prerelease: false
196
196
  version_requirements: !ruby/object:Gem::Requirement
197
197
  requirements:
198
198
  - - "~>"
199
199
  - !ruby/object:Gem::Version
200
- version: 2.23.0
200
+ version: 2.29.1
201
201
  - !ruby/object:Gem::Dependency
202
202
  name: rspec_junit_formatter
203
203
  requirement: !ruby/object:Gem::Requirement
@@ -219,28 +219,13 @@ executables: []
219
219
  extensions: []
220
220
  extra_rdoc_files: []
221
221
  files:
222
- - Appraisals
223
222
  - CHANGELOG.md
224
223
  - CODE_OF_CONDUCT.md
225
224
  - CONTRIBUTING.md
226
- - Gemfile
227
225
  - MIT-LICENSE
228
226
  - README.md
229
227
  - Rakefile
230
- - Steepfile
231
228
  - certs/kpumuk.pem
232
- - gemfiles/rails_5.1.gemfile
233
- - gemfiles/rails_5.1.gemfile.lock
234
- - gemfiles/rails_5.2.gemfile
235
- - gemfiles/rails_5.2.gemfile.lock
236
- - gemfiles/rails_6.0.gemfile
237
- - gemfiles/rails_6.0.gemfile.lock
238
- - gemfiles/rails_6.1.gemfile
239
- - gemfiles/rails_6.1.gemfile.lock
240
- - gemfiles/rails_7.0.gemfile
241
- - gemfiles/rails_7.0.gemfile.lock
242
- - gemfiles/rails_7.1.gemfile
243
- - gemfiles/rails_7.1.gemfile.lock
244
229
  - lib/generators/meta_tags/install_generator.rb
245
230
  - lib/generators/meta_tags/templates/config/initializers/meta_tags.rb
246
231
  - lib/meta-tags.rb
@@ -285,14 +270,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
285
270
  requirements:
286
271
  - - ">="
287
272
  - !ruby/object:Gem::Version
288
- version: 2.7.0
273
+ version: 3.0.0
289
274
  required_rubygems_version: !ruby/object:Gem::Requirement
290
275
  requirements:
291
276
  - - ">="
292
277
  - !ruby/object:Gem::Version
293
278
  version: '0'
294
279
  requirements: []
295
- rubygems_version: 3.4.10
280
+ rubygems_version: 3.5.3
296
281
  signing_key:
297
282
  specification_version: 4
298
283
  summary: Collection of SEO helpers for Ruby on Rails.
metadata.gz.sig CHANGED
Binary file
data/Appraisals DELETED
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- appraise "rails-5.1" do
4
- gem "railties", "5.1.7"
5
- end
6
-
7
- appraise "rails-5.2" do
8
- gem "railties", "5.2.8.1"
9
- end
10
-
11
- appraise "rails-6.0" do
12
- gem "railties", "6.0.6"
13
- end
14
-
15
- appraise "rails-6.1" do
16
- gem "railties", "6.1.7"
17
- end
18
-
19
- appraise "rails-7.0" do
20
- gem "railties", "7.0.4"
21
- end
22
-
23
- appraise "rails-7.1" do
24
- gem "railties", "7.1.0"
25
- end
data/Gemfile DELETED
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- # Specify gem's dependencies in meta-tags.gemspec
6
- gemspec
7
-
8
- unless ENV["NO_STEEP"] == "1"
9
- # Ruby typings
10
- gem "steep", "~> 1.5.2", platform: :mri
11
- end
data/Steepfile DELETED
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- target :lib do
4
- signature "sig"
5
-
6
- check "lib"
7
- # check "Gemfile"
8
-
9
- # We don't want to type check Rails/RSpec related code
10
- # (because we don't have RBS files for it)
11
- ignore "lib/meta_tags/railtie.rb"
12
- ignore "lib/generators"
13
- end
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "steep", "~> 1.5.2", platform: :mri
6
- gem "railties", "5.1.7"
7
-
8
- gemspec path: "../"
@@ -1,200 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- meta-tags (2.19.0)
5
- actionpack (>= 3.2.0, < 7.2)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- actionpack (5.1.7)
11
- actionview (= 5.1.7)
12
- activesupport (= 5.1.7)
13
- rack (~> 2.0)
14
- rack-test (>= 0.6.3)
15
- rails-dom-testing (~> 2.0)
16
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
17
- actionview (5.1.7)
18
- activesupport (= 5.1.7)
19
- builder (~> 3.1)
20
- erubi (~> 1.4)
21
- rails-dom-testing (~> 2.0)
22
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
23
- activesupport (5.1.7)
24
- concurrent-ruby (~> 1.0, >= 1.0.2)
25
- i18n (>= 0.7, < 2)
26
- minitest (~> 5.1)
27
- tzinfo (~> 1.1)
28
- appraisal (2.5.0)
29
- bundler
30
- rake
31
- thor (>= 0.14.0)
32
- ast (2.4.2)
33
- base64 (0.1.1)
34
- builder (3.2.4)
35
- concurrent-ruby (1.2.2)
36
- crass (1.0.6)
37
- csv (3.2.7)
38
- diff-lcs (1.5.0)
39
- docile (1.4.0)
40
- erubi (1.12.0)
41
- ffi (1.16.3)
42
- fileutils (1.7.1)
43
- i18n (1.14.1)
44
- concurrent-ruby (~> 1.0)
45
- json (2.6.3)
46
- language_server-protocol (3.17.0.3)
47
- lint_roller (1.1.0)
48
- listen (3.8.0)
49
- rb-fsevent (~> 0.10, >= 0.10.3)
50
- rb-inotify (~> 0.9, >= 0.9.10)
51
- logger (1.5.3)
52
- loofah (2.21.3)
53
- crass (~> 1.0.2)
54
- nokogiri (>= 1.12.0)
55
- method_source (1.0.0)
56
- minitest (5.20.0)
57
- nokogiri (1.15.4-arm64-darwin)
58
- racc (~> 1.4)
59
- parallel (1.23.0)
60
- parser (3.2.2.4)
61
- ast (~> 2.4.1)
62
- racc
63
- racc (1.7.1)
64
- rack (2.2.8)
65
- rack-test (2.1.0)
66
- rack (>= 1.3)
67
- rails-dom-testing (2.2.0)
68
- activesupport (>= 5.0.0)
69
- minitest
70
- nokogiri (>= 1.6)
71
- rails-html-sanitizer (1.6.0)
72
- loofah (~> 2.21)
73
- nokogiri (~> 1.14)
74
- railties (5.1.7)
75
- actionpack (= 5.1.7)
76
- activesupport (= 5.1.7)
77
- method_source
78
- rake (>= 0.8.7)
79
- thor (>= 0.18.1, < 2.0)
80
- rainbow (3.1.1)
81
- rake (13.0.6)
82
- rb-fsevent (0.11.2)
83
- rb-inotify (0.10.1)
84
- ffi (~> 1.0)
85
- rbs (3.2.2)
86
- regexp_parser (2.8.1)
87
- rexml (3.2.6)
88
- rspec (3.12.0)
89
- rspec-core (~> 3.12.0)
90
- rspec-expectations (~> 3.12.0)
91
- rspec-mocks (~> 3.12.0)
92
- rspec-core (3.12.2)
93
- rspec-support (~> 3.12.0)
94
- rspec-expectations (3.12.3)
95
- diff-lcs (>= 1.2.0, < 2.0)
96
- rspec-support (~> 3.12.0)
97
- rspec-html-matchers (0.10.0)
98
- nokogiri (~> 1)
99
- rspec (>= 3.0.0.a)
100
- rspec-mocks (3.12.6)
101
- diff-lcs (>= 1.2.0, < 2.0)
102
- rspec-support (~> 3.12.0)
103
- rspec-support (3.12.1)
104
- rspec_junit_formatter (0.6.0)
105
- rspec-core (>= 2, < 4, != 2.12.0)
106
- rubocop (1.56.4)
107
- base64 (~> 0.1.1)
108
- json (~> 2.3)
109
- language_server-protocol (>= 3.17.0)
110
- parallel (~> 1.10)
111
- parser (>= 3.2.2.3)
112
- rainbow (>= 2.2.2, < 4.0)
113
- regexp_parser (>= 1.8, < 3.0)
114
- rexml (>= 3.2.5, < 4.0)
115
- rubocop-ast (>= 1.28.1, < 2.0)
116
- ruby-progressbar (~> 1.7)
117
- unicode-display_width (>= 2.4.0, < 3.0)
118
- rubocop-ast (1.29.0)
119
- parser (>= 3.2.1.0)
120
- rubocop-capybara (2.19.0)
121
- rubocop (~> 1.41)
122
- rubocop-factory_bot (2.24.0)
123
- rubocop (~> 1.33)
124
- rubocop-performance (1.19.1)
125
- rubocop (>= 1.7.0, < 2.0)
126
- rubocop-ast (>= 0.4.0)
127
- rubocop-rails (2.20.2)
128
- activesupport (>= 4.2.0)
129
- rack (>= 1.1)
130
- rubocop (>= 1.33.0, < 2.0)
131
- rubocop-rake (0.6.0)
132
- rubocop (~> 1.0)
133
- rubocop-rspec (2.23.2)
134
- rubocop (~> 1.33)
135
- rubocop-capybara (~> 2.17)
136
- rubocop-factory_bot (~> 2.22)
137
- ruby-progressbar (1.13.0)
138
- securerandom (0.2.2)
139
- simplecov (0.22.0)
140
- docile (~> 1.1)
141
- simplecov-html (~> 0.11)
142
- simplecov_json_formatter (~> 0.1)
143
- simplecov-html (0.12.3)
144
- simplecov_json_formatter (0.1.4)
145
- standard (1.31.1)
146
- language_server-protocol (~> 3.17.0.2)
147
- lint_roller (~> 1.0)
148
- rubocop (~> 1.56.2)
149
- standard-custom (~> 1.0.0)
150
- standard-performance (~> 1.2)
151
- standard-custom (1.0.2)
152
- lint_roller (~> 1.0)
153
- rubocop (~> 1.50)
154
- standard-performance (1.2.0)
155
- lint_roller (~> 1.1)
156
- rubocop-performance (~> 1.19.0)
157
- steep (1.5.3)
158
- activesupport (>= 5.1)
159
- concurrent-ruby (>= 1.1.10)
160
- csv (>= 3.0.9)
161
- fileutils (>= 1.1.0)
162
- json (>= 2.1.0)
163
- language_server-protocol (>= 3.15, < 4.0)
164
- listen (~> 3.0)
165
- logger (>= 1.3.0)
166
- parser (>= 3.1)
167
- rainbow (>= 2.2.2, < 4.0)
168
- rbs (>= 3.1.0)
169
- securerandom (>= 0.1)
170
- strscan (>= 1.0.0)
171
- terminal-table (>= 2, < 4)
172
- strscan (3.0.6)
173
- terminal-table (3.0.2)
174
- unicode-display_width (>= 1.1.1, < 3)
175
- thor (1.2.2)
176
- thread_safe (0.3.6)
177
- tzinfo (1.2.11)
178
- thread_safe (~> 0.1)
179
- unicode-display_width (2.5.0)
180
-
181
- PLATFORMS
182
- arm64-darwin
183
-
184
- DEPENDENCIES
185
- appraisal (~> 2.5.0)
186
- meta-tags!
187
- railties (= 5.1.7)
188
- rake (~> 13.0)
189
- rspec (~> 3.12.0)
190
- rspec-html-matchers (~> 0.10.0)
191
- rspec_junit_formatter (~> 0.6.0)
192
- rubocop-rails (~> 2.20.2)
193
- rubocop-rake (~> 0.6.0)
194
- rubocop-rspec (~> 2.23.0)
195
- simplecov (~> 0.22.0)
196
- standard (~> 1.29)
197
- steep (~> 1.5.2)
198
-
199
- BUNDLED WITH
200
- 2.4.10
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "steep", "~> 1.5.2", platform: :mri
6
- gem "railties", "5.2.8.1"
7
-
8
- gemspec path: "../"