webinspector 0.2.0 → 0.2.1
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/web_inspector/page.rb +7 -7
- data/lib/web_inspector/request.rb +35 -0
- data/lib/web_inspector/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab3cfc405792d46d5ad89038e2f81d4ae2d45793
|
4
|
+
data.tar.gz: 52958fc3132b4cb97e548ac6dd0b1187a3e95755
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01e3855519d7d01e264462950994c18096686566f8876cf1a18c23753a2a0ac33cf0611ddea9fb4a4a4012168ebb520c7e516387deb285589306943c55ddfbbc
|
7
|
+
data.tar.gz: a0b8c97245e009cc54865779c05597daa8ffee067d90d67d193c1d84ce5d446936720cd679b67f42fe98c164a5f1adbf26ee4fef73c16525cc5aad490b486d90
|
data/lib/web_inspector/page.rb
CHANGED
@@ -5,7 +5,7 @@ require 'open_uri_redirections'
|
|
5
5
|
require 'faraday'
|
6
6
|
|
7
7
|
require File.expand_path(File.join(File.dirname(__FILE__), 'inspector'))
|
8
|
-
require File.expand_path(File.join(File.dirname(__FILE__), '
|
8
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'request'))
|
9
9
|
|
10
10
|
module WebInspector
|
11
11
|
class Page
|
@@ -14,7 +14,7 @@ module WebInspector
|
|
14
14
|
def initialize(url, options = {})
|
15
15
|
@url = url
|
16
16
|
@options = options
|
17
|
-
@
|
17
|
+
@request = WebInspector::Request.new(url)
|
18
18
|
@inspector = WebInspector::Inspector.new(page)
|
19
19
|
end
|
20
20
|
|
@@ -39,19 +39,19 @@ module WebInspector
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def url
|
42
|
-
@
|
42
|
+
@request.url
|
43
43
|
end
|
44
44
|
|
45
45
|
def host
|
46
|
-
@
|
46
|
+
@request.host
|
47
47
|
end
|
48
48
|
|
49
49
|
def scheme
|
50
|
-
@
|
50
|
+
@request.scheme
|
51
51
|
end
|
52
52
|
|
53
53
|
def port
|
54
|
-
@
|
54
|
+
@request.port
|
55
55
|
end
|
56
56
|
|
57
57
|
def to_hash
|
@@ -107,7 +107,7 @@ module WebInspector
|
|
107
107
|
end
|
108
108
|
|
109
109
|
def page
|
110
|
-
Nokogiri::HTML(open(@
|
110
|
+
Nokogiri::HTML(open(@request.url, :allow_redirections => :safe))
|
111
111
|
end
|
112
112
|
end
|
113
113
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'addressable/uri'
|
2
|
+
|
3
|
+
module WebInspector
|
4
|
+
class Request
|
5
|
+
def initialize(url)
|
6
|
+
@url = url
|
7
|
+
end
|
8
|
+
|
9
|
+
def url
|
10
|
+
normalized_uri
|
11
|
+
end
|
12
|
+
|
13
|
+
def host
|
14
|
+
uri.host
|
15
|
+
end
|
16
|
+
|
17
|
+
def scheme
|
18
|
+
uri.scheme
|
19
|
+
end
|
20
|
+
|
21
|
+
def port
|
22
|
+
URI(normalized_uri).port
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def uri
|
28
|
+
Addressable::URI.parse(@url)
|
29
|
+
end
|
30
|
+
|
31
|
+
def normalized_uri
|
32
|
+
uri.normalize.to_s
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webinspector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Davide Santangelo
|
@@ -185,6 +185,7 @@ files:
|
|
185
185
|
- lib/web_inspector/inspector.rb
|
186
186
|
- lib/web_inspector/meta.rb
|
187
187
|
- lib/web_inspector/page.rb
|
188
|
+
- lib/web_inspector/request.rb
|
188
189
|
- lib/web_inspector/version.rb
|
189
190
|
- lib/webinspector.rb
|
190
191
|
- webinspector.gemspec
|