aranha-parsers 0.4.0 → 0.7.1
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.rb +3 -5
- data/lib/aranha/parsers/base.rb +21 -3
- data/lib/aranha/parsers/html.rb +3 -4
- data/lib/aranha/parsers/html/node.rb +3 -2
- data/lib/aranha/parsers/patches.rb +11 -0
- data/lib/aranha/parsers/patches/ofx_parser.rb +38 -0
- data/lib/aranha/parsers/source_address.rb +4 -5
- data/lib/aranha/parsers/source_target_fixtures.rb +0 -1
- data/lib/aranha/parsers/spec/source_target_fixtures_example.rb +15 -3
- data/lib/aranha/parsers/version.rb +1 -1
- metadata +41 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b49b2b95850fa90b40ef009a9238577a17fefe5cbe49d23cb72be9be24e91546
|
4
|
+
data.tar.gz: 47b4f7becc2cba914955d7c37418fbab3048550fa99d9446a77b8c73d0e8a659
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82922c7b14bd371a8eca750edd40e1efbd95cdf4fc455262f7ee7a4125cd5e4341057187544f17253fdf91f6cf624addbbcd21682c303d39e0b8da2519249f49
|
7
|
+
data.tar.gz: 8ae0858f712dbcb477278df6a25f1e781453f522659ccd579ba90bcdb9a2a68f876fa137703ec7000fa624b72f23351ee363d9ca96c0569de7b9835a9a6561d0
|
data/lib/aranha/parsers.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'eac_ruby_utils/require_sub'
|
4
|
+
|
3
5
|
module Aranha
|
4
6
|
module Parsers
|
5
|
-
|
6
|
-
require 'aranha/parsers/html'
|
7
|
-
require 'aranha/parsers/invalid_state_exception'
|
8
|
-
require 'aranha/parsers/source_address'
|
9
|
-
require 'aranha/parsers/version'
|
7
|
+
::EacRubyUtils.require_sub __FILE__
|
10
8
|
end
|
11
9
|
end
|
data/lib/aranha/parsers/base.rb
CHANGED
@@ -3,10 +3,26 @@
|
|
3
3
|
require 'open-uri'
|
4
4
|
require 'fileutils'
|
5
5
|
require 'aranha/parsers/source_address'
|
6
|
+
require 'eac_ruby_utils/fs/temp'
|
6
7
|
|
7
8
|
module Aranha
|
8
9
|
module Parsers
|
9
10
|
class Base
|
11
|
+
class << self
|
12
|
+
def from_content(content)
|
13
|
+
::EacRubyUtils::Fs::Temp.on_file do |path|
|
14
|
+
path.write(content)
|
15
|
+
r = new(path.to_path)
|
16
|
+
r.content
|
17
|
+
r
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def parse_content(content)
|
22
|
+
from_content(content).data
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
10
26
|
LOG_DIR_ENVVAR = 'ARANHA_PARSERS_LOG_DIR'
|
11
27
|
|
12
28
|
attr_reader :source_address
|
@@ -19,9 +35,11 @@ module Aranha
|
|
19
35
|
delegate :url, to: :source_address
|
20
36
|
|
21
37
|
def content
|
22
|
-
|
23
|
-
|
24
|
-
|
38
|
+
@content ||= begin
|
39
|
+
s = source_address.content
|
40
|
+
log_content(s)
|
41
|
+
s
|
42
|
+
end
|
25
43
|
end
|
26
44
|
|
27
45
|
private
|
data/lib/aranha/parsers/html.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'eac_ruby_utils/require_sub'
|
4
|
+
|
3
5
|
module Aranha
|
4
6
|
module Parsers
|
5
7
|
module Html
|
6
|
-
|
7
|
-
require 'aranha/parsers/html/item'
|
8
|
-
require 'aranha/parsers/html/item_list'
|
9
|
-
require 'aranha/parsers/html/node'
|
8
|
+
::EacRubyUtils.require_sub __FILE__
|
10
9
|
end
|
11
10
|
end
|
12
11
|
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'eac_ruby_utils/require_sub'
|
4
|
+
|
3
5
|
module Aranha
|
4
6
|
module Parsers
|
5
7
|
module Html
|
6
8
|
module Node
|
7
|
-
|
8
|
-
require 'aranha/parsers/html/node/default'
|
9
|
+
::EacRubyUtils.require_sub __FILE__
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ofx-parser'
|
4
|
+
|
5
|
+
module Aranha
|
6
|
+
module Parsers
|
7
|
+
module Patches
|
8
|
+
module OfxParser
|
9
|
+
module OfxParser
|
10
|
+
def self.included(base)
|
11
|
+
base.class_eval do
|
12
|
+
class << self
|
13
|
+
prepend ClassMethods
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
module ClassMethods
|
19
|
+
def build_transaction(transaction)
|
20
|
+
r = super
|
21
|
+
r.currate = (transaction / 'CURRENCY/CURRATE').inner_text
|
22
|
+
r
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
module Transaction
|
28
|
+
attr_accessor :currate, :cursym
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'eac_ruby_utils/patch'
|
36
|
+
|
37
|
+
::EacRubyUtils.patch(::OfxParser::OfxParser, ::Aranha::Parsers::Patches::OfxParser::OfxParser)
|
38
|
+
::EacRubyUtils.patch(::OfxParser::Transaction, ::Aranha::Parsers::Patches::OfxParser::Transaction)
|
@@ -1,15 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'yaml'
|
4
3
|
require 'active_support/core_ext/module/delegation'
|
5
|
-
require '
|
6
|
-
require '
|
7
|
-
require 'aranha/parsers/source_address/http_get'
|
8
|
-
require 'aranha/parsers/source_address/file'
|
4
|
+
require 'eac_ruby_utils/require_sub'
|
5
|
+
require 'yaml'
|
9
6
|
|
10
7
|
module Aranha
|
11
8
|
module Parsers
|
12
9
|
class SourceAddress
|
10
|
+
::EacRubyUtils.require_sub __FILE__
|
11
|
+
|
13
12
|
class << self
|
14
13
|
SUBS = [
|
15
14
|
::Aranha::Parsers::SourceAddress::HashHttpGet,
|
@@ -20,8 +20,8 @@ RSpec.shared_examples 'source_target_fixtures' do |spec_file| # rubocop:disable
|
|
20
20
|
source_target_fixtures.source_files.each do |source_file|
|
21
21
|
sd = sort_results(source_data(source_file))
|
22
22
|
basename = ::Aranha::Parsers::SourceTargetFixtures.source_target_basename(source_file)
|
23
|
-
target_file = File.expand_path("../#{basename}.target
|
24
|
-
File.write(target_file, sd
|
23
|
+
target_file = File.expand_path("../#{basename}.target#{target_file_extname}", source_file)
|
24
|
+
File.write(target_file, target_content(sd))
|
25
25
|
end
|
26
26
|
end
|
27
27
|
else
|
@@ -46,7 +46,11 @@ RSpec.shared_examples 'source_target_fixtures' do |spec_file| # rubocop:disable
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def source_data(source_file)
|
49
|
-
described_class.new(source_file)
|
49
|
+
instance = described_class.new(source_file)
|
50
|
+
return instance.data if instance.respond_to?(:data)
|
51
|
+
|
52
|
+
raise "#{instance} has no \"data\" method. You need to implement \"#{instance}.data\" or " \
|
53
|
+
"\"#{self}.source_data(source_file)\""
|
50
54
|
end
|
51
55
|
|
52
56
|
def fixtures_dir
|
@@ -63,4 +67,12 @@ RSpec.shared_examples 'source_target_fixtures' do |spec_file| # rubocop:disable
|
|
63
67
|
def target_data(target_file)
|
64
68
|
::YAML.load_file(target_file)
|
65
69
|
end
|
70
|
+
|
71
|
+
def target_content(data)
|
72
|
+
data.to_yaml
|
73
|
+
end
|
74
|
+
|
75
|
+
def target_file_extname
|
76
|
+
'.yaml'
|
77
|
+
end
|
66
78
|
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.7.1
|
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:
|
11
|
+
date: 2021-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -52,6 +52,26 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.9.10
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: eac_ruby_utils
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.33'
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 0.33.1
|
65
|
+
type: :runtime
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - "~>"
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0.33'
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 0.33.1
|
55
75
|
- !ruby/object:Gem::Dependency
|
56
76
|
name: httpclient
|
57
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,20 +92,34 @@ dependencies:
|
|
72
92
|
- - ">="
|
73
93
|
- !ruby/object:Gem::Version
|
74
94
|
version: 2.8.3
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: ofx-parser
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.1.0
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - "~>"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: 1.1.0
|
75
109
|
- !ruby/object:Gem::Dependency
|
76
110
|
name: eac_ruby_gem_support
|
77
111
|
requirement: !ruby/object:Gem::Requirement
|
78
112
|
requirements:
|
79
113
|
- - "~>"
|
80
114
|
- !ruby/object:Gem::Version
|
81
|
-
version: '0.
|
115
|
+
version: '0.2'
|
82
116
|
type: :development
|
83
117
|
prerelease: false
|
84
118
|
version_requirements: !ruby/object:Gem::Requirement
|
85
119
|
requirements:
|
86
120
|
- - "~>"
|
87
121
|
- !ruby/object:Gem::Version
|
88
|
-
version: '0.
|
122
|
+
version: '0.2'
|
89
123
|
description:
|
90
124
|
email:
|
91
125
|
executables: []
|
@@ -103,6 +137,8 @@ files:
|
|
103
137
|
- lib/aranha/parsers/html/node/base.rb
|
104
138
|
- lib/aranha/parsers/html/node/default.rb
|
105
139
|
- lib/aranha/parsers/invalid_state_exception.rb
|
140
|
+
- lib/aranha/parsers/patches.rb
|
141
|
+
- lib/aranha/parsers/patches/ofx_parser.rb
|
106
142
|
- lib/aranha/parsers/source_address.rb
|
107
143
|
- lib/aranha/parsers/source_address/file.rb
|
108
144
|
- lib/aranha/parsers/source_address/hash_http_get.rb
|
@@ -129,8 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
165
|
- !ruby/object:Gem::Version
|
130
166
|
version: '0'
|
131
167
|
requirements: []
|
132
|
-
|
133
|
-
rubygems_version: 2.7.7
|
168
|
+
rubygems_version: 3.0.9
|
134
169
|
signing_key:
|
135
170
|
specification_version: 4
|
136
171
|
summary: Parsers' utilities for Ruby.
|