eac_rails_utils 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 +5 -5
- data/lib/eac/parsers/base.rb +14 -3
- data/lib/eac_rails_utils/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 92359094dd9193f30a276178f430b75878c97cbc08f09a57c0a2f0fa281d5314
|
4
|
+
data.tar.gz: 8b9abd7eb1dd2d09ff86bdb631ef5f75166b15db1d5ba1681c3bfb8e8972080c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec17e583b51e3160e23d39c0cb3898b22f227e9db72f7e26383adedab68bd1b735c0fc9fae83188b94afe168a04a543d489c00002d3496e0e81833bf4cb79014
|
7
|
+
data.tar.gz: 106a2660951190c7d0fe6f5d6560d36b807ba1b2fd224ea52d5b7ca3ab12a063708df3ad3ccfaf85723617087dcb7aca5520eade074cad3c79173da3b1848124
|
data/lib/eac/parsers/base.rb
CHANGED
@@ -43,19 +43,30 @@ module Eac
|
|
43
43
|
|
44
44
|
def content_get_fetch(uri, limit = 10)
|
45
45
|
raise 'too many HTTP redirects' if limit == 0
|
46
|
+
uri = Addressable::URI.parse(uri)
|
47
|
+
content_get_fetch_result(uri, limit, Net::HTTP.get_response(uri))
|
48
|
+
end
|
46
49
|
|
47
|
-
|
48
|
-
|
50
|
+
def content_get_fetch_result(uri, limit, response)
|
49
51
|
case response
|
50
52
|
when Net::HTTPSuccess then
|
51
53
|
response.body
|
52
54
|
when Net::HTTPRedirection then
|
53
|
-
|
55
|
+
content_get_fetch_redirect(uri, Addressable::URI.parse(response['location']), limit)
|
54
56
|
else
|
55
57
|
response.value
|
56
58
|
end
|
57
59
|
end
|
58
60
|
|
61
|
+
def content_get_fetch_redirect(original_uri, redirect_uri, limit)
|
62
|
+
if redirect_uri.scheme.blank?
|
63
|
+
redirect_uri.scheme = original_uri.scheme
|
64
|
+
redirect_uri.authority = original_uri.authority
|
65
|
+
end
|
66
|
+
Rails.logger.debug("#{original_uri} redirected to #{redirect_uri}")
|
67
|
+
content_get_fetch(redirect_uri, limit - 1)
|
68
|
+
end
|
69
|
+
|
59
70
|
def content_hash
|
60
71
|
return content_post if @url[:method] == :post
|
61
72
|
raise "Unknown URL format: #{@url}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eac_rails_utils
|
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
|
- E.A.C.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel-associations
|
@@ -237,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
237
237
|
version: '0'
|
238
238
|
requirements: []
|
239
239
|
rubyforge_project:
|
240
|
-
rubygems_version: 2.
|
240
|
+
rubygems_version: 2.7.7
|
241
241
|
signing_key:
|
242
242
|
specification_version: 4
|
243
243
|
summary: Código reutilizável para as aplicações Rails da E.A.C..
|