metainspector 5.17.1 → 5.17.3

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: cd87067f76c53378efc09102389b5d1274e137f96af734ff45ee2694843b3215
4
- data.tar.gz: 927bbf399454d988d2e2f683047c43b3405eaffcc43834d50cfdbcb64d583a71
3
+ metadata.gz: c1f6f69c4c45cfd382cf56438a16e3b17356b8b138a18d06587afd5362e01ab3
4
+ data.tar.gz: 423554e86d4162e84956924cde9936a2965e5999c2f52af3e9f38133c1b40198
5
5
  SHA512:
6
- metadata.gz: f9ef996e2a0618e92ec095a7f93ce7719309804e85ed2fff4fdf7d0074c60adaf1491169011252f3a45d14a6c1913baed8603b298d34f175eb8db79eff6f585f
7
- data.tar.gz: b0168e321f558f168a8243fc3078d0bc6f79f4485b3548011f479f12669b4754608b37491c646f3eacf50f50fc0a20b6efa583a5a038a6cb13cfed58472ecf36
6
+ metadata.gz: 2fb047c624d262317532c5688e26d02ac36eaa962b4c5fb76cc5b25950d9422262939048094b07850ec93a232e406d18ee8b0ddd46f039fa091524c9f119bb53
7
+ data.tar.gz: 1b5351860cb95bbf71f56549bc71b493481f32b1f2724c3f788d85e7b5591ad6745b475a31a3f064770fe9101817cef4620be566e91db16d6c05ebc08e61b888
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # MetaInspector Changelog
2
2
 
3
+ ## [Changes in 5.17.3](https://github.com/jaimeiniesta/metainspector/compare/v5.17.2...v5.17.3)
4
+
5
+ * Update faraday-http-cache requirement to allow 3.x.
6
+ * Update resolv to 0.8.
7
+
8
+ ## [Changes in 5.17.2](https://github.com/jaimeiniesta/metainspector/compare/v5.17.1...v5.17.2)
9
+
10
+ * Fix best title and author so empty strings are skipped.
11
+ * Update resolv.
12
+
3
13
  ## [Changes in 5.17.1](https://github.com/jaimeiniesta/metainspector/compare/v5.17.0...v5.17.1)
4
14
 
5
15
  * Upgrade addressable and puma dependencies
@@ -86,7 +86,7 @@ module MetaInspector
86
86
  candidates.compact!
87
87
  candidates.map! { |c| (c.respond_to? :inner_text) ? c.inner_text : c }
88
88
  candidates.map! { |c| c.strip.gsub(/\s+/, ' ') }
89
- candidates.first
89
+ candidates.find { |c| !c.to_s.empty? }
90
90
  end
91
91
 
92
92
  def find_best_author
@@ -100,7 +100,7 @@ module MetaInspector
100
100
  candidates.compact!
101
101
  candidates.map! { |c| (c.respond_to? :inner_text) ? c.inner_text : c }
102
102
  candidates.map! { |c| c.strip.gsub(/\s+/, ' ') }
103
- candidates.first
103
+ candidates.find { |c| !c.to_s.empty? }
104
104
  end
105
105
 
106
106
  def find_best_description
@@ -1,3 +1,3 @@
1
1
  module MetaInspector
2
- VERSION = '5.17.1'
2
+ VERSION = '5.17.3'
3
3
  end
@@ -20,7 +20,7 @@ Gem::Specification.new do |gem|
20
20
  gem.add_dependency 'faraday-encoding', '~> 0.0'
21
21
  gem.add_dependency 'faraday-follow_redirects', '~> 0.3'
22
22
  gem.add_dependency 'faraday-gzip', '>= 0.1', '< 4.0'
23
- gem.add_dependency 'faraday-http-cache', '~> 2.5'
23
+ gem.add_dependency 'faraday-http-cache', '>= 2.5', '< 4.0'
24
24
  gem.add_dependency 'faraday-retry', '~> 2.0'
25
25
  gem.add_dependency 'addressable', '~> 2.9.0'
26
26
  gem.add_dependency 'fastimage', '~> 2.2'
@@ -33,6 +33,6 @@ Gem::Specification.new do |gem|
33
33
  gem.add_development_dependency 'pry', '~> 0.14'
34
34
  gem.add_development_dependency 'puma', '~> 8.0.0'
35
35
  gem.add_development_dependency 'rubocop', '~> 1.34'
36
- gem.add_development_dependency 'resolv', '~> 0.6.2'
36
+ gem.add_development_dependency 'resolv', '~> 0.8.0'
37
37
  gem.add_development_dependency 'sinatra', '~> 4.2.0'
38
38
  end
@@ -0,0 +1,23 @@
1
+ HTTP/1.1 200 OK
2
+ Age: 13
3
+ Cache-Control: max-age=120
4
+ Content-Type: text/html
5
+ Date: Mon, 06 Jan 2014 12:47:42 GMT
6
+ Expires: Mon, 06 Jan 2014 12:49:28 GMT
7
+ Server: Apache/2.2.14 (Ubuntu)
8
+ Vary: Accept-Encoding
9
+ Via: 1.1 varnish
10
+ X-Powered-By: PHP/5.3.2-1ubuntu4.22
11
+ X-Varnish: 1188792404 1188790413
12
+ Content-Length: 320
13
+ Connection: keep-alive
14
+
15
+ <!DOCTYPE html>
16
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
17
+ <head>
18
+ <meta name="author" content="" />
19
+ </head>
20
+ <body>
21
+ <a rel="author">This author came from the link when the meta author was empty</a>
22
+ </body>
23
+ </html>
@@ -0,0 +1,24 @@
1
+ HTTP/1.1 200 OK
2
+ Age: 13
3
+ Cache-Control: max-age=120
4
+ Content-Type: text/html
5
+ Date: Mon, 06 Jan 2014 12:47:42 GMT
6
+ Expires: Mon, 06 Jan 2014 12:49:28 GMT
7
+ Server: Apache/2.2.14 (Ubuntu)
8
+ Vary: Accept-Encoding
9
+ Via: 1.1 varnish
10
+ X-Powered-By: PHP/5.3.2-1ubuntu4.22
11
+ X-Varnish: 1188792404 1188790413
12
+ Content-Length: 365
13
+ Connection: keep-alive
14
+
15
+ <!DOCTYPE html>
16
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
17
+ <head>
18
+ <title>This title came from the head when og:title was empty</title>
19
+ <meta property="og:title" content="" />
20
+ </head>
21
+ <body>
22
+ <p>A sample page with an empty og:title that should fall through to the head title</p>
23
+ </body>
24
+ </html>
@@ -79,6 +79,11 @@ describe MetaInspector do
79
79
  expect(page.best_title).to eq('This title came from the head and has leading and trailing whitespace')
80
80
  end
81
81
 
82
+ it "should skip empty candidates and fall back to the next one" do
83
+ page = MetaInspector.new('http://example.com/title_in_head_with_empty_og_title')
84
+ expect(page.best_title).to eq('This title came from the head when og:title was empty')
85
+ end
86
+
82
87
  it "should return nil if none of the candidates are present" do
83
88
  page = MetaInspector.new('http://example.com/title_not_present')
84
89
  expect(page.best_title).to be(nil)
@@ -122,6 +127,11 @@ describe MetaInspector do
122
127
  expect(page.best_author).to eq("This author came from the twitter creator tag")
123
128
  end
124
129
 
130
+ it "should skip empty candidates and fall back to the next one" do
131
+ page = MetaInspector.new('http://example.com/author_in_link_with_empty_meta_author')
132
+ expect(page.best_author).to eq("This author came from the link when the meta author was empty")
133
+ end
134
+
125
135
  it "should return nil if no author information present" do
126
136
  page = MetaInspector.new('http://example.com/empty')
127
137
 
data/spec/spec_helper.rb CHANGED
@@ -45,10 +45,12 @@ RSpec.configure do |config|
45
45
  stub_request(:get, "http://example.com/title_in_h1").to_return(fixture_file("title_in_h1.response"))
46
46
  stub_request(:get, "http://example.com/title_in_head").to_return(fixture_file("title_in_head.response"))
47
47
  stub_request(:get, "http://example.com/title_in_head_with_whitespace").to_return(fixture_file("title_in_head_with_whitespace.response"))
48
+ stub_request(:get, "http://example.com/title_in_head_with_empty_og_title").to_return(fixture_file("title_in_head_with_empty_og_title.response"))
48
49
  stub_request(:get, "http://example.com/title_not_present").to_return(fixture_file("title_not_present.response"))
49
50
  stub_request(:get, "http://example.com/author_in_meta").to_return(fixture_file("author_in_meta.response"))
50
51
  stub_request(:get, "http://example.com/author_in_body").to_return(fixture_file("author_in_body.response"))
51
52
  stub_request(:get, "http://example.com/author_in_link").to_return(fixture_file("author_in_link.response"))
53
+ stub_request(:get, "http://example.com/author_in_link_with_empty_meta_author").to_return(fixture_file("author_in_link_with_empty_meta_author.response"))
52
54
  stub_request(:get, "http://example.com/author_in_twitter").to_return(fixture_file("author_in_twitter.response"))
53
55
  stub_request(:get, "http://example.com/?name=joe martins").to_return(fixture_file("example.response"))
54
56
  stub_request(:get, "http://example.com/?name=joe+martins").to_return(fixture_file("example.response"))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metainspector
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.17.1
4
+ version: 5.17.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaime Iniesta
@@ -103,16 +103,22 @@ dependencies:
103
103
  name: faraday-http-cache
104
104
  requirement: !ruby/object:Gem::Requirement
105
105
  requirements:
106
- - - "~>"
106
+ - - ">="
107
107
  - !ruby/object:Gem::Version
108
108
  version: '2.5'
109
+ - - "<"
110
+ - !ruby/object:Gem::Version
111
+ version: '4.0'
109
112
  type: :runtime
110
113
  prerelease: false
111
114
  version_requirements: !ruby/object:Gem::Requirement
112
115
  requirements:
113
- - - "~>"
116
+ - - ">="
114
117
  - !ruby/object:Gem::Version
115
118
  version: '2.5'
119
+ - - "<"
120
+ - !ruby/object:Gem::Version
121
+ version: '4.0'
116
122
  - !ruby/object:Gem::Dependency
117
123
  name: faraday-retry
118
124
  requirement: !ruby/object:Gem::Requirement
@@ -273,14 +279,14 @@ dependencies:
273
279
  requirements:
274
280
  - - "~>"
275
281
  - !ruby/object:Gem::Version
276
- version: 0.6.2
282
+ version: 0.8.0
277
283
  type: :development
278
284
  prerelease: false
279
285
  version_requirements: !ruby/object:Gem::Requirement
280
286
  requirements:
281
287
  - - "~>"
282
288
  - !ruby/object:Gem::Version
283
- version: 0.6.2
289
+ version: 0.8.0
284
290
  - !ruby/object:Gem::Dependency
285
291
  name: sinatra
286
292
  requirement: !ruby/object:Gem::Requirement
@@ -344,6 +350,7 @@ files:
344
350
  - spec/fixtures/alazan_websolution.response
345
351
  - spec/fixtures/author_in_body.response
346
352
  - spec/fixtures/author_in_link.response
353
+ - spec/fixtures/author_in_link_with_empty_meta_author.response
347
354
  - spec/fixtures/author_in_meta.response
348
355
  - spec/fixtures/author_in_twitter.response
349
356
  - spec/fixtures/broken_head_links.response
@@ -394,6 +401,7 @@ files:
394
401
  - spec/fixtures/title_in_body.response
395
402
  - spec/fixtures/title_in_h1.response
396
403
  - spec/fixtures/title_in_head.response
404
+ - spec/fixtures/title_in_head_with_empty_og_title.response
397
405
  - spec/fixtures/title_in_head_with_whitespace.response
398
406
  - spec/fixtures/title_not_present.response
399
407
  - spec/fixtures/twitter_markupvalidator.response