aranha-parsers 0.8.2 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/aranha/parsers/base.rb +3 -1
- data/lib/aranha/parsers/json/base.rb +20 -0
- data/lib/aranha/parsers/json.rb +11 -0
- data/lib/aranha/parsers/rspec/setup.rb +2 -2
- data/lib/aranha/parsers/rspec/{source_target_fixtures_example.rb → shared_examples/source_target_fixtures.rb} +0 -0
- data/lib/aranha/parsers/source_address/fetch_content_error.rb +10 -0
- data/lib/aranha/parsers/source_address/http_get.rb +21 -2
- data/lib/aranha/parsers/version.rb +1 -1
- metadata +30 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb3631929ccd8b029ab5b097554f96f5eb0cc27dcf8767d3a8a97f050ee60b80
|
4
|
+
data.tar.gz: f30f306452ac72997887550051954d290f7e6c321b694236fd9f49bc6fff5d4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35ebd10ceebadd29ade03ef0c5a75ed024e8d4377b19295861d8ef4c4e3bb4e091df5ff9f74398f523c98e0e3ee65eac1352bedc39eae033000cdc8561c5b749
|
7
|
+
data.tar.gz: 68a7664bef2ffd163cf110f14779feb92305b90cfb6b23e8d254c4cf2ca6871233d64032704790dd30397383cc67fd5a5b5dc9e67a1d866f1365524707b5ebb5
|
data/lib/aranha/parsers/base.rb
CHANGED
@@ -11,7 +11,9 @@ module Aranha
|
|
11
11
|
class << self
|
12
12
|
def from_content(content)
|
13
13
|
::EacRubyUtils::Fs::Temp.on_file do |path|
|
14
|
-
path.
|
14
|
+
::File.open(path.to_s, 'w:UTF-8') do |f|
|
15
|
+
f.write content.force_encoding('UTF-8')
|
16
|
+
end
|
15
17
|
r = new(path.to_path)
|
16
18
|
r.content
|
17
19
|
r
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aranha/parsers/base'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module Aranha
|
7
|
+
module Parsers
|
8
|
+
module Json
|
9
|
+
class Base < ::Aranha::Parsers::Base
|
10
|
+
def data
|
11
|
+
default_data
|
12
|
+
end
|
13
|
+
|
14
|
+
def default_data
|
15
|
+
::JSON.parse(content)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -6,8 +6,8 @@ module Aranha
|
|
6
6
|
module Parsers
|
7
7
|
module Rspec
|
8
8
|
module Setup
|
9
|
-
def self.
|
10
|
-
require 'aranha/parsers/rspec/
|
9
|
+
def self.extended(_setup_obj)
|
10
|
+
require 'aranha/parsers/rspec/shared_examples/source_target_fixtures'
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
File without changes
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'addressable'
|
4
4
|
require 'curb'
|
5
|
+
require 'aranha/parsers/source_address/fetch_content_error'
|
5
6
|
|
6
7
|
module Aranha
|
7
8
|
module Parsers
|
@@ -31,18 +32,36 @@ module Aranha
|
|
31
32
|
source
|
32
33
|
end
|
33
34
|
|
35
|
+
def final_url
|
36
|
+
content unless @final_url
|
37
|
+
@final_url
|
38
|
+
end
|
39
|
+
|
34
40
|
def content
|
35
41
|
c = ::Curl::Easy.new(url)
|
36
42
|
c.follow_location = true
|
37
|
-
|
43
|
+
curl_perform(c)
|
38
44
|
return c.body_str if c.status.to_i == 200
|
39
45
|
|
40
|
-
raise
|
46
|
+
raise ::Aranha::Parsers::SourceAddress::FetchContentError,
|
47
|
+
"Get #{url} returned #{c.status.to_i}"
|
41
48
|
end
|
42
49
|
|
43
50
|
def serialize
|
44
51
|
url
|
45
52
|
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def curl_perform(curl)
|
57
|
+
unless curl.perform
|
58
|
+
raise(::Aranha::Parsers::SourceAddress::FetchContentError,
|
59
|
+
"Curl perform failed (URL: #{url})")
|
60
|
+
end
|
61
|
+
@final_url = curl.url
|
62
|
+
rescue Curl::Err::CurlError => e
|
63
|
+
raise ::Aranha::Parsers::SourceAddress::FetchContentError, "CURL error: #{e.class.name}"
|
64
|
+
end
|
46
65
|
end
|
47
66
|
end
|
48
67
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aranha-parsers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esquilo Azul Company
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0.
|
61
|
+
version: '0.74'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0.
|
68
|
+
version: '0.74'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: httpclient
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,6 +86,26 @@ dependencies:
|
|
86
86
|
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: 2.8.3
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: nokogiri
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '1.12'
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 1.12.4
|
99
|
+
type: :runtime
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - "~>"
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '1.12'
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: 1.12.4
|
89
109
|
- !ruby/object:Gem::Dependency
|
90
110
|
name: ofx-parser
|
91
111
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,7 +129,7 @@ dependencies:
|
|
109
129
|
version: '0.3'
|
110
130
|
- - ">="
|
111
131
|
- !ruby/object:Gem::Version
|
112
|
-
version: 0.3.
|
132
|
+
version: 0.3.3
|
113
133
|
type: :development
|
114
134
|
prerelease: false
|
115
135
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -119,7 +139,7 @@ dependencies:
|
|
119
139
|
version: '0.3'
|
120
140
|
- - ">="
|
121
141
|
- !ruby/object:Gem::Version
|
122
|
-
version: 0.3.
|
142
|
+
version: 0.3.3
|
123
143
|
description:
|
124
144
|
email:
|
125
145
|
executables: []
|
@@ -137,12 +157,15 @@ files:
|
|
137
157
|
- lib/aranha/parsers/html/node/base.rb
|
138
158
|
- lib/aranha/parsers/html/node/default.rb
|
139
159
|
- lib/aranha/parsers/invalid_state_exception.rb
|
160
|
+
- lib/aranha/parsers/json.rb
|
161
|
+
- lib/aranha/parsers/json/base.rb
|
140
162
|
- lib/aranha/parsers/patches.rb
|
141
163
|
- lib/aranha/parsers/patches/ofx_parser.rb
|
142
164
|
- lib/aranha/parsers/rspec.rb
|
143
165
|
- lib/aranha/parsers/rspec/setup.rb
|
144
|
-
- lib/aranha/parsers/rspec/
|
166
|
+
- lib/aranha/parsers/rspec/shared_examples/source_target_fixtures.rb
|
145
167
|
- lib/aranha/parsers/source_address.rb
|
168
|
+
- lib/aranha/parsers/source_address/fetch_content_error.rb
|
146
169
|
- lib/aranha/parsers/source_address/file.rb
|
147
170
|
- lib/aranha/parsers/source_address/hash_http_get.rb
|
148
171
|
- lib/aranha/parsers/source_address/hash_http_post.rb
|