ehbrs-tools 0.16.0 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ehbrs/tools/version.rb +1 -1
- data/lib/ehbrs/vg/wii/wit/parsers/dump.rb +10 -5
- data/vendor/aranha-parsers/Gemfile +5 -0
- data/vendor/aranha-parsers/aranha-parsers.gemspec +23 -0
- data/vendor/aranha-parsers/lib/aranha/parsers.rb +9 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/base.rb +79 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/html.rb +11 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/html/base.rb +47 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/html/item.rb +24 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/html/item_list.rb +29 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/html/node.rb +13 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/html/node/base.rb +36 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/html/node/default.rb +126 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/invalid_state_exception.rb +8 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/patches.rb +11 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/patches/ofx_parser.rb +38 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/source_address.rb +55 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/source_address/file.rb +31 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/source_address/hash_http_get.rb +25 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/source_address/hash_http_post.rb +45 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/source_address/http_get.rb +49 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/source_target_fixtures.rb +77 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/spec/source_target_fixtures_example.rb +70 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/version.rb +7 -0
- data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_address/http_get_spec.rb +21 -0
- data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_address_spec.rb +74 -0
- data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec.rb +27 -0
- data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub1.source.txt +1 -0
- data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub1.target.html +1 -0
- data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub2.source.html +1 -0
- data/vendor/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub3.target.yaml +1 -0
- data/vendor/aranha-parsers/spec/lib/rubocop_check_spec.rb +7 -0
- data/vendor/aranha-parsers/spec/spec_helper.rb +8 -0
- data/vendor/eac_cli/lib/eac_cli/definition.rb +14 -4
- data/vendor/eac_cli/lib/eac_cli/definition/help_formatter.rb +76 -0
- data/vendor/eac_cli/lib/eac_cli/definition/positional_argument.rb +15 -2
- data/vendor/eac_cli/lib/eac_cli/parser/options_collection.rb +4 -63
- data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs.rb +4 -69
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/entry_reader.rb +81 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/password_entry_reader.rb +18 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb +7 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/store_passwords_entry_reader.rb +27 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/debug.rb +17 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- metadata +38 -2
@@ -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)
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/module/delegation'
|
4
|
+
require 'eac_ruby_utils/require_sub'
|
5
|
+
require 'yaml'
|
6
|
+
|
7
|
+
module Aranha
|
8
|
+
module Parsers
|
9
|
+
class SourceAddress
|
10
|
+
::EacRubyUtils.require_sub __FILE__
|
11
|
+
|
12
|
+
class << self
|
13
|
+
SUBS = [
|
14
|
+
::Aranha::Parsers::SourceAddress::HashHttpGet,
|
15
|
+
::Aranha::Parsers::SourceAddress::HashHttpPost,
|
16
|
+
::Aranha::Parsers::SourceAddress::HttpGet,
|
17
|
+
::Aranha::Parsers::SourceAddress::File
|
18
|
+
].freeze
|
19
|
+
|
20
|
+
def detect_sub(source)
|
21
|
+
return source.sub if source.is_a?(self)
|
22
|
+
|
23
|
+
SUBS.each do |sub|
|
24
|
+
return sub.new(source) if sub.valid_source?(source)
|
25
|
+
end
|
26
|
+
raise "No content fetcher found for source \"#{source}\""
|
27
|
+
end
|
28
|
+
|
29
|
+
def deserialize(string)
|
30
|
+
new(string =~ %r{\A[a-z]+://} ? string.strip : ::YAML.load(string)) # rubocop:disable Security/YAMLLoad
|
31
|
+
end
|
32
|
+
|
33
|
+
def from_file(path)
|
34
|
+
deserialize(::File.read(path))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
attr_reader :sub
|
39
|
+
|
40
|
+
def initialize(source)
|
41
|
+
@sub = self.class.detect_sub(source)
|
42
|
+
end
|
43
|
+
|
44
|
+
delegate :content, :url, to: :sub
|
45
|
+
|
46
|
+
def to_s
|
47
|
+
sub.url
|
48
|
+
end
|
49
|
+
|
50
|
+
def serialize
|
51
|
+
sub.serialize.strip + "\n"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aranha/parsers/source_address/http_get'
|
4
|
+
|
5
|
+
module Aranha
|
6
|
+
module Parsers
|
7
|
+
class SourceAddress
|
8
|
+
class File < ::Aranha::Parsers::SourceAddress::HttpGet
|
9
|
+
SCHEME = 'file://'
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def valid_source?(source)
|
13
|
+
source.to_s.start_with?(SCHEME + '/', '/')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(source)
|
18
|
+
super source.to_s.gsub(/\A#{Regexp.quote(SCHEME)}/, '')
|
19
|
+
end
|
20
|
+
|
21
|
+
def url
|
22
|
+
"#{SCHEME}#{source}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def content
|
26
|
+
::File.open(source, &:read)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aranha/parsers/source_address/hash_http_post'
|
4
|
+
|
5
|
+
module Aranha
|
6
|
+
module Parsers
|
7
|
+
class SourceAddress
|
8
|
+
class HashHttpGet < ::Aranha::Parsers::SourceAddress::HashHttpPost
|
9
|
+
class << self
|
10
|
+
def valid_source?(source)
|
11
|
+
source.is_a?(::Hash) &&
|
12
|
+
source.with_indifferent_access[:method].to_s.downcase.strip == 'get'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def content
|
17
|
+
HTTPClient.new.get_content(
|
18
|
+
source[:url],
|
19
|
+
source[:params]
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/hash/indifferent_access'
|
4
|
+
require 'httpclient'
|
5
|
+
require 'yaml'
|
6
|
+
|
7
|
+
module Aranha
|
8
|
+
module Parsers
|
9
|
+
class SourceAddress
|
10
|
+
class HashHttpPost
|
11
|
+
class << self
|
12
|
+
def valid_source?(source)
|
13
|
+
source.is_a?(::Hash) &&
|
14
|
+
source.with_indifferent_access[:method].to_s.downcase.strip == 'post'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
attr_reader :source
|
19
|
+
|
20
|
+
def initialize(source)
|
21
|
+
@source = source.with_indifferent_access
|
22
|
+
end
|
23
|
+
|
24
|
+
def ==(other)
|
25
|
+
self.class == other.class && source == other.source
|
26
|
+
end
|
27
|
+
|
28
|
+
def url
|
29
|
+
source.fetch(:url)
|
30
|
+
end
|
31
|
+
|
32
|
+
def serialize
|
33
|
+
source.to_yaml
|
34
|
+
end
|
35
|
+
|
36
|
+
def content
|
37
|
+
HTTPClient.new.post_content(
|
38
|
+
source[:url],
|
39
|
+
source[:params].merge(follow_redirect: true)
|
40
|
+
)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'addressable'
|
4
|
+
require 'curb'
|
5
|
+
|
6
|
+
module Aranha
|
7
|
+
module Parsers
|
8
|
+
class SourceAddress
|
9
|
+
class HttpGet
|
10
|
+
class << self
|
11
|
+
def location_uri(source_uri, location)
|
12
|
+
::Addressable::URI.join(source_uri, location).to_s
|
13
|
+
end
|
14
|
+
|
15
|
+
def valid_source?(source)
|
16
|
+
source.to_s =~ %r{\Ahttps?://}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_reader :source
|
21
|
+
|
22
|
+
def initialize(source)
|
23
|
+
@source = source.to_s
|
24
|
+
end
|
25
|
+
|
26
|
+
def ==(other)
|
27
|
+
self.class == other.class && source == other.source
|
28
|
+
end
|
29
|
+
|
30
|
+
def url
|
31
|
+
source
|
32
|
+
end
|
33
|
+
|
34
|
+
def content
|
35
|
+
c = ::Curl::Easy.new(url)
|
36
|
+
c.follow_location = true
|
37
|
+
raise "Curl perform failed (URL: #{url})" unless c.perform
|
38
|
+
return c.body_str if c.status.to_i == 200
|
39
|
+
|
40
|
+
raise "Get #{url} returned #{c.status.to_i}"
|
41
|
+
end
|
42
|
+
|
43
|
+
def serialize
|
44
|
+
url
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/object'
|
4
|
+
require 'active_support/core_ext/string'
|
5
|
+
|
6
|
+
module Aranha
|
7
|
+
module Parsers
|
8
|
+
# Lists pairs of source/target files in a directory.
|
9
|
+
class SourceTargetFixtures
|
10
|
+
class << self
|
11
|
+
def source_target_basename(file)
|
12
|
+
m = /^(.+)\.(?:source|target)(?:\..+)?$/.match(File.basename(file))
|
13
|
+
m ? m[1] : nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
attr_reader :fixtures_directory
|
18
|
+
|
19
|
+
def initialize(fixtures_directory)
|
20
|
+
@fixtures_directory = fixtures_directory
|
21
|
+
end
|
22
|
+
|
23
|
+
def source_target_files
|
24
|
+
sources_targets_basenames.map do |basename|
|
25
|
+
OpenStruct.new(basename: basename, source: source_file(basename),
|
26
|
+
target: target_file(basename))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def source_files
|
31
|
+
r = []
|
32
|
+
source_target_files.each do |st|
|
33
|
+
r << st.source if st.source
|
34
|
+
end
|
35
|
+
r
|
36
|
+
end
|
37
|
+
|
38
|
+
def target_files
|
39
|
+
r = []
|
40
|
+
source_target_files.each do |st|
|
41
|
+
r << st.target if st.target
|
42
|
+
end
|
43
|
+
r
|
44
|
+
end
|
45
|
+
|
46
|
+
def target_file(basename)
|
47
|
+
fixture_file(basename, 'target')
|
48
|
+
end
|
49
|
+
|
50
|
+
def source_file(basename)
|
51
|
+
fixture_file(basename, 'source')
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def fixture_file(basename, suffix)
|
57
|
+
prefix = "#{basename}.#{suffix}"
|
58
|
+
Dir.foreach(fixtures_directory) do |item|
|
59
|
+
next if %w[. ..].include?(item)
|
60
|
+
return File.expand_path(item, fixtures_directory) if item.starts_with?(prefix)
|
61
|
+
end
|
62
|
+
nil
|
63
|
+
end
|
64
|
+
|
65
|
+
def sources_targets_basenames
|
66
|
+
basenames = Set.new
|
67
|
+
Dir.foreach(fixtures_directory) do |item|
|
68
|
+
next if %w[. ..].include?(item)
|
69
|
+
|
70
|
+
b = self.class.source_target_basename(item)
|
71
|
+
basenames << b if b.present?
|
72
|
+
end
|
73
|
+
basenames
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aranha/parsers/source_target_fixtures'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
RSpec.shared_examples 'source_target_fixtures' do |spec_file| # rubocop:disable Metrics/BlockLength
|
7
|
+
let(:spec_file) { spec_file }
|
8
|
+
|
9
|
+
it 'fixtures directory should exist' do
|
10
|
+
expect(::File.directory?(fixtures_dir)).to be true
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'with fixtures directory' do
|
14
|
+
it 'has at least one file' do
|
15
|
+
expect(source_target_fixtures.source_target_files.count).to be > 0 # rubocop:disable Style/NumericPredicate
|
16
|
+
end
|
17
|
+
|
18
|
+
if ENV['WRITE_TARGET_FIXTURES']
|
19
|
+
it 'writes target data for all files' do
|
20
|
+
source_target_fixtures.source_files.each do |source_file|
|
21
|
+
sd = sort_results(source_data(source_file))
|
22
|
+
basename = ::Aranha::Parsers::SourceTargetFixtures.source_target_basename(source_file)
|
23
|
+
target_file = File.expand_path("../#{basename}.target.yaml", source_file)
|
24
|
+
File.write(target_file, sd.to_yaml)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
else
|
28
|
+
it 'parses data for all files' do
|
29
|
+
source_target_fixtures.source_target_files.each do |st|
|
30
|
+
assert_source_target_complete(st)
|
31
|
+
sd = source_data(st.source)
|
32
|
+
td = target_data(st.target)
|
33
|
+
expect(sort_results(sd)).to eq(sort_results(td))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def source_target_fixtures
|
40
|
+
@source_target_fixtures ||= ::Aranha::Parsers::SourceTargetFixtures.new(fixtures_dir)
|
41
|
+
end
|
42
|
+
|
43
|
+
def assert_source_target_complete(source_target)
|
44
|
+
expect(source_target.source).to(be_truthy, "Source not found (Target: #{source_target.target})")
|
45
|
+
expect(source_target.target).to(be_truthy, "Target not found (Source: #{source_target.source})")
|
46
|
+
end
|
47
|
+
|
48
|
+
def source_data(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)\""
|
54
|
+
end
|
55
|
+
|
56
|
+
def fixtures_dir
|
57
|
+
::File.join(
|
58
|
+
::File.dirname(spec_file),
|
59
|
+
::File.basename(spec_file, '.*') + '_files'
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
def sort_results(results)
|
64
|
+
results
|
65
|
+
end
|
66
|
+
|
67
|
+
def target_data(target_file)
|
68
|
+
::YAML.load_file(target_file)
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aranha/parsers/source_address/http_get'
|
4
|
+
|
5
|
+
RSpec.describe ::Aranha::Parsers::SourceAddress::HttpGet do
|
6
|
+
SOURCE_URI = 'http://example.net/abc' # rubocop:disable RSpec/LeakyConstantDeclaration
|
7
|
+
|
8
|
+
describe '#location_uri' do
|
9
|
+
[
|
10
|
+
{ location: 'http://example.net/def', expected: 'http://example.net/def' },
|
11
|
+
{ location: '/def', expected: 'http://example.net/def' }
|
12
|
+
].each do |stub|
|
13
|
+
context "when source_uri is \"#{SOURCE_URI}\" and location is \"#{stub.fetch(:location)}\"" do
|
14
|
+
it "return #{stub.fetch(:expected)}" do
|
15
|
+
expect(described_class.location_uri(SOURCE_URI, stub.fetch(:location)))
|
16
|
+
.to eq(stub.fetch(:expected))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|