metainspector 5.17.1 → 5.17.2
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/lib/meta_inspector/parsers/texts.rb +2 -2
- data/lib/meta_inspector/version.rb +1 -1
- data/meta_inspector.gemspec +1 -1
- data/spec/fixtures/author_in_link_with_empty_meta_author.response +23 -0
- data/spec/fixtures/title_in_head_with_empty_og_title.response +24 -0
- data/spec/meta_inspector/texts_spec.rb +10 -0
- data/spec/spec_helper.rb +2 -0
- metadata +5 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2e9605e47f410256715a5a3944362e203535eaa37603f1e8cfdf4f5a94d55890
|
|
4
|
+
data.tar.gz: 46cdbfdb7ecfa22091777a49f81f5bf261fed551ed624a7ea80d5c7c19c51008
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c0f771666159eda7086cfc912fa5db8bccf00924248da36483574198716ff527d558d106b53d08d0bb774e59db70a6225b9fe3441658a387eef170a239726007
|
|
7
|
+
data.tar.gz: ef0d3abdf02d14777c06fdc529e20f801e6c7a7061adf2230837d877d80b0f57b3cf010b1e745444f2df442971afc2bc78b4cf20c4a41742069be1b23d4f0b9e
|
|
@@ -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.
|
|
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.
|
|
103
|
+
candidates.find { |c| !c.to_s.empty? }
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
def find_best_description
|
data/meta_inspector.gemspec
CHANGED
|
@@ -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.
|
|
36
|
+
gem.add_development_dependency 'resolv', '~> 0.7.1'
|
|
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.
|
|
4
|
+
version: 5.17.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jaime Iniesta
|
|
@@ -273,14 +273,14 @@ dependencies:
|
|
|
273
273
|
requirements:
|
|
274
274
|
- - "~>"
|
|
275
275
|
- !ruby/object:Gem::Version
|
|
276
|
-
version: 0.
|
|
276
|
+
version: 0.7.1
|
|
277
277
|
type: :development
|
|
278
278
|
prerelease: false
|
|
279
279
|
version_requirements: !ruby/object:Gem::Requirement
|
|
280
280
|
requirements:
|
|
281
281
|
- - "~>"
|
|
282
282
|
- !ruby/object:Gem::Version
|
|
283
|
-
version: 0.
|
|
283
|
+
version: 0.7.1
|
|
284
284
|
- !ruby/object:Gem::Dependency
|
|
285
285
|
name: sinatra
|
|
286
286
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -344,6 +344,7 @@ files:
|
|
|
344
344
|
- spec/fixtures/alazan_websolution.response
|
|
345
345
|
- spec/fixtures/author_in_body.response
|
|
346
346
|
- spec/fixtures/author_in_link.response
|
|
347
|
+
- spec/fixtures/author_in_link_with_empty_meta_author.response
|
|
347
348
|
- spec/fixtures/author_in_meta.response
|
|
348
349
|
- spec/fixtures/author_in_twitter.response
|
|
349
350
|
- spec/fixtures/broken_head_links.response
|
|
@@ -394,6 +395,7 @@ files:
|
|
|
394
395
|
- spec/fixtures/title_in_body.response
|
|
395
396
|
- spec/fixtures/title_in_h1.response
|
|
396
397
|
- spec/fixtures/title_in_head.response
|
|
398
|
+
- spec/fixtures/title_in_head_with_empty_og_title.response
|
|
397
399
|
- spec/fixtures/title_in_head_with_whitespace.response
|
|
398
400
|
- spec/fixtures/title_not_present.response
|
|
399
401
|
- spec/fixtures/twitter_markupvalidator.response
|