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,31 +0,0 @@
|
|
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
|
@@ -1,85 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'aranha/parsers/source_address/fetch_content_error'
|
4
|
-
require 'aranha/parsers/source_address/hash_http_base'
|
5
|
-
require 'eac_envs/http/error'
|
6
|
-
require 'eac_envs/http/request'
|
7
|
-
require 'eac_ruby_utils/core_ext'
|
8
|
-
require 'yaml'
|
9
|
-
|
10
|
-
module Aranha
|
11
|
-
module Parsers
|
12
|
-
class SourceAddress
|
13
|
-
class HashHttpBase
|
14
|
-
class << self
|
15
|
-
def http_method
|
16
|
-
const_get 'HTTP_METHOD'
|
17
|
-
end
|
18
|
-
|
19
|
-
def valid_source?(source)
|
20
|
-
source.is_a?(::Hash) &&
|
21
|
-
source.with_indifferent_access[:method].to_s.downcase.strip == http_method.to_s
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
DEFAULT_BODY = ''
|
26
|
-
DEFAULT_FOLLOW_REDIRECT = true
|
27
|
-
DEFAULT_HEADERS = {}.freeze
|
28
|
-
DEFAULT_PARAMS = {}.freeze
|
29
|
-
|
30
|
-
enable_simple_cache
|
31
|
-
|
32
|
-
common_constructor :source do
|
33
|
-
self.source = source.with_indifferent_access
|
34
|
-
end
|
35
|
-
compare_by :source
|
36
|
-
|
37
|
-
def body
|
38
|
-
param(:body, DEFAULT_BODY)
|
39
|
-
end
|
40
|
-
|
41
|
-
def follow_redirect?
|
42
|
-
param(:follow_redirect, DEFAULT_FOLLOW_REDIRECT)
|
43
|
-
end
|
44
|
-
|
45
|
-
def headers
|
46
|
-
param(:headers, DEFAULT_HEADERS)
|
47
|
-
end
|
48
|
-
|
49
|
-
def url
|
50
|
-
source.fetch(:url)
|
51
|
-
end
|
52
|
-
|
53
|
-
def serialize
|
54
|
-
source.to_yaml
|
55
|
-
end
|
56
|
-
|
57
|
-
def content
|
58
|
-
request = http_request
|
59
|
-
request.response.body_str
|
60
|
-
rescue ::EacEnvs::Http::Error => e
|
61
|
-
raise ::Aranha::Parsers::SourceAddress::FetchContentError, e.message, request
|
62
|
-
end
|
63
|
-
|
64
|
-
def param(key, default_value)
|
65
|
-
source[key] || params[key] || default_value
|
66
|
-
end
|
67
|
-
|
68
|
-
def params
|
69
|
-
source[:params].if_present(DEFAULT_PARAMS)
|
70
|
-
end
|
71
|
-
|
72
|
-
private
|
73
|
-
|
74
|
-
# @return [EacEnvs::Http::Request]
|
75
|
-
def http_request
|
76
|
-
r = ::EacEnvs::Http::Request.new.verb(self.class.http_method).url(url)
|
77
|
-
r = headers.if_present(r) { |v| r.headers(v) }
|
78
|
-
r = body.if_present(r) { |v| r.body(v) }
|
79
|
-
r = r.follow_redirect(true) if follow_redirect?
|
80
|
-
r
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'aranha/parsers/source_address/hash_http_base'
|
4
|
-
|
5
|
-
module Aranha
|
6
|
-
module Parsers
|
7
|
-
class SourceAddress
|
8
|
-
class HashHttpGet < ::Aranha::Parsers::SourceAddress::HashHttpBase
|
9
|
-
HTTP_METHOD = :get
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'aranha/parsers/source_address/hash_http_base'
|
4
|
-
|
5
|
-
module Aranha
|
6
|
-
module Parsers
|
7
|
-
class SourceAddress
|
8
|
-
class HashHttpPost < ::Aranha::Parsers::SourceAddress::HashHttpBase
|
9
|
-
HTTP_METHOD = :post
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'addressable'
|
4
|
-
require 'aranha/parsers/source_address/fetch_content_error'
|
5
|
-
require 'eac_envs/http/error'
|
6
|
-
require 'eac_envs/http/request'
|
7
|
-
|
8
|
-
module Aranha
|
9
|
-
module Parsers
|
10
|
-
class SourceAddress
|
11
|
-
class HttpGet
|
12
|
-
class << self
|
13
|
-
def location_uri(source_uri, location)
|
14
|
-
::Addressable::URI.join(source_uri, location).to_s
|
15
|
-
end
|
16
|
-
|
17
|
-
def valid_source?(source)
|
18
|
-
source.to_s =~ %r{\Ahttps?://}
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
attr_reader :source
|
23
|
-
|
24
|
-
def initialize(source)
|
25
|
-
@source = source.to_s
|
26
|
-
end
|
27
|
-
|
28
|
-
def ==(other)
|
29
|
-
self.class == other.class && source == other.source
|
30
|
-
end
|
31
|
-
|
32
|
-
def url
|
33
|
-
source
|
34
|
-
end
|
35
|
-
|
36
|
-
def final_url
|
37
|
-
content unless @final_url
|
38
|
-
@final_url
|
39
|
-
end
|
40
|
-
|
41
|
-
def content
|
42
|
-
request = ::EacEnvs::Http::Request.new.url(url).retry(true).follow_redirect(true)
|
43
|
-
request.response.body_str
|
44
|
-
rescue ::EacEnvs::Http::Error => e
|
45
|
-
raise ::Aranha::Parsers::SourceAddress::FetchContentError, e.message, request
|
46
|
-
end
|
47
|
-
|
48
|
-
def serialize
|
49
|
-
url
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'active_support/core_ext/module/delegation'
|
4
|
-
require 'eac_ruby_utils/core_ext'
|
5
|
-
require 'yaml'
|
6
|
-
|
7
|
-
module Aranha
|
8
|
-
module Parsers
|
9
|
-
class SourceAddress
|
10
|
-
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
|
-
enable_simple_cache
|
39
|
-
common_constructor :source
|
40
|
-
delegate :content, :url, to: :sub
|
41
|
-
|
42
|
-
def to_s
|
43
|
-
sub.url
|
44
|
-
end
|
45
|
-
|
46
|
-
def serialize
|
47
|
-
sub.serialize.strip + "\n"
|
48
|
-
end
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
def sub_uncached
|
53
|
-
self.class.detect_sub(source)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Aranha
|
4
|
-
module Parsers
|
5
|
-
class SourceTargetFixtures
|
6
|
-
class SourceTargetFile
|
7
|
-
common_constructor :owner, :basename
|
8
|
-
|
9
|
-
def source
|
10
|
-
owner.source_file(basename)
|
11
|
-
end
|
12
|
-
|
13
|
-
def target
|
14
|
-
owner.target_file(basename)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,78 +0,0 @@
|
|
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
|
-
require_sub __FILE__
|
11
|
-
|
12
|
-
class << self
|
13
|
-
def source_target_basename(file)
|
14
|
-
m = /^(.+)\.(?:source|target)(?:\..+)?$/.match(File.basename(file))
|
15
|
-
m ? m[1] : nil
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
attr_reader :fixtures_directory
|
20
|
-
|
21
|
-
def initialize(fixtures_directory)
|
22
|
-
@fixtures_directory = fixtures_directory
|
23
|
-
end
|
24
|
-
|
25
|
-
def source_target_files
|
26
|
-
sources_targets_basenames.map do |basename|
|
27
|
-
::Aranha::Parsers::SourceTargetFixtures::SourceTargetFile.new(self, basename)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def source_files
|
32
|
-
r = []
|
33
|
-
source_target_files.each do |st|
|
34
|
-
r << st.source if st.source
|
35
|
-
end
|
36
|
-
r
|
37
|
-
end
|
38
|
-
|
39
|
-
def target_files
|
40
|
-
r = []
|
41
|
-
source_target_files.each do |st|
|
42
|
-
r << st.target if st.target
|
43
|
-
end
|
44
|
-
r
|
45
|
-
end
|
46
|
-
|
47
|
-
def target_file(basename)
|
48
|
-
fixture_file(basename, 'target')
|
49
|
-
end
|
50
|
-
|
51
|
-
def source_file(basename)
|
52
|
-
fixture_file(basename, 'source')
|
53
|
-
end
|
54
|
-
|
55
|
-
private
|
56
|
-
|
57
|
-
def fixture_file(basename, suffix)
|
58
|
-
prefix = "#{basename}.#{suffix}"
|
59
|
-
Dir.foreach(fixtures_directory) do |item|
|
60
|
-
next if %w[. ..].include?(item)
|
61
|
-
return File.expand_path(item, fixtures_directory) if item.starts_with?(prefix)
|
62
|
-
end
|
63
|
-
nil
|
64
|
-
end
|
65
|
-
|
66
|
-
def sources_targets_basenames
|
67
|
-
basenames = Set.new
|
68
|
-
Dir.foreach(fixtures_directory) do |item|
|
69
|
-
next if %w[. ..].include?(item)
|
70
|
-
|
71
|
-
b = self.class.source_target_basename(item)
|
72
|
-
basenames << b if b.present?
|
73
|
-
end
|
74
|
-
basenames
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
data/sub/aranha-parsers/spec/lib/aranha/parsers/rspec/shared_examples/source_target_fixtures_spec.rb
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
::RSpec.describe 'RSpec.shared_examples(\'source_target_fixtures\')' do # rubocop:disable RSpec/DescribeClass
|
4
|
-
include_examples 'source_target_fixtures', __FILE__
|
5
|
-
|
6
|
-
def source_data(source_file)
|
7
|
-
::File.read(source_file)
|
8
|
-
end
|
9
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
Isto é um fixture.
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'aranha/parsers/source_address'
|
4
|
-
require 'eac_envs/http/rspec/echo_server'
|
5
|
-
require 'eac_ruby_utils/yaml'
|
6
|
-
|
7
|
-
::RSpec.describe ::Aranha::Parsers::SourceAddress do
|
8
|
-
describe '#detect_sub' do
|
9
|
-
let(:http_server) { ::EacEnvs::Http::Rspec::EchoServer.http }
|
10
|
-
|
11
|
-
around { |example| http_server.on_active(&example) }
|
12
|
-
|
13
|
-
include_examples 'source_target_fixtures', __FILE__
|
14
|
-
|
15
|
-
def source_data(source_file)
|
16
|
-
source = ::EacRubyUtils::Yaml.load_file(source_file)
|
17
|
-
url = source_url_get(source)
|
18
|
-
%w[scheme host port].each { |attr| url.send("#{attr}=", http_server.root_url.send(attr)) }
|
19
|
-
if source.is_a?(::Hash)
|
20
|
-
source[:url] = url.to_s
|
21
|
-
else
|
22
|
-
source = url.to_s
|
23
|
-
end
|
24
|
-
::JSON.parse(described_class.detect_sub(source).content)
|
25
|
-
end
|
26
|
-
|
27
|
-
# @return [Addressable::URI]
|
28
|
-
def source_url_get(source)
|
29
|
-
(source.is_a?(::Hash) ? source.fetch(:url) : source).to_uri
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
--- http://postdata.net
|
@@ -1,21 +0,0 @@
|
|
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
|
@@ -1,74 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'aranha/parsers/source_address'
|
4
|
-
|
5
|
-
RSpec.describe ::Aranha::Parsers::SourceAddress do
|
6
|
-
describe '#detect_sub' do
|
7
|
-
{
|
8
|
-
{ method: :post, url: 'http://postdata.net', params: { key1: :value1 } } => {
|
9
|
-
klass: ::Aranha::Parsers::SourceAddress::HashHttpBase,
|
10
|
-
url: 'http://postdata.net',
|
11
|
-
serialization: <<~SERIALIZATION
|
12
|
-
--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
|
13
|
-
method: :post
|
14
|
-
url: http://postdata.net
|
15
|
-
params: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
|
16
|
-
key1: :value1
|
17
|
-
SERIALIZATION
|
18
|
-
},
|
19
|
-
{ method: :get, url: 'http://getdata.net', params: { headers: %w[abc] } } => {
|
20
|
-
klass: ::Aranha::Parsers::SourceAddress::HashHttpBase,
|
21
|
-
url: 'http://getdata.net',
|
22
|
-
serialization: <<~SERIALIZATION
|
23
|
-
--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
|
24
|
-
method: :get
|
25
|
-
url: http://getdata.net
|
26
|
-
params: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
|
27
|
-
headers:
|
28
|
-
- abc
|
29
|
-
SERIALIZATION
|
30
|
-
},
|
31
|
-
'http://postdata.net' => {
|
32
|
-
klass: ::Aranha::Parsers::SourceAddress::HttpGet,
|
33
|
-
url: 'http://postdata.net',
|
34
|
-
serialization: 'http://postdata.net'
|
35
|
-
},
|
36
|
-
'https://getdata.com.br' => {
|
37
|
-
klass: ::Aranha::Parsers::SourceAddress::HttpGet,
|
38
|
-
url: 'https://getdata.com.br',
|
39
|
-
serialization: 'https://getdata.com.br'
|
40
|
-
},
|
41
|
-
'file:///postdata.net' => {
|
42
|
-
klass: ::Aranha::Parsers::SourceAddress::File,
|
43
|
-
url: 'file:///postdata.net',
|
44
|
-
serialization: 'file:///postdata.net'
|
45
|
-
},
|
46
|
-
'/postdata.net' => {
|
47
|
-
klass: ::Aranha::Parsers::SourceAddress::File,
|
48
|
-
url: 'file:///postdata.net',
|
49
|
-
serialization: 'file:///postdata.net'
|
50
|
-
}
|
51
|
-
}.each do |source, expected|
|
52
|
-
context "when source is #{source}" do
|
53
|
-
let(:sub) { described_class.detect_sub(source) }
|
54
|
-
let(:deserialized) { described_class.deserialize(sub.serialize).sub }
|
55
|
-
|
56
|
-
it "sub is a #{expected.fetch(:klass)}" do
|
57
|
-
expect(sub).to be_a(expected.fetch(:klass))
|
58
|
-
end
|
59
|
-
|
60
|
-
it "sub #{expected.fetch(:klass)} return properly URL" do
|
61
|
-
expect(sub.url).to eq(expected.fetch(:url))
|
62
|
-
end
|
63
|
-
|
64
|
-
it "sub #{expected.fetch(:klass)} serialize properly" do
|
65
|
-
expect(sub.serialize).to eq(expected.fetch(:serialization))
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'deserialize properly' do
|
69
|
-
expect(deserialized).to eq(sub)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'aranha/parsers/source_target_fixtures'
|
4
|
-
|
5
|
-
RSpec.describe ::Aranha::Parsers::SourceTargetFixtures do
|
6
|
-
let(:fixtures_dir) { ::File.join(__dir__, 'source_target_fixtures_spec_files') }
|
7
|
-
let(:instance) { described_class.new(fixtures_dir) }
|
8
|
-
|
9
|
-
describe '#source_target_files' do
|
10
|
-
it { expect(instance.source_target_files.count).to eq(3) }
|
11
|
-
|
12
|
-
(1..3).each do |index|
|
13
|
-
basename = "stub#{index}"
|
14
|
-
let(basename) { instance.source_target_files.find { |stf| stf.basename == basename } }
|
15
|
-
|
16
|
-
it { expect(send(basename)).to be_present }
|
17
|
-
it { expect(send(basename).basename).to eq(basename) }
|
18
|
-
end
|
19
|
-
|
20
|
-
it { expect(stub1.source).to eq(::File.join(fixtures_dir, 'stub1.source.txt')) }
|
21
|
-
it { expect(stub1.target).to eq(::File.join(fixtures_dir, 'stub1.target.html')) }
|
22
|
-
it { expect(stub2.source).to eq(::File.join(fixtures_dir, 'stub2.source.html')) }
|
23
|
-
it { expect(stub2.target).to eq(nil) }
|
24
|
-
it { expect(stub3.source).to eq(nil) }
|
25
|
-
it { expect(stub3.target).to eq(::File.join(fixtures_dir, 'stub3.target.yaml')) }
|
26
|
-
end
|
27
|
-
end
|
data/sub/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub1.source.txt
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
|
data/sub/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub1.target.html
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
|
data/sub/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub2.source.html
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
|
data/sub/aranha-parsers/spec/lib/aranha/parsers/source_target_fixtures_spec_files/stub3.target.yaml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
|