pincers 0.7.6 → 0.7.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pincers/chenso/html_page_request.rb +10 -4
- data/lib/pincers/http/client.rb +1 -2
- data/lib/pincers/http/errors.rb +1 -1
- data/lib/pincers/http/{response_document.rb → response.rb} +10 -7
- data/lib/pincers/http/session.rb +5 -5
- data/lib/pincers/version.rb +1 -1
- metadata +3 -4
- data/lib/pincers/http/base_document.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6da332a1a2cd06206a29878abce0860c7dd9714a
|
4
|
+
data.tar.gz: 77a17252be6f58e1e76adcd04158c2ce94c3cbd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e34c26b569947c44307c280864268f6e7cbe855f35c9c265b188ef585a87d96e98b82973fc05230b679fbdbfb93c7a7bb9a95e688b55f7df4dd889ae0d5a34ec
|
7
|
+
data.tar.gz: 01c3d5999f23c5351a14aaeab86a516d11006f8f93ec963af24d6a5c39e655d9ea422c9808a949d10ab5a27acee83842feb0cd3e8dede0aff6e8c2aadbd7d7ca
|
@@ -33,12 +33,18 @@ module Pincers::Chenso
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def execute(_client)
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
response = begin
|
37
|
+
_client.send(@method, @uri) do |request|
|
38
|
+
request.headers.merge DEFAULT_HEADERS
|
39
|
+
request.set_form_data(@data, @encoding) unless @data.nil?
|
40
|
+
end
|
41
|
+
|
42
|
+
_client
|
43
|
+
rescue Pincers::Http::RequestError => exc
|
44
|
+
exc
|
39
45
|
end
|
40
46
|
|
41
|
-
BrowsingState.new
|
47
|
+
BrowsingState.new response.uri, ::Nokogiri::HTML(response.content)
|
42
48
|
end
|
43
49
|
end
|
44
50
|
end
|
data/lib/pincers/http/client.rb
CHANGED
@@ -4,7 +4,6 @@ require 'net/http'
|
|
4
4
|
require 'pincers/http/utils'
|
5
5
|
require 'pincers/http/session'
|
6
6
|
require 'pincers/http/request'
|
7
|
-
require 'pincers/http/response_document'
|
8
7
|
require 'pincers/http/errors'
|
9
8
|
|
10
9
|
module Pincers::Http
|
@@ -127,7 +126,7 @@ module Pincers::Http
|
|
127
126
|
|
128
127
|
def perform_in_session(_request)
|
129
128
|
begin
|
130
|
-
new_document =
|
129
|
+
new_document = @session.perform _request
|
131
130
|
rescue
|
132
131
|
@document = nil unless frozen
|
133
132
|
raise
|
data/lib/pincers/http/errors.rb
CHANGED
@@ -1,16 +1,19 @@
|
|
1
|
-
require 'pincers/http/base_document'
|
2
|
-
|
3
1
|
module Pincers::Http
|
4
|
-
class
|
2
|
+
class Response
|
5
3
|
|
6
|
-
attr_reader :response
|
4
|
+
attr_reader :uri, :response
|
7
5
|
|
8
|
-
def initialize(_response)
|
6
|
+
def initialize(_uri, _response)
|
9
7
|
@response = _response
|
8
|
+
@uri = _uri
|
9
|
+
end
|
10
|
+
|
11
|
+
def code
|
12
|
+
@response.code
|
10
13
|
end
|
11
14
|
|
12
|
-
def
|
13
|
-
@response.
|
15
|
+
def message
|
16
|
+
@response.message
|
14
17
|
end
|
15
18
|
|
16
19
|
def content_type
|
data/lib/pincers/http/session.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'pincers/http/errors'
|
2
2
|
require 'pincers/http/cookie_jar'
|
3
|
+
require 'pincers/http/response'
|
3
4
|
|
4
5
|
module Pincers::Http
|
5
6
|
class Session
|
@@ -66,15 +67,14 @@ module Pincers::Http
|
|
66
67
|
update_cookies(uri, http_response)
|
67
68
|
|
68
69
|
case http_response
|
69
|
-
when Net::HTTPSuccess
|
70
|
-
|
71
|
-
|
72
|
-
when Net::HTTPRedirection then
|
70
|
+
when Net::HTTPSuccess
|
71
|
+
Response.new(uri, http_response)
|
72
|
+
when Net::HTTPRedirection
|
73
73
|
location = Utils.parse_uri(http_response['location'])
|
74
74
|
location = URI.join(uri, location) if location.relative?
|
75
75
|
perform_recursive(_request, _limit - 1, location)
|
76
76
|
else
|
77
|
-
handle_error_response http_response
|
77
|
+
handle_error_response Response.new(uri, http_response)
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
data/lib/pincers/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pincers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ignacio Baixas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -252,13 +252,12 @@ files:
|
|
252
252
|
- lib/pincers/extension/labs.rb
|
253
253
|
- lib/pincers/extension/queries.rb
|
254
254
|
- lib/pincers/factory.rb
|
255
|
-
- lib/pincers/http/base_document.rb
|
256
255
|
- lib/pincers/http/client.rb
|
257
256
|
- lib/pincers/http/cookie.rb
|
258
257
|
- lib/pincers/http/cookie_jar.rb
|
259
258
|
- lib/pincers/http/errors.rb
|
260
259
|
- lib/pincers/http/request.rb
|
261
|
-
- lib/pincers/http/
|
260
|
+
- lib/pincers/http/response.rb
|
262
261
|
- lib/pincers/http/session.rb
|
263
262
|
- lib/pincers/http/utils.rb
|
264
263
|
- lib/pincers/nokogiri/backend.rb
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Pincers::Http
|
2
|
-
class BaseDocument
|
3
|
-
|
4
|
-
def uri
|
5
|
-
raise NotImplementedError
|
6
|
-
end
|
7
|
-
|
8
|
-
def content_type
|
9
|
-
raise NotImplementedError
|
10
|
-
end
|
11
|
-
|
12
|
-
def content
|
13
|
-
raise NotImplementedError
|
14
|
-
end
|
15
|
-
|
16
|
-
def save(_path)
|
17
|
-
File.write _path, content
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|