eac_tools 0.69.0 → 0.70.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +38 -43
- data/lib/eac_tools/version.rb +1 -1
- data/sub/avm/avm.gemspec +3 -3
- data/sub/avm/lib/avm/entries/base/uri_components_entries_values/generic_component.rb +32 -6
- data/sub/avm/lib/avm/entries/base/uri_components_entries_values/url_component.rb +2 -2
- data/sub/avm/lib/avm/instances/base/entry_keys.rb +5 -0
- data/sub/avm/lib/avm/instances/base/processes.rb +27 -0
- data/sub/avm/lib/avm/instances/data/package.rb +4 -0
- data/sub/avm/lib/avm/instances/data/unit.rb +4 -0
- data/sub/avm/lib/avm/instances/process.rb +21 -0
- data/sub/avm/lib/avm/version.rb +1 -1
- data/sub/avm-eac_rails_base1/avm-eac_rails_base1.gemspec +4 -4
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/base.rb +6 -0
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/processes/daemon.rb +35 -0
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/processes/tasks_scheduler.rb +27 -0
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/instances/processes.rb +13 -0
- data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/version.rb +1 -1
- data/sub/avm-eac_ubuntu_base0/avm-eac_ubuntu_base0.gemspec +2 -2
- data/sub/avm-eac_ubuntu_base0/lib/avm/eac_ubuntu_base0/instances/base.rb +6 -0
- data/sub/avm-eac_ubuntu_base0/lib/avm/eac_ubuntu_base0/version.rb +1 -1
- data/sub/avm-eac_webapp_base0/avm-eac_webapp_base0.gemspec +3 -3
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/apache_base.rb +28 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/apache_host.rb +2 -10
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/apache_path.rb +2 -10
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/base/install.rb +22 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/base.rb +15 -1
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/processes/web_server.rb +33 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/processes.rb +13 -0
- data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/version.rb +1 -1
- data/sub/avm-eac_webapp_base0/spec/lib/avm/eac_webapp_base0/instances/base_spec.rb +11 -0
- data/sub/avm-eac_webapp_base0/spec/spec_helper.rb +1 -1
- data/sub/avm-tools/avm-tools.gemspec +1 -1
- data/sub/avm-tools/lib/avm/tools/runner/instance/data/load.rb +5 -0
- data/sub/avm-tools/lib/avm/tools/runner/instance/data/unit/load.rb +5 -0
- data/sub/avm-tools/lib/avm/tools/runner/instance/info.rb +1 -5
- data/sub/avm-tools/lib/avm/tools/runner_with/instance_data_load.rb +1 -1
- data/sub/avm-tools/lib/avm/tools/version.rb +1 -1
- data/sub/eac_cli/lib/eac_cli/runner/context.rb +5 -4
- data/sub/eac_cli/lib/eac_cli/version.rb +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +1 -1
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/yaml_spec.rb +2 -1
- metadata +30 -71
- data/sub/aranha-parsers/Gemfile +0 -8
- data/sub/aranha-parsers/aranha-parsers.gemspec +0 -23
- data/sub/aranha-parsers/lib/aranha/parsers/base.rb +0 -86
- data/sub/aranha-parsers/lib/aranha/parsers/html/base.rb +0 -61
- data/sub/aranha-parsers/lib/aranha/parsers/html/item.rb +0 -24
- data/sub/aranha-parsers/lib/aranha/parsers/html/item_list.rb +0 -33
- data/sub/aranha-parsers/lib/aranha/parsers/html/node/base.rb +0 -34
- data/sub/aranha-parsers/lib/aranha/parsers/html/node/default/numeric_support.rb +0 -129
- data/sub/aranha-parsers/lib/aranha/parsers/html/node/default/string_support.rb +0 -77
- data/sub/aranha-parsers/lib/aranha/parsers/html/node/default.rb +0 -43
- data/sub/aranha-parsers/lib/aranha/parsers/html/node.rb +0 -13
- data/sub/aranha-parsers/lib/aranha/parsers/html.rb +0 -11
- data/sub/aranha-parsers/lib/aranha/parsers/invalid_state_exception.rb +0 -8
- data/sub/aranha-parsers/lib/aranha/parsers/json/base.rb +0 -20
- data/sub/aranha-parsers/lib/aranha/parsers/json.rb +0 -11
- data/sub/aranha-parsers/lib/aranha/parsers/patches/ofx_parser.rb +0 -38
- data/sub/aranha-parsers/lib/aranha/parsers/patches.rb +0 -11
- data/sub/aranha-parsers/lib/aranha/parsers/rspec/setup.rb +0 -15
- data/sub/aranha-parsers/lib/aranha/parsers/rspec/shared_examples/source_target_fixtures.rb +0 -74
- data/sub/aranha-parsers/lib/aranha/parsers/rspec/source_target_fixtures_controller.rb +0 -39
- data/sub/aranha-parsers/lib/aranha/parsers/rspec.rb +0 -11
- data/sub/aranha-parsers/lib/aranha/parsers/source_address/fetch_content_error.rb +0 -16
- data/sub/aranha-parsers/lib/aranha/parsers/source_address/file.rb +0 -31
- data/sub/aranha-parsers/lib/aranha/parsers/source_address/hash_http_base.rb +0 -85
- data/sub/aranha-parsers/lib/aranha/parsers/source_address/hash_http_get.rb +0 -13
- data/sub/aranha-parsers/lib/aranha/parsers/source_address/hash_http_post.rb +0 -13
- data/sub/aranha-parsers/lib/aranha/parsers/source_address/http_get.rb +0 -54
- data/sub/aranha-parsers/lib/aranha/parsers/source_address.rb +0 -57
- data/sub/aranha-parsers/lib/aranha/parsers/source_target_fixtures/source_target_file.rb +0 -19
- data/sub/aranha-parsers/lib/aranha/parsers/source_target_fixtures.rb +0 -78
- data/sub/aranha-parsers/lib/aranha/parsers/version.rb +0 -7
- data/sub/aranha-parsers/lib/aranha/parsers.rb +0 -9
- data/sub/aranha-parsers/spec/lib/aranha/parsers/rspec/shared_examples/source_target_fixtures_spec.rb +0 -9
- data/sub/aranha-parsers/spec/lib/aranha/parsers/rspec/shared_examples/source_target_fixtures_spec_files/fixture1.source.txt +0 -1
- data/sub/aranha-parsers/spec/lib/aranha/parsers/rspec/shared_examples/source_target_fixtures_spec_files/fixture1.target.yaml +0 -3
- data/sub/aranha-parsers/spec/lib/aranha/parsers/source_address/detect_sub_spec.rb +0 -32
- data/sub/aranha-parsers/spec/lib/aranha/parsers/source_address/detect_sub_spec_files/hash_http_get.source.yml +0 -6
- data/sub/aranha-parsers/spec/lib/aranha/parsers/source_address/detect_sub_spec_files/hash_http_get.target.yaml +0 -10
- data/sub/aranha-parsers/spec/lib/aranha/parsers/source_address/detect_sub_spec_files/hash_http_post.source.yml +0 -5
- data/sub/aranha-parsers/spec/lib/aranha/parsers/source_address/detect_sub_spec_files/hash_http_post.target.yaml +0 -12
- data/sub/aranha-parsers/spec/lib/aranha/parsers/source_address/detect_sub_spec_files/http_get.source.yml +0 -1
- data/sub/aranha-parsers/spec/lib/aranha/parsers/source_address/detect_sub_spec_files/http_get.target.yaml +0 -10
- data/sub/aranha-parsers/spec/lib/aranha/parsers/source_address/http_get_spec.rb +0 -21
- data/sub/aranha-parsers/spec/lib/aranha/parsers/source_address_spec.rb +0 -74
- data/sub/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec.rb +0 -27
- data/sub/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub1.source.txt +0 -1
- data/sub/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub1.target.html +0 -1
- data/sub/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub2.source.html +0 -1
- data/sub/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub3.target.yaml +0 -1
- data/sub/aranha-parsers/spec/lib/rubocop_check_spec.rb +0 -3
- data/sub/aranha-parsers/spec/spec_helper.rb +0 -4
@@ -1,61 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'nokogiri'
|
4
|
-
require 'aranha/parsers/base'
|
5
|
-
require 'aranha/parsers/html/node/default'
|
6
|
-
|
7
|
-
module Aranha
|
8
|
-
module Parsers
|
9
|
-
module Html
|
10
|
-
class Base < ::Aranha::Parsers::Base
|
11
|
-
class << self
|
12
|
-
def fields
|
13
|
-
@fields ||= []
|
14
|
-
@fields.dup
|
15
|
-
end
|
16
|
-
|
17
|
-
def field(name, type, xpath)
|
18
|
-
@fields ||= []
|
19
|
-
@fields << Field.new(name, type, xpath)
|
20
|
-
end
|
21
|
-
|
22
|
-
# @param node [Nokogiri::XML::Node]
|
23
|
-
# @return [Aranha::Parsers::Html::Base]
|
24
|
-
def from_node(node)
|
25
|
-
from_string(node.to_html)
|
26
|
-
end
|
27
|
-
|
28
|
-
# @param haystack [String]
|
29
|
-
# @param needle [String]
|
30
|
-
# @return [String]
|
31
|
-
def xpath_ends_with(haystack, needle)
|
32
|
-
"substring(#{haystack}, string-length(#{haystack}) - string-length(#{needle}) + 1) " \
|
33
|
-
"= #{needle}"
|
34
|
-
end
|
35
|
-
|
36
|
-
Field = Struct.new(:name, :type, :xpath)
|
37
|
-
end
|
38
|
-
|
39
|
-
def nokogiri
|
40
|
-
@nokogiri ||= Nokogiri::HTML(content, &:noblanks)
|
41
|
-
end
|
42
|
-
|
43
|
-
protected
|
44
|
-
|
45
|
-
def node_parser_class
|
46
|
-
::Aranha::Parsers::Html::Node::Default
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
def node_parser
|
52
|
-
@node_parser ||= node_parser_class.new(fields)
|
53
|
-
end
|
54
|
-
|
55
|
-
def fields
|
56
|
-
self.class.fields.map { |f| [f.name, f.type, f.xpath] }
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'aranha/parsers/html/base'
|
4
|
-
|
5
|
-
module Aranha
|
6
|
-
module Parsers
|
7
|
-
module Html
|
8
|
-
class Item < Base
|
9
|
-
def data
|
10
|
-
@data ||= node_parser.parse(item_node)
|
11
|
-
end
|
12
|
-
|
13
|
-
def item_node
|
14
|
-
@item_node ||= begin
|
15
|
-
r = item_xpath ? nokogiri.at_xpath(item_xpath) : nokogiri
|
16
|
-
raise "Item node not found (Item xpath: #{item_xpath})" unless r
|
17
|
-
|
18
|
-
r
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'aranha/parsers/html/base'
|
4
|
-
|
5
|
-
module Aranha
|
6
|
-
module Parsers
|
7
|
-
module Html
|
8
|
-
class ItemList < Base
|
9
|
-
def data
|
10
|
-
items_data
|
11
|
-
end
|
12
|
-
|
13
|
-
def item_data(item)
|
14
|
-
item
|
15
|
-
end
|
16
|
-
|
17
|
-
def items_data
|
18
|
-
count = 0
|
19
|
-
@data ||= nokogiri.xpath(items_xpath).map do |m|
|
20
|
-
count += 1
|
21
|
-
item_data(node_parser.parse(m))
|
22
|
-
end
|
23
|
-
rescue StandardError => e
|
24
|
-
raise StandardError, "#{e.message} (Count: #{count})"
|
25
|
-
end
|
26
|
-
|
27
|
-
def items_xpath
|
28
|
-
raise "Class #{self.class} has no method \"#{__method__}\". Implement it"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Aranha
|
4
|
-
module Parsers
|
5
|
-
module Html
|
6
|
-
module Node
|
7
|
-
class Base
|
8
|
-
attr_reader :fields
|
9
|
-
|
10
|
-
def initialize(fields)
|
11
|
-
@fields = fields
|
12
|
-
end
|
13
|
-
|
14
|
-
def parse(node)
|
15
|
-
fields.map do |f|
|
16
|
-
[f[0], parse_field(node, f[2], f[1])]
|
17
|
-
rescue StandardError => e
|
18
|
-
raise StandardError, "#{e.message}\nFields: #{f}"
|
19
|
-
end.to_h
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def parse_field(node, xpath, parser_method)
|
25
|
-
value_method = "#{parser_method}_value"
|
26
|
-
return send(value_method, node, xpath) if respond_to?(value_method)
|
27
|
-
|
28
|
-
raise "Method \"#{value_method}\" not found in #{self.class}"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,129 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'aranha/parsers/html/node/base'
|
4
|
-
require 'eac_ruby_utils/core_ext'
|
5
|
-
|
6
|
-
module Aranha
|
7
|
-
module Parsers
|
8
|
-
module Html
|
9
|
-
module Node
|
10
|
-
class Default < ::Aranha::Parsers::Html::Node::Base
|
11
|
-
module NumericSupport
|
12
|
-
# @param node [Nokogiri::XML::Element]
|
13
|
-
# @param xpath [String]
|
14
|
-
# @return [Float]
|
15
|
-
def decimal_comma_value(node, xpath)
|
16
|
-
parse_decimal_comma(node, xpath, true)
|
17
|
-
end
|
18
|
-
|
19
|
-
# @param node [Nokogiri::XML::Element]
|
20
|
-
# @param xpath [String]
|
21
|
-
# @return [Float, nil]
|
22
|
-
def decimal_comma_optional_value(node, xpath)
|
23
|
-
parse_decimal_comma(node, xpath, false)
|
24
|
-
end
|
25
|
-
|
26
|
-
# @param node [Nokogiri::XML::Element]
|
27
|
-
# @param xpath [String]
|
28
|
-
# @return [Float]
|
29
|
-
def decimal_dot_value(node, xpath)
|
30
|
-
parse_decimal_dot(node, xpath, true)
|
31
|
-
end
|
32
|
-
|
33
|
-
# @param node [Nokogiri::XML::Element]
|
34
|
-
# @param xpath [String]
|
35
|
-
# @return [Float, nil]
|
36
|
-
def decimal_dot_optional_value(node, xpath)
|
37
|
-
parse_decimal_dot(node, xpath, false)
|
38
|
-
end
|
39
|
-
|
40
|
-
def integer_value(node, xpath)
|
41
|
-
r = string_value(node, xpath)
|
42
|
-
return nil if r.blank?
|
43
|
-
|
44
|
-
m = /\d+/.match(r)
|
45
|
-
raise "Integer not found in \"#{r}\"" unless m
|
46
|
-
|
47
|
-
m[0].to_i
|
48
|
-
end
|
49
|
-
|
50
|
-
def integer_optional_value(node, xpath)
|
51
|
-
r = string_value(node, xpath)
|
52
|
-
m = /\d+/.match(r)
|
53
|
-
m ? m[0].to_i : nil
|
54
|
-
end
|
55
|
-
|
56
|
-
def float_value(node, xpath)
|
57
|
-
parse_float(node, xpath, true)
|
58
|
-
end
|
59
|
-
|
60
|
-
def float_optional_value(node, xpath)
|
61
|
-
parse_float(node, xpath, false)
|
62
|
-
end
|
63
|
-
|
64
|
-
# @deprecated Use {#decimal_dot_value} instead.
|
65
|
-
# @param node [Nokogiri::XML::Element]
|
66
|
-
# @param xpath [String]
|
67
|
-
# @return [Float]
|
68
|
-
def us_decimal_value(node, xpath)
|
69
|
-
decimal_dot_value(node, xpath)
|
70
|
-
end
|
71
|
-
|
72
|
-
# @deprecated Use {#decimal_dot_optional_value} instead.
|
73
|
-
# @param node [Nokogiri::XML::Element]
|
74
|
-
# @param xpath [String]
|
75
|
-
# @return [Float, nil]
|
76
|
-
def us_decimal_optional_value(node, xpath)
|
77
|
-
decimal_dot_optional_value(node, xpath)
|
78
|
-
end
|
79
|
-
|
80
|
-
private
|
81
|
-
|
82
|
-
def parse_float(node, xpath, required)
|
83
|
-
s = string_value(node, xpath)
|
84
|
-
m = /\d+(?:[\.\,](\d+))?/.match(s)
|
85
|
-
if m
|
86
|
-
m[0].delete('.').tr(',', '.').to_f
|
87
|
-
elsif required
|
88
|
-
raise "Float value not found in \"#{s}\""
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
# @param node [Nokogiri::XML::Element]
|
93
|
-
# @param xpath [String]
|
94
|
-
# @param required [Boolean]
|
95
|
-
# @param separator [String]
|
96
|
-
# @param delimiter [String]
|
97
|
-
# @return [Float, nil]
|
98
|
-
def parse_decimal(node, xpath, required, separator, delimiter)
|
99
|
-
s = string_value(node, xpath)
|
100
|
-
m = /\d+(?:[#{::Regexp.quote(separator + delimiter)}](\d+))?/.match(s)
|
101
|
-
if m
|
102
|
-
m[0].delete(delimiter).to_f
|
103
|
-
elsif required
|
104
|
-
raise "decimal [Separator=\"#{separator}, Delimiter=\"#{delimiter}\"] value not " \
|
105
|
-
"found in \"#{s}\""
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
# @param node [Nokogiri::XML::Element]
|
110
|
-
# @param xpath [String]
|
111
|
-
# @param required [Boolean]
|
112
|
-
# @return [Float, nil]
|
113
|
-
def parse_decimal_dot(node, xpath, required)
|
114
|
-
parse_decimal(node, xpath, required, '.', ',')
|
115
|
-
end
|
116
|
-
|
117
|
-
# @param node [Nokogiri::XML::Element]
|
118
|
-
# @param xpath [String]
|
119
|
-
# @param required [Boolean]
|
120
|
-
# @return [Float, nil]
|
121
|
-
def parse_decimal_comma(node, xpath, required)
|
122
|
-
parse_decimal(node, xpath, required, ',', '.')
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'aranha/parsers/html/node/base'
|
4
|
-
require 'eac_ruby_utils/core_ext'
|
5
|
-
|
6
|
-
module Aranha
|
7
|
-
module Parsers
|
8
|
-
module Html
|
9
|
-
module Node
|
10
|
-
class Default < ::Aranha::Parsers::Html::Node::Base
|
11
|
-
module StringSupport
|
12
|
-
def quoted_value(node, xpath)
|
13
|
-
s = string_value(node, xpath)
|
14
|
-
return '' unless s
|
15
|
-
|
16
|
-
m = /\"([^\"]+)\"/.match(s)
|
17
|
-
return m[1] if m
|
18
|
-
|
19
|
-
''
|
20
|
-
end
|
21
|
-
|
22
|
-
def regxep(node, xpath, pattern)
|
23
|
-
s = string_value(node, xpath)
|
24
|
-
m = pattern.match(s)
|
25
|
-
return m if m
|
26
|
-
|
27
|
-
raise "Pattern \"#{pattern}\" not found in string \"#{s}\""
|
28
|
-
end
|
29
|
-
|
30
|
-
# @param node [Nokogiri::XML::Node]
|
31
|
-
# @param xpath [String]
|
32
|
-
# @return [String]
|
33
|
-
def string_value(node, xpath)
|
34
|
-
found = node_value(node, xpath)
|
35
|
-
found ? sanitize_string(found.text) : ''
|
36
|
-
end
|
37
|
-
|
38
|
-
def string_recursive_value(node, xpath, required = true)
|
39
|
-
root = node_value(node, xpath)
|
40
|
-
if root.blank?
|
41
|
-
return nil unless required
|
42
|
-
|
43
|
-
raise "No node found (Xpath: #{xpath})"
|
44
|
-
end
|
45
|
-
result = string_recursive(root)
|
46
|
-
return result if result.present?
|
47
|
-
return nil unless required
|
48
|
-
|
49
|
-
raise "String blank (Xpath: #{xpath})"
|
50
|
-
end
|
51
|
-
|
52
|
-
def string_recursive_optional_value(node, xpath)
|
53
|
-
string_recursive_value(node, xpath, false)
|
54
|
-
end
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
def sanitize_string(obj)
|
59
|
-
obj.to_s.tr("\u00A0", ' ').strip
|
60
|
-
end
|
61
|
-
|
62
|
-
def string_recursive(node)
|
63
|
-
return sanitize_string(node.text) if node.is_a?(::Nokogiri::XML::Text)
|
64
|
-
|
65
|
-
s = ''
|
66
|
-
node.children.each do |child|
|
67
|
-
child_s = string_recursive(child)
|
68
|
-
s += ' ' + child_s if child_s.present?
|
69
|
-
end
|
70
|
-
sanitize_string(s)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'aranha/parsers/html/node/base'
|
4
|
-
require 'eac_ruby_utils/core_ext'
|
5
|
-
|
6
|
-
module Aranha
|
7
|
-
module Parsers
|
8
|
-
module Html
|
9
|
-
module Node
|
10
|
-
class Default < ::Aranha::Parsers::Html::Node::Base
|
11
|
-
require_sub __FILE__, include_modules: true
|
12
|
-
|
13
|
-
def join_value(node, xpath)
|
14
|
-
m = ''
|
15
|
-
node_set_value(node, xpath).each do |n|
|
16
|
-
m << n.text.strip
|
17
|
-
end
|
18
|
-
m
|
19
|
-
end
|
20
|
-
|
21
|
-
def duration_value(node, xpath)
|
22
|
-
m = /(\d+) m/.match(join_value(node, xpath))
|
23
|
-
m ? m[1].to_i : nil
|
24
|
-
end
|
25
|
-
|
26
|
-
# @param node [Nokogiri::XML::Node]
|
27
|
-
# @param xpath [String]
|
28
|
-
# @return [Nokogiri::XML::NodeSet]
|
29
|
-
def node_set_value(node, xpath)
|
30
|
-
node.xpath(xpath)
|
31
|
-
end
|
32
|
-
|
33
|
-
# @param node [Nokogiri::XML::Node]
|
34
|
-
# @param xpath [String]
|
35
|
-
# @return [Nokogiri::XML::Node]
|
36
|
-
def node_value(node, xpath)
|
37
|
-
node.at_xpath(xpath)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,20 +0,0 @@
|
|
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
|
@@ -1,38 +0,0 @@
|
|
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 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
|
5
|
-
module Aranha
|
6
|
-
module Parsers
|
7
|
-
module Rspec
|
8
|
-
module Setup
|
9
|
-
def self.extended(_setup_obj)
|
10
|
-
require 'aranha/parsers/rspec/shared_examples/source_target_fixtures'
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'aranha/parsers/rspec/source_target_fixtures_controller'
|
4
|
-
require 'aranha/parsers/source_target_fixtures'
|
5
|
-
require 'yaml'
|
6
|
-
|
7
|
-
RSpec.shared_examples 'source_target_fixtures' do |spec_file| # rubocop:disable Metrics/BlockLength
|
8
|
-
fixtures_controller = ::Aranha::Parsers::Rspec::SourceTargetFixturesController
|
9
|
-
.new(self, spec_file)
|
10
|
-
|
11
|
-
let(:fixtures_controller) { fixtures_controller }
|
12
|
-
let(:spec_file) { spec_file }
|
13
|
-
|
14
|
-
it 'fixtures directory should exist' do
|
15
|
-
expect(::File.directory?(fixtures_controller.fixtures_dir)).to be true
|
16
|
-
end
|
17
|
-
|
18
|
-
context 'with fixtures directory' do
|
19
|
-
it 'has at least one file' do
|
20
|
-
expect(source_target_fixtures.source_target_files.count).to be > 0 # rubocop:disable Style/NumericPredicate
|
21
|
-
end
|
22
|
-
|
23
|
-
fixtures_controller.source_target_fixtures.source_target_files.each do |st|
|
24
|
-
context "when source file is \"#{::File.basename(st.source)}\"" do
|
25
|
-
if fixtures_controller.write_target_fixtures?
|
26
|
-
it 'writes target data' do
|
27
|
-
sd = sort_results(source_data(st.source))
|
28
|
-
basename = ::Aranha::Parsers::SourceTargetFixtures.source_target_basename(st.source)
|
29
|
-
target_file = File.expand_path("../#{basename}.target#{target_file_extname}", st.source)
|
30
|
-
File.write(target_file, target_content(sd))
|
31
|
-
end
|
32
|
-
else
|
33
|
-
it 'parses data' do
|
34
|
-
assert_source_target_complete(st)
|
35
|
-
sd = source_data(st.source)
|
36
|
-
td = target_data(st.target)
|
37
|
-
expect(sort_results(sd)).to eq(sort_results(td))
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
delegate :source_target_fixtures, to: :fixtures_controller
|
45
|
-
|
46
|
-
def assert_source_target_complete(source_target)
|
47
|
-
expect(source_target.source).to(be_truthy, "Source not found (Target: #{source_target.target})")
|
48
|
-
expect(source_target.target).to(be_truthy, "Target not found (Source: #{source_target.source})")
|
49
|
-
end
|
50
|
-
|
51
|
-
def source_data(source_file)
|
52
|
-
instance = described_class.new(source_file)
|
53
|
-
return instance.data if instance.respond_to?(:data)
|
54
|
-
|
55
|
-
raise "#{instance} has no \"data\" method. You need to implement \"#{instance}.data\" or " \
|
56
|
-
"\"#{self}.source_data(source_file)\""
|
57
|
-
end
|
58
|
-
|
59
|
-
def sort_results(results)
|
60
|
-
results
|
61
|
-
end
|
62
|
-
|
63
|
-
def target_data(target_file)
|
64
|
-
::YAML.load_file(target_file)
|
65
|
-
end
|
66
|
-
|
67
|
-
def target_content(data)
|
68
|
-
data.to_yaml
|
69
|
-
end
|
70
|
-
|
71
|
-
def target_file_extname
|
72
|
-
'.yaml'
|
73
|
-
end
|
74
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
|
5
|
-
module Aranha
|
6
|
-
module Parsers
|
7
|
-
module Rspec
|
8
|
-
class SourceTargetFixturesController
|
9
|
-
enable_simple_cache
|
10
|
-
common_constructor :example, :spec_file
|
11
|
-
|
12
|
-
def default_fixtures_dir
|
13
|
-
::File.join(
|
14
|
-
::File.dirname(spec_file),
|
15
|
-
::File.basename(spec_file, '.*') + '_files'
|
16
|
-
)
|
17
|
-
end
|
18
|
-
|
19
|
-
def fixtures_dir
|
20
|
-
if example.respond_to?(:fixtures_dir)
|
21
|
-
example.fixtures_dir
|
22
|
-
else
|
23
|
-
default_fixtures_dir
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def write_target_fixtures?
|
28
|
-
ENV['WRITE_TARGET_FIXTURES'].to_bool
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def source_target_fixtures_uncached
|
34
|
-
::Aranha::Parsers::SourceTargetFixtures.new(fixtures_dir)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Aranha
|
4
|
-
module Parsers
|
5
|
-
class SourceAddress
|
6
|
-
class FetchContentError < ::RuntimeError
|
7
|
-
attr_reader :request
|
8
|
-
|
9
|
-
def initialize(msg, request)
|
10
|
-
super(msg)
|
11
|
-
@request = request
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|