webinspector 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/web_inspector/page.rb +7 -14
- data/lib/web_inspector/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ad37cd905f72b0d7b6a9e12253b65dd2a48e94a
|
4
|
+
data.tar.gz: efddee40c1b9505a43b96085e2f7ff93dfb678ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e208ec285ed76abaaca8b16f8a76a1323343ace86ee44cd5bb23a94148468841c63e28e5dcc14d04f0dfae580019d2b92194311f4e34bdb0e7c5b56f3e06978
|
7
|
+
data.tar.gz: bbd316683c9ea289975ad12d7d039ace65e3ffca109d71c25f54f61347032729e775d93f29b4a3dd341d66d7ee8e7b32af0ca8c6708981d1d068088839c8425b
|
data/lib/web_inspector/page.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'nokogiri'
|
2
2
|
require 'uri'
|
3
|
-
require 'addressable/uri'
|
4
3
|
require 'open-uri'
|
5
4
|
require 'open_uri_redirections'
|
6
5
|
require 'faraday'
|
7
6
|
|
8
7
|
require File.expand_path(File.join(File.dirname(__FILE__), 'inspector'))
|
8
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'uri'))
|
9
9
|
|
10
10
|
module WebInspector
|
11
11
|
class Page
|
@@ -14,6 +14,7 @@ module WebInspector
|
|
14
14
|
def initialize(url, options = {})
|
15
15
|
@url = url
|
16
16
|
@options = options
|
17
|
+
@uri = WebInspector::Uri.new(url)
|
17
18
|
@inspector = WebInspector::Inspector.new(page)
|
18
19
|
end
|
19
20
|
|
@@ -38,19 +39,19 @@ module WebInspector
|
|
38
39
|
end
|
39
40
|
|
40
41
|
def url
|
41
|
-
|
42
|
+
@uri.url
|
42
43
|
end
|
43
44
|
|
44
45
|
def host
|
45
|
-
uri.host
|
46
|
+
@uri.host
|
46
47
|
end
|
47
48
|
|
48
49
|
def scheme
|
49
|
-
uri.scheme
|
50
|
+
@uri.scheme
|
50
51
|
end
|
51
52
|
|
52
53
|
def port
|
53
|
-
|
54
|
+
@uri.port
|
54
55
|
end
|
55
56
|
|
56
57
|
def to_hash
|
@@ -101,20 +102,12 @@ module WebInspector
|
|
101
102
|
response
|
102
103
|
end
|
103
104
|
|
104
|
-
def uri
|
105
|
-
Addressable::URI.parse(@url)
|
106
|
-
end
|
107
|
-
|
108
|
-
def normalized_uri
|
109
|
-
uri.normalize.to_s
|
110
|
-
end
|
111
|
-
|
112
105
|
def default_user_agent
|
113
106
|
"WebInspector/#{WebInspector::VERSION} (+https://github.com/davidesantangelo/webinspector)"
|
114
107
|
end
|
115
108
|
|
116
109
|
def page
|
117
|
-
Nokogiri::HTML(open(
|
110
|
+
Nokogiri::HTML(open(@uri.url, :allow_redirections => :safe))
|
118
111
|
end
|
119
112
|
end
|
120
113
|
end
|