webinspector 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ad37cd905f72b0d7b6a9e12253b65dd2a48e94a
4
- data.tar.gz: efddee40c1b9505a43b96085e2f7ff93dfb678ea
3
+ metadata.gz: ab3cfc405792d46d5ad89038e2f81d4ae2d45793
4
+ data.tar.gz: 52958fc3132b4cb97e548ac6dd0b1187a3e95755
5
5
  SHA512:
6
- metadata.gz: 6e208ec285ed76abaaca8b16f8a76a1323343ace86ee44cd5bb23a94148468841c63e28e5dcc14d04f0dfae580019d2b92194311f4e34bdb0e7c5b56f3e06978
7
- data.tar.gz: bbd316683c9ea289975ad12d7d039ace65e3ffca109d71c25f54f61347032729e775d93f29b4a3dd341d66d7ee8e7b32af0ca8c6708981d1d068088839c8425b
6
+ metadata.gz: 01e3855519d7d01e264462950994c18096686566f8876cf1a18c23753a2a0ac33cf0611ddea9fb4a4a4012168ebb520c7e516387deb285589306943c55ddfbbc
7
+ data.tar.gz: a0b8c97245e009cc54865779c05597daa8ffee067d90d67d193c1d84ce5d446936720cd679b67f42fe98c164a5f1adbf26ee4fef73c16525cc5aad490b486d90
@@ -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__), 'uri'))
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
- @uri = WebInspector::Uri.new(url)
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
- @uri.url
42
+ @request.url
43
43
  end
44
44
 
45
45
  def host
46
- @uri.host
46
+ @request.host
47
47
  end
48
48
 
49
49
  def scheme
50
- @uri.scheme
50
+ @request.scheme
51
51
  end
52
52
 
53
53
  def port
54
- @uri.port
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(@uri.url, :allow_redirections => :safe))
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
@@ -1,3 +1,3 @@
1
1
  module WebInspector
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  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.0
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