metainspector 1.17.1 → 1.17.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/meta_inspector/parser.rb +11 -6
- data/lib/meta_inspector/request.rb +1 -1
- data/lib/meta_inspector/version.rb +1 -1
- data/meta_inspector.gemspec +6 -6
- data/spec/redirections_spec.rb +8 -10
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d1795a40750fba9db895d1ab321f54d94349a38
|
4
|
+
data.tar.gz: 0648ba0471516d9a6e33a9439972619d51580ff7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4c8859c52e9f424cf08c72b8f3515dede0f678ac87bcc2331a8e543fa1a839912c0fd85f2b5c56069990cd270dd5db8c2761ac2a3dce6d5929ba906b3692856
|
7
|
+
data.tar.gz: 61217d3d51e81e892f6750f8d24379ea75a80d9e7d07c2408d6c762786e5c088a14996674ed2cb070a5e532c9286e406e55832398c5bb842f4bd51497fcc1674
|
@@ -121,7 +121,7 @@ module MetaInspector
|
|
121
121
|
unless @data.meta
|
122
122
|
@data.meta!.name!
|
123
123
|
@data.meta!.property!
|
124
|
-
|
124
|
+
parsed_search("//meta").each do |element|
|
125
125
|
get_meta_name_or_property(element)
|
126
126
|
end
|
127
127
|
end
|
@@ -139,20 +139,20 @@ module MetaInspector
|
|
139
139
|
|
140
140
|
# Look for the first <p> block with 120 characters or more
|
141
141
|
def secondary_description
|
142
|
-
first_long_paragraph =
|
142
|
+
first_long_paragraph = parsed_search('//p[string-length() >= 120]').first
|
143
143
|
first_long_paragraph ? first_long_paragraph.text : ''
|
144
144
|
end
|
145
145
|
|
146
146
|
def parsed_links
|
147
|
-
@parsed_links ||= cleanup_nokogiri_values(
|
147
|
+
@parsed_links ||= cleanup_nokogiri_values(parsed_search("//a/@href"))
|
148
148
|
end
|
149
149
|
|
150
150
|
def parsed_images
|
151
|
-
@parsed_images ||= cleanup_nokogiri_values(
|
151
|
+
@parsed_images ||= cleanup_nokogiri_values(parsed_search('//img/@src'))
|
152
152
|
end
|
153
153
|
|
154
154
|
def parsed_feed(format)
|
155
|
-
feed =
|
155
|
+
feed = parsed_search("//link[@type='application/#{format}+xml']").first
|
156
156
|
feed ? URL.absolutify(feed.attributes['href'].value, base_url) : nil
|
157
157
|
end
|
158
158
|
|
@@ -172,12 +172,17 @@ module MetaInspector
|
|
172
172
|
|
173
173
|
# Returns the value of the href attribute on the <base /> tag, if it exists
|
174
174
|
def base_href
|
175
|
-
|
175
|
+
parsed_search('base').first.attributes['href'].value rescue nil
|
176
176
|
end
|
177
177
|
|
178
178
|
# Takes a nokogiri search result, strips the values, rejects the empty ones, and removes duplicates
|
179
179
|
def cleanup_nokogiri_values(results)
|
180
180
|
results.map { |a| a.value.strip }.reject { |s| s.empty? }.uniq
|
181
181
|
end
|
182
|
+
|
183
|
+
# Searches the parsed document for the selector, if the parsed document is searchable
|
184
|
+
def parsed_search(selector)
|
185
|
+
parsed.respond_to?(:search) ? parsed.search(selector) : []
|
186
|
+
end
|
182
187
|
end
|
183
188
|
end
|
data/meta_inspector.gemspec
CHANGED
@@ -15,13 +15,13 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = MetaInspector::VERSION
|
17
17
|
|
18
|
-
gem.add_dependency 'nokogiri', '~> 1.
|
18
|
+
gem.add_dependency 'nokogiri', '~> 1.6'
|
19
19
|
gem.add_dependency 'rash', '~> 0.4.0'
|
20
|
-
gem.add_dependency 'open_uri_redirections', '~> 0.1.
|
21
|
-
gem.add_dependency 'addressable', '~> 2.3.
|
20
|
+
gem.add_dependency 'open_uri_redirections', '~> 0.1.4'
|
21
|
+
gem.add_dependency 'addressable', '~> 2.3.5'
|
22
22
|
|
23
|
-
gem.add_development_dependency 'rspec', '2.
|
23
|
+
gem.add_development_dependency 'rspec', '2.14.1'
|
24
24
|
gem.add_development_dependency 'fakeweb', '1.3.0'
|
25
|
-
gem.add_development_dependency 'awesome_print', '1.
|
26
|
-
gem.add_development_dependency 'rake', '~> 10.0
|
25
|
+
gem.add_development_dependency 'awesome_print', '~> 1.2.0'
|
26
|
+
gem.add_development_dependency 'rake', '~> 10.1.0'
|
27
27
|
end
|
data/spec/redirections_spec.rb
CHANGED
@@ -7,20 +7,20 @@ describe MetaInspector do
|
|
7
7
|
describe "safe redirections (HTTP to HTTPS)" do
|
8
8
|
it "disallows safe redirections by default" do
|
9
9
|
m = MetaInspector.new("http://facebook.com")
|
10
|
-
m.
|
10
|
+
m.to_hash
|
11
11
|
m.should_not be_ok
|
12
12
|
m.exceptions.first.message.should == "redirection forbidden: http://facebook.com/ -> https://www.facebook.com/"
|
13
13
|
end
|
14
14
|
|
15
15
|
it "allows safe redirections when :allow_redirections => :safe" do
|
16
16
|
m = MetaInspector.new("http://facebook.com", :allow_redirections => :safe)
|
17
|
-
m.
|
17
|
+
m.to_hash
|
18
18
|
m.should be_ok
|
19
19
|
end
|
20
20
|
|
21
21
|
it "allows safe redirections when :allow_redirections => :all" do
|
22
22
|
m = MetaInspector.new("http://facebook.com", :allow_redirections => :all)
|
23
|
-
m.
|
23
|
+
m.to_hash
|
24
24
|
m.should be_ok
|
25
25
|
end
|
26
26
|
end
|
@@ -28,21 +28,21 @@ describe MetaInspector do
|
|
28
28
|
describe "unsafe redirections (HTTPS to HTTP)" do
|
29
29
|
it "disallows unsafe redirections by default" do
|
30
30
|
m = MetaInspector.new("https://unsafe-facebook.com")
|
31
|
-
m.
|
31
|
+
m.to_hash
|
32
32
|
m.should_not be_ok
|
33
33
|
m.exceptions.first.message.should == "redirection forbidden: https://unsafe-facebook.com/ -> http://unsafe-facebook.com/"
|
34
34
|
end
|
35
35
|
|
36
36
|
it "disallows unsafe redirections when :allow_redirections => :safe" do
|
37
37
|
m = MetaInspector.new("https://unsafe-facebook.com", :allow_redirections => :safe)
|
38
|
-
m.
|
38
|
+
m.to_hash
|
39
39
|
m.should_not be_ok
|
40
40
|
m.exceptions.first.message.should == "redirection forbidden: https://unsafe-facebook.com/ -> http://unsafe-facebook.com/"
|
41
41
|
end
|
42
42
|
|
43
43
|
it "allows unsafe redirections when :allow_redirections => :all" do
|
44
44
|
m = MetaInspector.new("https://unsafe-facebook.com", :allow_redirections => :all)
|
45
|
-
m.
|
45
|
+
m.to_hash
|
46
46
|
m.should be_ok
|
47
47
|
end
|
48
48
|
end
|
@@ -50,15 +50,13 @@ describe MetaInspector do
|
|
50
50
|
describe "Redirections should update the base_uri" do
|
51
51
|
it "updates the base_uri on safe redirections" do
|
52
52
|
m = MetaInspector.new("http://facebook.com", :allow_redirections => :safe)
|
53
|
-
|
54
|
-
m.title.should == "Hello From Facebook"
|
53
|
+
m.to_hash
|
55
54
|
m.url.should == "https://www.facebook.com/"
|
56
55
|
end
|
57
56
|
|
58
57
|
it "updates the base_uri on all redirections" do
|
59
58
|
m = MetaInspector.new("http://facebook.com", :allow_redirections => :all)
|
60
|
-
|
61
|
-
m.title.should == "Hello From Facebook"
|
59
|
+
m.to_hash
|
62
60
|
|
63
61
|
m.url.should == "https://www.facebook.com/"
|
64
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metainspector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.17.
|
4
|
+
version: 1.17.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jaime Iniesta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rash
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,42 +44,42 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.1.
|
47
|
+
version: 0.1.4
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.1.
|
54
|
+
version: 0.1.4
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: addressable
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.3.
|
61
|
+
version: 2.3.5
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.3.
|
68
|
+
version: 2.3.5
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 2.
|
75
|
+
version: 2.14.1
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 2.
|
82
|
+
version: 2.14.1
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: fakeweb
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,30 +98,30 @@ dependencies:
|
|
98
98
|
name: awesome_print
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ~>
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 1.
|
103
|
+
version: 1.2.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ~>
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 1.
|
110
|
+
version: 1.2.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rake
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - ~>
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 10.0
|
117
|
+
version: 10.1.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - ~>
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 10.0
|
124
|
+
version: 10.1.0
|
125
125
|
description: MetaInspector lets you scrape a web page and get its title, charset,
|
126
126
|
link and meta tags
|
127
127
|
email:
|