meta-tags 2.18.0 → 2.20.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,22 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler'
3
+ require "bundler"
4
4
  Bundler::GemHelper.install_tasks
5
5
 
6
- require 'rspec/core/rake_task'
6
+ require "rspec/core/rake_task"
7
7
  RSpec::Core::RakeTask.new(:spec)
8
8
 
9
+ desc "Run RSpec tests"
9
10
  task test: :spec
10
11
  task default: :spec
11
12
 
12
- desc 'Rebuild Circle CI configuration based on the build matrix template .circleci/config.yml.erb'
13
- task :circleci do
14
- require 'erb'
15
- template_path = File.expand_path('.circleci/config.yml.erb', __dir__)
16
- config_path = File.expand_path('.circleci/config.yml', __dir__)
17
- File.write config_path, ERB.new(File.read(template_path)).result
18
- end
19
-
20
13
  module SteepRunner
21
14
  def self.run(*command)
22
15
  require "steep"
@@ -26,24 +19,30 @@ module SteepRunner
26
19
  end
27
20
  end
28
21
 
29
- task :steep do
30
- SteepRunner.run("check")
31
- end
22
+ desc "Check type information"
23
+ task steep: "steep:check"
32
24
 
33
25
  namespace :steep do
26
+ desc "Check type information"
27
+ task :check do
28
+ SteepRunner.run("check")
29
+ end
30
+
31
+ desc "Print type statistics"
34
32
  task :stats do
35
33
  SteepRunner.run("stats", "--log-level=fatal")
36
34
  end
37
35
  end
38
36
 
39
37
  namespace :rbs do
38
+ desc "Run RSpec tests with RBS enabled to test type signatures"
40
39
  task :spec do
41
40
  exec(
42
41
  {
43
- 'RBS_TEST_TARGET' => 'MetaTags::*',
44
- 'RUBYOPT' => '-rrbs/test/setup',
42
+ "RBS_TEST_TARGET" => "MetaTags::*",
43
+ "RUBYOPT" => "-rrbs/test/setup"
45
44
  },
46
- 'bundle exec rspec',
45
+ "bundle exec rspec"
47
46
  )
48
47
  end
49
48
  end
data/certs/kpumuk.pem CHANGED
@@ -1,20 +1,21 @@
1
1
  -----BEGIN CERTIFICATE-----
2
- MIIDODCCAiCgAwIBAgIBAT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rd
16
+ 2R5uQS4uiZ5KA+3SkgWQOFOzpFlo7ywS5264ULCcvfix6NQpb2aIDsZuzWGBIDbs
17
+ ixS+8wYslrzsOgUSn/RjF0sVB0dw4wv6G8YnVrR/Jf2SaO+Q2lYuKEOKfj52I+Yt
18
+ TdFiOjR+WwXSxs/XdSdFtqK2q/THbZdk+HkAe8guvXYtD/fzO2mBlk2AQ0hV1Pxu
19
+ ovz1LEphwrX/6v635mteXvl+OKWrNo1Q78sU364BgY5MvJMxFytmUrKMgO6RAiIM
20
+ N9+lhJiLa7+h0LrvPPDZRhV8ze0=
20
21
  -----END CERTIFICATE-----
@@ -4,7 +4,7 @@ module MetaTags
4
4
  module Generators
5
5
  class InstallGenerator < Rails::Generators::Base
6
6
  desc "Copy MetaTags default files"
7
- source_root File.expand_path('templates', __dir__)
7
+ source_root File.expand_path("templates", __dir__)
8
8
 
9
9
  def copy_config
10
10
  template "config/initializers/meta_tags.rb"
@@ -9,6 +9,12 @@ MetaTags.configure do |config|
9
9
  # When true, site title will be truncated instead of title. Default is false.
10
10
  # config.truncate_site_title_first = false
11
11
 
12
+ # Add HTML attributes to the <title> HTML tag. Default is {}.
13
+ # config.title_tag_attributes = {}
14
+
15
+ # Add HTML attributes to the <title> HTML tag. Default is {}.
16
+ # config.title_tag_attributes = {}
17
+
12
18
  # Maximum length of the page description. Default is 300.
13
19
  # Set to nil or 0 to remove limits.
14
20
  # config.description_limit = 300
data/lib/meta-tags.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'meta_tags'
3
+ require "meta_tags"
@@ -6,9 +6,15 @@ module MetaTags
6
6
  # How many characters to truncate title to.
7
7
  attr_accessor :title_limit
8
8
 
9
+ # HTML attributes for the title tag.
10
+ attr_accessor :title_tag_attributes
11
+
9
12
  # Truncate site_title instead of title.
10
13
  attr_accessor :truncate_site_title_first
11
14
 
15
+ # A string or regexp separator to truncate text at a natural break.
16
+ attr_accessor :truncate_on_natural_separator
17
+
12
18
  # How many characters to truncate description to.
13
19
  attr_accessor :description_limit
14
20
 
@@ -47,25 +53,25 @@ module MetaTags
47
53
  def default_property_tags
48
54
  [
49
55
  # App Link metadata https://developers.facebook.com/docs/applinks/metadata-reference
50
- 'al',
56
+ "al",
51
57
  # Open Graph Markup https://developers.facebook.com/docs/sharing/webmasters#markup
52
- 'fb',
53
- 'og',
58
+ "fb",
59
+ "og",
54
60
  # Facebook OpenGraph Object Types https://developers.facebook.com/docs/reference/opengraph
55
61
  # Note that these tags are used in a regex, so including e.g. 'restaurant' will affect
56
62
  # 'restaurant:category', 'restaurant:price_rating', and anything else under that namespace.
57
- 'article',
58
- 'book',
59
- 'books',
60
- 'business',
61
- 'fitness',
62
- 'game',
63
- 'music',
64
- 'place',
65
- 'product',
66
- 'profile',
67
- 'restaurant',
68
- 'video',
63
+ "article",
64
+ "book",
65
+ "books",
66
+ "business",
67
+ "fitness",
68
+ "game",
69
+ "music",
70
+ "place",
71
+ "product",
72
+ "profile",
73
+ "restaurant",
74
+ "video"
69
75
  ].freeze
70
76
  end
71
77
 
@@ -76,9 +82,11 @@ module MetaTags
76
82
  def reset_defaults!
77
83
  @title_limit = 70
78
84
  @truncate_site_title_first = false
85
+ @truncate_on_natural_separator = " "
86
+ @title_tag_attributes = {}
79
87
  @description_limit = 300
80
88
  @keywords_limit = 255
81
- @keywords_separator = ', '
89
+ @keywords_separator = ", "
82
90
  @keywords_lowercase = true
83
91
  @property_tags = default_property_tags.dup
84
92
  @open_meta_tags = true
@@ -15,8 +15,8 @@ module MetaTags
15
15
  # Processes the <tt>@page_title</tt>, <tt>@page_keywords</tt>, and
16
16
  # <tt>@page_description</tt> instance variables and calls +render+.
17
17
  def render(*args, &block)
18
- meta_tags[:title] = @page_title if defined?(@page_title) && @page_title
19
- meta_tags[:keywords] = @page_keywords if defined?(@page_keywords) && @page_keywords
18
+ meta_tags[:title] = @page_title if defined?(@page_title) && @page_title
19
+ meta_tags[:keywords] = @page_keywords if defined?(@page_keywords) && @page_keywords
20
20
  meta_tags[:description] = @page_description if defined?(@page_description) && @page_description
21
21
 
22
22
  super
@@ -25,7 +25,7 @@ module MetaTags
25
25
  # Set meta tags for the page.
26
26
  #
27
27
  # See <tt>MetaTags::ViewHelper#set_meta_tags</tt> for details.
28
- def set_meta_tags(meta_tags) # rubocop:disable Naming/AccessorMethodName
28
+ def set_meta_tags(meta_tags)
29
29
  self.meta_tags.update(meta_tags)
30
30
  end
31
31
  protected :set_meta_tags
@@ -39,12 +39,12 @@ module MetaTags
39
39
  #
40
40
  def update(object = {})
41
41
  meta_tags = if object.respond_to?(:to_meta_tags)
42
- # @type var object: (_MetaTagish & Object)
43
- object.to_meta_tags
44
- else
45
- # @type var object: Hash[String | Symbol, untyped]
46
- object
47
- end
42
+ # @type var object: _MetaTagish & Object
43
+ object.to_meta_tags
44
+ else
45
+ # @type var object: Hash[String | Symbol, untyped]
46
+ object
47
+ end
48
48
  @meta_tags.deep_merge! normalize_open_graph(meta_tags)
49
49
  end
50
50
 
@@ -79,7 +79,7 @@ module MetaTags
79
79
  old_site = @meta_tags[:site]
80
80
  @meta_tags[:site] = nil
81
81
  full_title = with_defaults(defaults) { extract_full_title }
82
- full_title.presence || old_site || ''
82
+ full_title.presence || old_site || ""
83
83
  ensure
84
84
  @meta_tags[:site] = old_site
85
85
  end
@@ -106,10 +106,10 @@ module MetaTags
106
106
  # @return [String] page title.
107
107
  #
108
108
  def extract_full_title
109
- site_title = extract(:site) || ''
110
- title = extract_title
111
- separator = extract_separator
112
- reverse = extract(:reverse) == true
109
+ site_title = extract(:site) || ""
110
+ title = extract_title
111
+ separator = extract_separator
112
+ reverse = extract(:reverse) == true
113
113
 
114
114
  TextNormalizer.normalize_title(site_title, title, separator, reverse)
115
115
  end
@@ -136,15 +136,15 @@ module MetaTags
136
136
  def extract_separator
137
137
  if meta_tags[:separator] == false
138
138
  # Special case: if separator is hidden, do not display suffix/prefix
139
- prefix = separator = suffix = ''
139
+ prefix = separator = suffix = ""
140
140
  else
141
- prefix = extract_separator_section(:prefix, ' ')
142
- separator = extract_separator_section(:separator, '|')
143
- suffix = extract_separator_section(:suffix, ' ')
141
+ prefix = extract_separator_section(:prefix, " ")
142
+ separator = extract_separator_section(:separator, "|")
143
+ suffix = extract_separator_section(:suffix, " ")
144
144
  end
145
145
  delete(:separator, :prefix, :suffix)
146
146
 
147
- TextNormalizer.safe_join([prefix, separator, suffix], '')
147
+ TextNormalizer.safe_join([prefix, separator, suffix], "")
148
148
  end
149
149
 
150
150
  # Extracts noindex settings as a Hash mapping noindex tag name to value.
@@ -159,12 +159,12 @@ module MetaTags
159
159
  [:noindex, :index],
160
160
  # follow has higher priority than nofollow
161
161
  [:follow, :nofollow],
162
- :noarchive,
162
+ :noarchive
163
163
  ].each do |attributes|
164
164
  calculate_robots_attributes(result, attributes)
165
165
  end
166
166
 
167
- result.transform_values { |v| v.join(', ') }
167
+ result.transform_values { |v| v.join(", ") }
168
168
  end
169
169
 
170
170
  protected
@@ -188,7 +188,7 @@ module MetaTags
188
188
  # @return [String] separator segment value.
189
189
  #
190
190
  def extract_separator_section(name, default)
191
- meta_tags[name] == false ? '' : (meta_tags[name] || default)
191
+ (meta_tags[name] == false) ? "" : (meta_tags[name] || default)
192
192
  end
193
193
 
194
194
  # Extracts robots attribute (noindex, nofollow, etc) name and value.
@@ -197,11 +197,11 @@ module MetaTags
197
197
  # @return [Array<String>] pair of noindex attribute name and value.
198
198
  #
199
199
  def extract_robots_attribute(name)
200
- noindex = extract(name)
201
- noindex_name = noindex.kind_of?(String) || noindex.kind_of?(Array) ? noindex : 'robots'
200
+ noindex = extract(name)
201
+ noindex_name = (noindex.is_a?(String) || noindex.is_a?(Array)) ? noindex : "robots"
202
202
  noindex_value = noindex ? name.to_s : nil
203
203
 
204
- [ noindex_name, noindex_value ]
204
+ [noindex_name, noindex_value]
205
205
  end
206
206
 
207
207
  def calculate_robots_attributes(result, attributes)
@@ -2,15 +2,15 @@
2
2
 
3
3
  module MetaTags
4
4
  class Railtie < Rails::Railtie
5
- initializer 'meta_tags.setup_action_controller' do
5
+ initializer "meta_tags.setup_action_controller" do
6
6
  ActiveSupport.on_load :action_controller do
7
- ActionController::Base.include MetaTags::ControllerHelper
7
+ include MetaTags::ControllerHelper
8
8
  end
9
9
  end
10
10
 
11
- initializer 'meta_tags.setup_action_view' do
11
+ initializer "meta_tags.setup_action_view" do
12
12
  ActiveSupport.on_load :action_view do
13
- ActionView::Base.include MetaTags::ViewHelper
13
+ include MetaTags::ViewHelper
14
14
  end
15
15
  end
16
16
  end
@@ -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.
@@ -71,12 +75,12 @@ module MetaTags
71
75
  return unless icon
72
76
 
73
77
  # String? Value is an href
74
- icon = [{ href: icon }] if icon.kind_of?(String)
78
+ icon = [{href: icon}] if icon.is_a?(String)
75
79
  # Hash? Single icon instead of a list of icons
76
- icon = [icon] if icon.kind_of?(Hash)
80
+ icon = [icon] if icon.is_a?(Hash)
77
81
 
78
82
  icon.each do |icon_params|
79
- icon_params = { rel: 'icon', type: 'image/x-icon' }.with_indifferent_access.merge(icon_params)
83
+ icon_params = {rel: "icon", type: "image/x-icon"}.with_indifferent_access.merge(icon_params)
80
84
  tags << Tag.new(:link, icon_params)
81
85
  end
82
86
  end
@@ -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
@@ -109,7 +113,7 @@ module MetaTags
109
113
  #
110
114
  def render_refresh(tags)
111
115
  refresh = meta_tags.extract(:refresh)
112
- tags << Tag.new(:meta, 'http-equiv' => 'refresh', content: refresh.to_s) if refresh.present?
116
+ tags << Tag.new(:meta, "http-equiv" => "refresh", :content => refresh.to_s) if refresh.present?
113
117
  end
114
118
 
115
119
  # Renders alternate link tags.
@@ -120,13 +124,13 @@ module MetaTags
120
124
  alternate = meta_tags.extract(:alternate)
121
125
  return unless alternate
122
126
 
123
- if alternate.kind_of?(Hash)
127
+ if alternate.is_a?(Hash)
124
128
  alternate.each do |hreflang, href|
125
- tags << Tag.new(:link, rel: 'alternate', href: href, hreflang: hreflang) if href.present?
129
+ tags << Tag.new(:link, rel: "alternate", href: href, hreflang: hreflang) if href.present?
126
130
  end
127
- elsif alternate.kind_of?(Array)
131
+ elsif alternate.is_a?(Array)
128
132
  alternate.each do |link_params|
129
- tags << Tag.new(:link, { rel: 'alternate' }.with_indifferent_access.merge(link_params))
133
+ tags << Tag.new(:link, {rel: "alternate"}.with_indifferent_access.merge(link_params))
130
134
  end
131
135
  end
132
136
  end
@@ -143,7 +147,7 @@ module MetaTags
143
147
  title = open_search[:title]
144
148
 
145
149
  type = "application/opensearchdescription+xml"
146
- tags << Tag.new(:link, rel: 'search', type: type, href: href, title: title) if href.present?
150
+ tags << Tag.new(:link, rel: "search", type: type, href: href, title: title) if href.present?
147
151
  end
148
152
 
149
153
  # Renders links.
@@ -151,7 +155,7 @@ module MetaTags
151
155
  # @param [Array<Tag>] tags a buffer object to store tag in.
152
156
  #
153
157
  def render_links(tags)
154
- [ :amphtml, :prev, :next, :image_src, :manifest ].each do |tag_name|
158
+ [:amphtml, :prev, :next, :image_src, :manifest].each do |tag_name|
155
159
  href = meta_tags.extract(tag_name)
156
160
  if href.present?
157
161
  @normalized_meta_tags[tag_name] = href
@@ -189,7 +193,7 @@ module MetaTags
189
193
  #
190
194
  def render_hash(tags, key, **opts)
191
195
  data = meta_tags.meta_tags[key]
192
- return unless data.kind_of?(Hash)
196
+ return unless data.is_a?(Hash)
193
197
 
194
198
  process_hash(tags, key, data, **opts)
195
199
  meta_tags.extract(key)
@@ -202,7 +206,7 @@ module MetaTags
202
206
  def render_custom(tags)
203
207
  meta_tags.meta_tags.each do |name, data|
204
208
  Array(data).each do |val|
205
- tags << Tag.new(:meta, configured_name_key(name) => name, content: val)
209
+ tags << Tag.new(:meta, configured_name_key(name) => name, :content => val)
206
210
  end
207
211
  meta_tags.extract(name)
208
212
  end
@@ -217,14 +221,14 @@ module MetaTags
217
221
  #
218
222
  def process_tree(tags, property, content, itemprop: nil, **opts)
219
223
  method = case content
220
- when Hash
221
- :process_hash
222
- when Array
223
- :process_array
224
- else
225
- iprop = itemprop
226
- :render_tag
227
- end
224
+ when Hash
225
+ :process_hash
226
+ when Array
227
+ :process_array
228
+ else
229
+ iprop = itemprop
230
+ :render_tag
231
+ end
228
232
  __send__(method, tags, property, content, itemprop: iprop, **opts)
229
233
  end
230
234
 
@@ -237,18 +241,18 @@ module MetaTags
237
241
  def process_hash(tags, property, content, **opts)
238
242
  itemprop = content.delete(:itemprop)
239
243
  content.each do |key, value|
240
- if key.to_s == '_'
244
+ if key.to_s == "_"
241
245
  iprop = itemprop
242
246
  key = property
243
247
  else
244
248
  key = "#{property}:#{key}"
245
249
  end
246
250
 
247
- normalized_value = if value.kind_of?(Symbol)
248
- normalized_meta_tags[value]
249
- else
250
- value
251
- end
251
+ normalized_value = if value.is_a?(Symbol)
252
+ normalized_meta_tags[value]
253
+ else
254
+ value
255
+ end
252
256
  process_tree(tags, key, normalized_value, **opts.merge(itemprop: iprop))
253
257
  end
254
258
  end
@@ -273,7 +277,7 @@ module MetaTags
273
277
  #
274
278
  def render_tag(tags, name, value, itemprop: nil)
275
279
  name_key ||= configured_name_key(name)
276
- tags << Tag.new(:meta, name_key => name.to_s, content: value, itemprop: itemprop) if value.present?
280
+ tags << Tag.new(:meta, name_key => name.to_s, :content => value, :itemprop => itemprop) if value.present?
277
281
  end
278
282
 
279
283
  # Returns meta tag property name for a give meta tag based on the
@@ -44,7 +44,7 @@ module MetaTags
44
44
  # serves the same purpose we could just as it to convert itself to str
45
45
  # and continue from there
46
46
  description = cleanup_string(description)
47
- return '' if description.blank?
47
+ return "" if description.blank?
48
48
 
49
49
  truncate(description, MetaTags.config.description_limit)
50
50
  end
@@ -56,7 +56,7 @@ module MetaTags
56
56
  #
57
57
  def normalize_keywords(keywords)
58
58
  keywords = cleanup_strings(keywords)
59
- return '' if keywords.blank?
59
+ return "" if keywords.blank?
60
60
 
61
61
  keywords.each(&:downcase!) if MetaTags.config.keywords_lowercase
62
62
  separator = cleanup_string MetaTags.config.keywords_separator, strip: false
@@ -107,12 +107,12 @@ module MetaTags
107
107
  # space characters squashed into a single space.
108
108
  #
109
109
  def cleanup_string(string, strip: true)
110
- return '' if string.nil?
111
- raise ArgumentError, 'Expected a string or an object that implements #to_str' unless string.respond_to?(:to_str)
110
+ return "" if string.nil?
111
+ raise ArgumentError, "Expected a string or an object that implements #to_str" unless string.respond_to?(:to_str)
112
112
 
113
113
  s = strip_tags(string.to_str)
114
114
  s = s.dup if s.frozen?
115
- s.gsub!(/\s+/, ' ')
115
+ s.gsub!(/\s+/, " ")
116
116
  s.strip! if strip
117
117
 
118
118
  s
@@ -134,18 +134,17 @@ 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 = ' ')
141
- return string if limit.to_i == 0 # rubocop:disable Lint/NumberConversion
139
+ def truncate(string, limit = nil)
140
+ return string if limit.to_i == 0
142
141
 
143
142
  helpers.truncate(
144
143
  string,
145
- length: limit,
146
- separator: natural_separator,
147
- omission: '',
148
- escape: true,
144
+ length: limit,
145
+ separator: MetaTags.config.truncate_on_natural_separator,
146
+ omission: "",
147
+ escape: true
149
148
  )
150
149
  end
151
150
 
@@ -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
 
@@ -188,14 +186,14 @@ module MetaTags
188
186
  end
189
187
 
190
188
  def truncate_title(site_title, title, separator)
191
- global_limit = MetaTags.config.title_limit.to_i # rubocop:disable Lint/NumberConversion
189
+ global_limit = MetaTags.config.title_limit.to_i
192
190
  if global_limit > 0
193
191
  site_title_limited_length, title_limited_length = calculate_title_limits(
194
- site_title, title, separator, global_limit,
192
+ site_title, title, separator, global_limit
195
193
  )
196
194
 
197
- title = title_limited_length > 0 ? truncate_array(title, title_limited_length, separator) : []
198
- site_title = site_title_limited_length > 0 ? truncate(site_title, site_title_limited_length) : nil
195
+ title = (title_limited_length > 0) ? truncate_array(title, title_limited_length, separator) : []
196
+ site_title = (site_title_limited_length > 0) ? truncate(site_title, site_title_limited_length) : nil
199
197
  end
200
198
 
201
199
  [site_title, title]
@@ -208,13 +206,13 @@ module MetaTags
208
206
  main_length = main_title.map(&:length).sum + ((main_title.size - 1) * separator.length)
209
207
  main_limited_length = global_limit
210
208
 
211
- secondary_limited_length = global_limit - (main_length > 0 ? main_length + separator.length : 0)
209
+ secondary_limited_length = global_limit - ((main_length > 0) ? main_length + separator.length : 0)
212
210
  secondary_limited_length = [0, secondary_limited_length].max
213
211
 
214
212
  if MetaTags.config.truncate_site_title_first
215
- [ secondary_limited_length, main_limited_length ]
213
+ [secondary_limited_length, main_limited_length]
216
214
  else
217
- [ main_limited_length, secondary_limited_length ]
215
+ [main_limited_length, secondary_limited_length]
218
216
  end
219
217
  end
220
218
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module MetaTags
4
4
  # Gem version.
5
- VERSION = '2.18.0'
5
+ VERSION = "2.20.0"
6
6
  public_constant :VERSION
7
7
  end
@@ -55,7 +55,7 @@ module MetaTags
55
55
  #
56
56
  # @see #display_meta_tags
57
57
  #
58
- def title(title = nil, headline = '')
58
+ def title(title = nil, headline = "")
59
59
  set_meta_tags(title: title) unless title.nil?
60
60
  headline.presence || meta_tags[:title]
61
61
  end
@@ -203,7 +203,7 @@ module MetaTags
203
203
  # <div data-page-container="true" title="<%= display_title title: 'My Page', site: 'PJAX Site' %>">
204
204
  #
205
205
  def display_title(defaults = {})
206
- @meta_tags.full_title(defaults)
206
+ meta_tags.full_title(defaults)
207
207
  end
208
208
  end
209
209
  end