eac_tools 0.76.0 → 0.76.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +28 -48
- data/lib/eac_tools/version.rb +1 -1
- data/sub/eac_cli/Gemfile +2 -2
- data/sub/eac_cli/eac_cli.gemspec +5 -3
- data/sub/eac_cli/lib/eac_cli/config.rb +0 -4
- data/sub/eac_cli/lib/eac_cli/core_ext.rb +1 -1
- data/sub/eac_cli/lib/eac_cli/definition/alternative.rb +24 -3
- data/sub/eac_cli/lib/eac_cli/definition.rb +1 -1
- data/sub/eac_cli/lib/eac_cli/old_configs/store_passwords_entry_reader.rb +1 -1
- data/sub/eac_cli/lib/eac_cli/parser/alternative/any_options.rb +19 -0
- data/sub/eac_cli/lib/eac_cli/parser/alternative/long_options.rb +1 -1
- data/sub/eac_cli/lib/eac_cli/parser/alternative/short_options.rb +1 -3
- data/sub/eac_cli/lib/eac_cli/parser/alternative.rb +0 -9
- data/sub/eac_cli/lib/eac_cli/parser.rb +1 -1
- data/sub/eac_cli/lib/eac_cli/patches/object.rb +1 -1
- data/sub/eac_cli/lib/eac_cli/patches.rb +1 -1
- data/sub/eac_cli/lib/eac_cli/runner/class_runner.rb +1 -1
- data/sub/eac_cli/lib/eac_cli/runner/context_responders/set.rb +2 -2
- data/sub/eac_cli/lib/eac_cli/runner/exit.rb +2 -1
- data/sub/eac_cli/lib/eac_cli/runner/instance_methods.rb +1 -1
- data/sub/eac_cli/lib/eac_cli/runner_with/help/builder/alternative.rb +1 -1
- data/sub/eac_cli/lib/eac_cli/runner_with/help/builder.rb +2 -2
- data/sub/eac_cli/lib/eac_cli/runner_with/help.rb +1 -0
- data/sub/eac_cli/lib/eac_cli/runner_with/subcommands.rb +1 -1
- data/sub/eac_cli/lib/eac_cli/runner_with_set.rb +1 -1
- data/sub/eac_cli/lib/eac_cli/speaker/list.rb +4 -4
- data/sub/eac_cli/lib/eac_cli/speaker/options.rb +3 -3
- data/sub/eac_cli/lib/eac_cli/speaker.rb +2 -1
- data/sub/eac_cli/lib/eac_cli/version.rb +1 -1
- data/sub/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb +2 -2
- data/sub/eac_cli/spec/lib/eac_cli/old_configs_spec.rb +1 -1
- data/sub/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb +10 -10
- data/sub/eac_cli/spec/lib/eac_cli/runner/for_context_spec.rb +13 -13
- data/sub/eac_cli/spec/lib/eac_cli/runner_spec.rb +10 -10
- data/sub/eac_cli/spec/lib/eac_cli/runner_with/confirmation_spec.rb +3 -3
- data/sub/eac_cli/spec/lib/eac_cli/runner_with/help/layout_spec.rb +1 -1
- data/sub/eac_cli/spec/lib/eac_cli/runner_with/help_spec.rb +3 -2
- data/sub/eac_cli/spec/lib/eac_cli/runner_with/output_spec.rb +6 -6
- data/sub/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +6 -6
- data/sub/eac_cli/spec/lib/eac_cli/speaker_spec.rb +1 -1
- data/sub/eac_cli/spec/rubocop_spec.rb +1 -1
- data/sub/eac_cli/spec/spec_helper.rb +1 -1
- metadata +3 -166
- data/sub/eac_envs-http/Gemfile +0 -8
- data/sub/eac_envs-http/eac_envs-http.gemspec +0 -25
- data/sub/eac_envs-http/lib/eac_envs/http/error.rb +0 -8
- data/sub/eac_envs-http/lib/eac_envs/http/request/body_field.rb +0 -51
- data/sub/eac_envs-http/lib/eac_envs/http/request/body_field_value.rb +0 -32
- data/sub/eac_envs-http/lib/eac_envs/http/request/body_fields.rb +0 -39
- data/sub/eac_envs-http/lib/eac_envs/http/request/faraday_connection.rb +0 -75
- data/sub/eac_envs-http/lib/eac_envs/http/request.rb +0 -58
- data/sub/eac_envs-http/lib/eac_envs/http/response/body.rb +0 -62
- data/sub/eac_envs-http/lib/eac_envs/http/response/headers.rb +0 -41
- data/sub/eac_envs-http/lib/eac_envs/http/response/links.rb +0 -28
- data/sub/eac_envs-http/lib/eac_envs/http/response/statuses.rb +0 -21
- data/sub/eac_envs-http/lib/eac_envs/http/response.rb +0 -30
- data/sub/eac_envs-http/lib/eac_envs/http/rspec/echo_server/request_processor.rb +0 -42
- data/sub/eac_envs-http/lib/eac_envs/http/rspec/echo_server/webrick_servlet.rb +0 -22
- data/sub/eac_envs-http/lib/eac_envs/http/rspec/echo_server.rb +0 -63
- data/sub/eac_envs-http/lib/eac_envs/http/rspec.rb +0 -11
- data/sub/eac_envs-http/lib/eac_envs/http/version.rb +0 -7
- data/sub/eac_envs-http/lib/eac_envs/http.rb +0 -9
- data/sub/eac_envs-http/spec/lib/eac_envs/http/request/body_fields_spec.rb +0 -47
- data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec.rb +0 -68
- data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/get.source.yaml +0 -5
- data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/get.target.yaml +0 -9
- data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/get_with_auth.source.yaml +0 -8
- data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/get_with_auth.target.yaml +0 -10
- data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/post_array_body.source.yaml +0 -10
- data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/post_array_body.target.yaml +0 -11
- data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/post_string_body.source.yaml +0 -4
- data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/post_string_body.target.yaml +0 -11
- data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/put_hash_body.source.yaml +0 -6
- data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/put_hash_body.target.yaml +0 -11
- data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/put_with_file.source.yaml +0 -5
- data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/put_with_file.target.yaml +0 -13
- data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/root.source.yaml +0 -2
- data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/root.target.yaml +0 -9
- data/sub/eac_envs-http/spec/rubocop_spec.rb +0 -3
- data/sub/eac_envs-http/spec/spec_helper/request_builder.rb +0 -62
- data/sub/eac_envs-http/spec/spec_helper.rb +0 -7
- data/sub/eac_fs/Gemfile +0 -8
- data/sub/eac_fs/eac_fs.gemspec +0 -20
- data/sub/eac_fs/lib/eac_fs/cached_download.rb +0 -40
- data/sub/eac_fs/lib/eac_fs/comparator/build.rb +0 -57
- data/sub/eac_fs/lib/eac_fs/comparator/rename_file.rb +0 -15
- data/sub/eac_fs/lib/eac_fs/comparator.rb +0 -18
- data/sub/eac_fs/lib/eac_fs/contexts.rb +0 -21
- data/sub/eac_fs/lib/eac_fs/core_ext.rb +0 -4
- data/sub/eac_fs/lib/eac_fs/file_info.rb +0 -29
- data/sub/eac_fs/lib/eac_fs/logs/file.rb +0 -56
- data/sub/eac_fs/lib/eac_fs/logs.rb +0 -64
- data/sub/eac_fs/lib/eac_fs/patches/module/fs_cache.rb +0 -15
- data/sub/eac_fs/lib/eac_fs/patches/module.rb +0 -4
- data/sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb +0 -32
- data/sub/eac_fs/lib/eac_fs/patches/object.rb +0 -4
- data/sub/eac_fs/lib/eac_fs/patches/pathname/info.rb +0 -12
- data/sub/eac_fs/lib/eac_fs/patches/pathname.rb +0 -4
- data/sub/eac_fs/lib/eac_fs/patches.rb +0 -4
- data/sub/eac_fs/lib/eac_fs/rspec/setup.rb +0 -25
- data/sub/eac_fs/lib/eac_fs/rspec.rb +0 -9
- data/sub/eac_fs/lib/eac_fs/storage_tree.rb +0 -81
- data/sub/eac_fs/lib/eac_fs/traversable.rb +0 -45
- data/sub/eac_fs/lib/eac_fs/traverser.rb +0 -76
- data/sub/eac_fs/lib/eac_fs/version.rb +0 -5
- data/sub/eac_fs/lib/eac_fs.rb +0 -7
- data/sub/eac_fs/spec/lib/eac_fs/storage_tree_spec.rb +0 -32
- data/sub/eac_fs/spec/rubocop_spec.rb +0 -3
- data/sub/eac_fs/spec/spec_helper.rb +0 -4
- data/sub/eac_rest/Gemfile +0 -8
- data/sub/eac_rest/eac_rest.gemspec +0 -21
- data/sub/eac_rest/lib/eac_rest/api.rb +0 -57
- data/sub/eac_rest/lib/eac_rest/entity/data.rb +0 -44
- data/sub/eac_rest/lib/eac_rest/entity/fetching.rb +0 -20
- data/sub/eac_rest/lib/eac_rest/entity.rb +0 -35
- data/sub/eac_rest/lib/eac_rest/error.rb +0 -6
- data/sub/eac_rest/lib/eac_rest/helper.rb +0 -34
- data/sub/eac_rest/lib/eac_rest/request.rb +0 -48
- data/sub/eac_rest/lib/eac_rest/response.rb +0 -27
- data/sub/eac_rest/lib/eac_rest/version.rb +0 -5
- data/sub/eac_rest/lib/eac_rest.rb +0 -7
- data/sub/eac_rest/spec/lib/eac_rest/api_spec.rb +0 -71
- data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/get.source.yaml +0 -5
- data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/get.target.yaml +0 -9
- data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/get_with_auth.source.yaml +0 -8
- data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/get_with_auth.target.yaml +0 -10
- data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/post_array_body.source.yaml +0 -10
- data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/post_array_body.target.yaml +0 -11
- data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/post_string_body.source.yaml +0 -4
- data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/post_string_body.target.yaml +0 -11
- data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/put_hash_body.source.yaml +0 -6
- data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/put_hash_body.target.yaml +0 -11
- data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/put_with_file.source.yaml +0 -5
- data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/put_with_file.target.yaml +0 -13
- data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/root.source.yaml +0 -2
- data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/root.target.yaml +0 -9
- data/sub/eac_rest/spec/rubocop_spec.rb +0 -3
- data/sub/eac_rest/spec/spec_helper/request_builder.rb +0 -51
- data/sub/eac_rest/spec/spec_helper.rb +0 -7
- data/sub/eac_templates/Gemfile +0 -8
- data/sub/eac_templates/eac_templates.gemspec +0 -19
- data/sub/eac_templates/lib/eac_templates/abstract/directory.rb +0 -42
- data/sub/eac_templates/lib/eac_templates/abstract/file.rb +0 -25
- data/sub/eac_templates/lib/eac_templates/abstract/fs_object.rb +0 -94
- data/sub/eac_templates/lib/eac_templates/abstract/fs_object_by_pathname.rb +0 -13
- data/sub/eac_templates/lib/eac_templates/abstract/not_found_error.rb +0 -8
- data/sub/eac_templates/lib/eac_templates/core_ext.rb +0 -4
- data/sub/eac_templates/lib/eac_templates/interface_methods.rb +0 -12
- data/sub/eac_templates/lib/eac_templates/modules/ancestor/directory.rb +0 -17
- data/sub/eac_templates/lib/eac_templates/modules/ancestor/file.rb +0 -16
- data/sub/eac_templates/lib/eac_templates/modules/ancestor/fs_object.rb +0 -25
- data/sub/eac_templates/lib/eac_templates/modules/ancestor.rb +0 -51
- data/sub/eac_templates/lib/eac_templates/modules/base.rb +0 -35
- data/sub/eac_templates/lib/eac_templates/modules.rb +0 -9
- data/sub/eac_templates/lib/eac_templates/patches/module/erb_template.rb +0 -9
- data/sub/eac_templates/lib/eac_templates/patches/module/template.rb +0 -9
- data/sub/eac_templates/lib/eac_templates/patches/module.rb +0 -4
- data/sub/eac_templates/lib/eac_templates/patches/object/erb_template.rb +0 -9
- data/sub/eac_templates/lib/eac_templates/patches/object/template.rb +0 -9
- data/sub/eac_templates/lib/eac_templates/patches/object.rb +0 -4
- data/sub/eac_templates/lib/eac_templates/patches.rb +0 -4
- data/sub/eac_templates/lib/eac_templates/sources/directory.rb +0 -37
- data/sub/eac_templates/lib/eac_templates/sources/file.rb +0 -13
- data/sub/eac_templates/lib/eac_templates/sources/from_all_gems.rb +0 -4
- data/sub/eac_templates/lib/eac_templates/sources/from_gem.rb +0 -37
- data/sub/eac_templates/lib/eac_templates/sources/fs_object.rb +0 -53
- data/sub/eac_templates/lib/eac_templates/sources/internal_set.rb +0 -22
- data/sub/eac_templates/lib/eac_templates/sources/set.rb +0 -55
- data/sub/eac_templates/lib/eac_templates/sources/single.rb +0 -29
- data/sub/eac_templates/lib/eac_templates/sources.rb +0 -9
- data/sub/eac_templates/lib/eac_templates/variables/content.rb +0 -52
- data/sub/eac_templates/lib/eac_templates/variables/directory.rb +0 -49
- data/sub/eac_templates/lib/eac_templates/variables/file.rb +0 -26
- data/sub/eac_templates/lib/eac_templates/variables/fs_object.rb +0 -65
- data/sub/eac_templates/lib/eac_templates/variables/not_found_error.rb +0 -7
- data/sub/eac_templates/lib/eac_templates/variables/providers/base.rb +0 -23
- data/sub/eac_templates/lib/eac_templates/variables/providers/config_reader.rb +0 -29
- data/sub/eac_templates/lib/eac_templates/variables/providers/entries_reader.rb +0 -25
- data/sub/eac_templates/lib/eac_templates/variables/providers/generic.rb +0 -25
- data/sub/eac_templates/lib/eac_templates/variables/providers/hash.rb +0 -29
- data/sub/eac_templates/lib/eac_templates/variables/providers.rb +0 -25
- data/sub/eac_templates/lib/eac_templates/variables.rb +0 -9
- data/sub/eac_templates/lib/eac_templates/version.rb +0 -5
- data/sub/eac_templates/lib/eac_templates.rb +0 -7
- data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec.rb +0 -141
- data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path1/a_module/a/a_a +0 -1
- data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path1/a_module/b +0 -1
- data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path1/super_class/a/a_b +0 -1
- data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path1/super_class/b +0 -1
- data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path2/a_module/a/a_b +0 -1
- data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path2/a_module/b +0 -1
- data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path2/a_module/c +0 -1
- data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path2/prepended_module/c +0 -1
- data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path2/sub_class/b +0 -1
- data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path2/super_class/a/a_b +0 -1
- data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path2/super_class/b +0 -1
- data/sub/eac_templates/spec/lib/eac_templates/patches/object/template_spec.rb +0 -26
- data/sub/eac_templates/spec/lib/eac_templates/patches/object/template_spec_files/path/my_stub_with_template +0 -1
- data/sub/eac_templates/spec/lib/eac_templates/sources/set_spec.rb +0 -42
- data/sub/eac_templates/spec/lib/eac_templates/sources/set_spec_files/path1/subdir1/file1.template +0 -1
- data/sub/eac_templates/spec/lib/eac_templates/sources/set_spec_files/path1/subdir1/file2 +0 -1
- data/sub/eac_templates/spec/lib/eac_templates/sources/set_spec_files/path2/subdir1/file3.template +0 -1
- data/sub/eac_templates/spec/lib/eac_templates/variables/content_spec.rb +0 -35
- data/sub/eac_templates/spec/lib/eac_templates/variables/content_spec_files/expected_content +0 -2
- data/sub/eac_templates/spec/lib/eac_templates/variables/content_spec_files/source.template +0 -2
- data/sub/eac_templates/spec/rubocop_spec.rb +0 -3
- data/sub/eac_templates/spec/spec_helper.rb +0 -4
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
require 'eac_envs/http/request/body_field'
|
5
|
-
|
6
|
-
module EacEnvs
|
7
|
-
module Http
|
8
|
-
class Request
|
9
|
-
class BodyFields
|
10
|
-
common_constructor :source_body
|
11
|
-
|
12
|
-
# @return [Hash, nil]
|
13
|
-
def to_h
|
14
|
-
fields.if_present do |v|
|
15
|
-
v.each_with_object({}) { |e, a| a[e.hash_key] = e.hash_value }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
# @return [Array<EacEnvs::Http::Request::BodyField>, nil]
|
20
|
-
def fields
|
21
|
-
source_body.if_present do |v|
|
22
|
-
next nil unless v.is_a?(::Enumerable)
|
23
|
-
|
24
|
-
if v.is_a?(::Hash)
|
25
|
-
::EacEnvs::Http::Request::BodyField.list_from_hash(v)
|
26
|
-
else
|
27
|
-
::EacEnvs::Http::Request::BodyField.list_from_enumerable(v)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
# @return [Boolean]
|
33
|
-
def with_file?
|
34
|
-
fields.if_present(false) { |v| v.any?(&:with_file?) }
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
require 'faraday'
|
5
|
-
require 'faraday/follow_redirects'
|
6
|
-
require 'faraday/gzip'
|
7
|
-
require 'faraday/multipart'
|
8
|
-
require 'faraday/retry'
|
9
|
-
|
10
|
-
module EacEnvs
|
11
|
-
module Http
|
12
|
-
class Request
|
13
|
-
class FaradayConnection
|
14
|
-
enable_method_class
|
15
|
-
common_constructor :request
|
16
|
-
|
17
|
-
SETUPS = %i[multipart authorization follow_redirect gzip retry].freeze
|
18
|
-
|
19
|
-
# @return [Faraday::Connection]
|
20
|
-
def result
|
21
|
-
::Faraday.default_connection_options[:headers] = {}
|
22
|
-
::Faraday::Connection.new(connection_options) do |conn|
|
23
|
-
SETUPS.each { |setup| send("setup_#{setup}", conn) }
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
# @return [Boolean]
|
30
|
-
def body_with_file?
|
31
|
-
request.body_fields.with_file?
|
32
|
-
end
|
33
|
-
|
34
|
-
# @return [Hash]
|
35
|
-
def connection_options
|
36
|
-
{
|
37
|
-
request: { params_encoder: Faraday::FlatParamsEncoder },
|
38
|
-
ssl: { verify: request.ssl_verify? }
|
39
|
-
}
|
40
|
-
end
|
41
|
-
|
42
|
-
# @param conn [Faraday::Connection]
|
43
|
-
def setup_authorization(conn)
|
44
|
-
request.auth.if_present do |v|
|
45
|
-
conn.request :authorization, :basic, v.username, v.password
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
# @param conn [Faraday::Connection]
|
50
|
-
def setup_follow_redirect(conn)
|
51
|
-
conn.response :follow_redirects if request.follow_redirect?
|
52
|
-
end
|
53
|
-
|
54
|
-
# @param conn [Faraday::Connection]
|
55
|
-
def setup_gzip(conn)
|
56
|
-
conn.request :gzip
|
57
|
-
end
|
58
|
-
|
59
|
-
# @param conn [Faraday::Connection]
|
60
|
-
def setup_multipart(conn)
|
61
|
-
if body_with_file?
|
62
|
-
conn.request :multipart, flat_encode: true
|
63
|
-
else
|
64
|
-
conn.request :url_encoded
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
# @param conn [Faraday::Connection]
|
69
|
-
def setup_retry(conn)
|
70
|
-
conn.request :retry if request.retry?
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_envs/http/response'
|
4
|
-
require 'eac_ruby_utils/core_ext'
|
5
|
-
|
6
|
-
module EacEnvs
|
7
|
-
module Http
|
8
|
-
class Request
|
9
|
-
BOOLEAN_MODIFIERS = %w[follow_redirect retry ssl_verify].freeze
|
10
|
-
COMMON_MODIFIERS = %w[auth body_data response_body_data_proc url verb].freeze
|
11
|
-
HASH_MODIFIERS = %w[header].freeze
|
12
|
-
MODIFIERS = COMMON_MODIFIERS + BOOLEAN_MODIFIERS + HASH_MODIFIERS.map(&:pluralize)
|
13
|
-
|
14
|
-
enable_immutable
|
15
|
-
immutable_accessor(*BOOLEAN_MODIFIERS, type: :boolean)
|
16
|
-
immutable_accessor(*COMMON_MODIFIERS, type: :common)
|
17
|
-
immutable_accessor(*HASH_MODIFIERS, type: :hash)
|
18
|
-
|
19
|
-
enable_listable
|
20
|
-
lists.add_symbol :verb, :get, :delete, :options, :post, :put
|
21
|
-
|
22
|
-
def basic_auth(username, password)
|
23
|
-
auth(::Struct.new(:username, :password).new(username, password))
|
24
|
-
end
|
25
|
-
|
26
|
-
# @return [EacEnvs::Http::Request::BodyFields]
|
27
|
-
def body_fields
|
28
|
-
@body_fields ||= ::EacEnvs::Http::Request::BodyFields.new(body_data)
|
29
|
-
end
|
30
|
-
|
31
|
-
# @return [Faraday::Response]
|
32
|
-
def faraday_response
|
33
|
-
conn = faraday_connection
|
34
|
-
conn.send(sanitized_verb, url) do |req|
|
35
|
-
req.headers = conn.headers.merge(headers)
|
36
|
-
sanitized_body_data.if_present { |v| req.body = v }
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def response
|
41
|
-
::EacEnvs::Http::Response.new(self)
|
42
|
-
end
|
43
|
-
|
44
|
-
# @return [Symbol]
|
45
|
-
def sanitized_verb
|
46
|
-
verb.if_present(VERB_GET) { |v| self.class.lists.verb.value_validate!(v) }
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
def sanitized_body_data
|
52
|
-
body_fields.to_h || body_data
|
53
|
-
end
|
54
|
-
|
55
|
-
require_sub __FILE__, require_dependency: true
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
require 'json'
|
5
|
-
|
6
|
-
module EacEnvs
|
7
|
-
module Http
|
8
|
-
class Response < ::StandardError
|
9
|
-
module Body
|
10
|
-
delegate :response_body_data_proc, to: :request
|
11
|
-
|
12
|
-
def body_data
|
13
|
-
r = body_data_method_name.if_present(body_str) do |v|
|
14
|
-
respond_to?(v, true) ? send(v) : body_str
|
15
|
-
end
|
16
|
-
r = response_body_data_proc.call(r) if response_body_data_proc.present?
|
17
|
-
r
|
18
|
-
end
|
19
|
-
|
20
|
-
def body_data_or_raise
|
21
|
-
raise_unless_200
|
22
|
-
|
23
|
-
body_data
|
24
|
-
end
|
25
|
-
|
26
|
-
# @return [String]
|
27
|
-
def body_str
|
28
|
-
performed.body
|
29
|
-
end
|
30
|
-
|
31
|
-
def body_str_or_raise
|
32
|
-
raise_unless_200
|
33
|
-
|
34
|
-
body_str
|
35
|
-
end
|
36
|
-
|
37
|
-
# @param path [Pathname]
|
38
|
-
def write_body(path)
|
39
|
-
::File.open(path, 'wb') { |fp| fp.write(performed.body) }
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def body_data_from_application_json
|
45
|
-
::JSON.parse(body_str)
|
46
|
-
end
|
47
|
-
|
48
|
-
def body_data_from_application_xml
|
49
|
-
Hash.from_xml(body_str)
|
50
|
-
end
|
51
|
-
|
52
|
-
# @return [String]
|
53
|
-
def body_data_method_name
|
54
|
-
content_type.if_present do |v|
|
55
|
-
'body_data_from_' +
|
56
|
-
v.split(';').first.force_encoding(::Encoding::UTF_8).variableize
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
|
5
|
-
module EacEnvs
|
6
|
-
module Http
|
7
|
-
class Response < ::StandardError
|
8
|
-
module Headers
|
9
|
-
COMMON_HEADERS = %w[Content-Type].freeze
|
10
|
-
HEADER_LINE_PARSER = /\A([^:]+):(.*)\z/.to_parser do |m|
|
11
|
-
[m[1].strip, m[2].strip]
|
12
|
-
end
|
13
|
-
|
14
|
-
def header(name)
|
15
|
-
hash_search(headers, name)
|
16
|
-
end
|
17
|
-
|
18
|
-
# @return [Hash<String, String>]
|
19
|
-
def headers
|
20
|
-
performed.headers.to_hash
|
21
|
-
end
|
22
|
-
|
23
|
-
COMMON_HEADERS.each do |header_key|
|
24
|
-
define_method header_key.underscore do
|
25
|
-
header(header_key)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def hash_search(hash, key)
|
32
|
-
key = key.to_s.downcase
|
33
|
-
hash.each do |k, v|
|
34
|
-
return v if k.to_s.downcase == key
|
35
|
-
end
|
36
|
-
nil
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
module EacEnvs
|
5
|
-
module Http
|
6
|
-
class Response < ::StandardError
|
7
|
-
module Links
|
8
|
-
# https://www.w3.org/wiki/LinkHeader
|
9
|
-
LINKS_HEADER_NAME = 'Link'
|
10
|
-
|
11
|
-
# https://www.w3.org/wiki/LinkHeader
|
12
|
-
LINK_PARSER = /\A\<(.+)\>\s*;\s*rel\s*=\s*\"(.*)\"\z/.to_parser do |m|
|
13
|
-
[m[2], m[1]]
|
14
|
-
end
|
15
|
-
|
16
|
-
def link(rel)
|
17
|
-
hash_search(links, rel)
|
18
|
-
end
|
19
|
-
|
20
|
-
def links
|
21
|
-
header(LINKS_HEADER_NAME).if_present({}) do |v|
|
22
|
-
v.split(',').map { |w| LINK_PARSER.parse!(w.strip) }.to_h
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
|
5
|
-
module EacEnvs
|
6
|
-
module Http
|
7
|
-
class Response < ::StandardError
|
8
|
-
module Statuses
|
9
|
-
def raise_unless_200
|
10
|
-
return nil if status >= 200 && status < 300
|
11
|
-
|
12
|
-
raise self
|
13
|
-
end
|
14
|
-
|
15
|
-
def status
|
16
|
-
performed.status.to_i
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'active_support/core_ext/hash/conversions'
|
4
|
-
require 'eac_envs/http/error'
|
5
|
-
require 'eac_ruby_utils/core_ext'
|
6
|
-
require 'faraday'
|
7
|
-
require 'json'
|
8
|
-
|
9
|
-
module EacEnvs
|
10
|
-
module Http
|
11
|
-
class Response < ::StandardError
|
12
|
-
common_constructor :request
|
13
|
-
delegate :url, to: :request
|
14
|
-
|
15
|
-
def to_s
|
16
|
-
"URL: #{url}\nStatus: #{status}\nBody:\n\n#{body_str}"
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def performed
|
22
|
-
@performed ||= request.faraday_response
|
23
|
-
rescue ::Faraday::Error
|
24
|
-
raise ::EacEnvs::Http::Error
|
25
|
-
end
|
26
|
-
|
27
|
-
require_sub __FILE__, include_modules: true
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_envs/http/request'
|
4
|
-
require 'eac_ruby_utils/core_ext'
|
5
|
-
require 'webrick'
|
6
|
-
|
7
|
-
module EacEnvs
|
8
|
-
module Http
|
9
|
-
module Rspec
|
10
|
-
class EchoServer
|
11
|
-
class RequestProcessor
|
12
|
-
REQUEST_TO_DATA = {
|
13
|
-
ssl: :ssl?,
|
14
|
-
method: :request_method,
|
15
|
-
uri: :unparsed_uri,
|
16
|
-
body: :body
|
17
|
-
}.freeze
|
18
|
-
|
19
|
-
common_constructor :request, :response
|
20
|
-
|
21
|
-
def perform
|
22
|
-
response.body = response_body
|
23
|
-
response.header['Content-type'] = 'application/json'
|
24
|
-
response.status = 200
|
25
|
-
end
|
26
|
-
|
27
|
-
def request_data
|
28
|
-
REQUEST_TO_DATA.map { |k, v| [k, request.send(v)] }.to_h.merge(headers: request_headers)
|
29
|
-
end
|
30
|
-
|
31
|
-
def request_headers
|
32
|
-
request.header.map { |k, v| [k, v.first] }.to_h
|
33
|
-
end
|
34
|
-
|
35
|
-
def response_body
|
36
|
-
::JSON.generate(request_data)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_envs/http/request'
|
4
|
-
require 'eac_envs/http/rspec/echo_server/request_processor'
|
5
|
-
require 'eac_ruby_utils/core_ext'
|
6
|
-
require 'webrick'
|
7
|
-
|
8
|
-
module EacEnvs
|
9
|
-
module Http
|
10
|
-
module Rspec
|
11
|
-
class EchoServer
|
12
|
-
class WebrickServlet < WEBrick::HTTPServlet::AbstractServlet
|
13
|
-
::EacEnvs::Http::Request.lists.verb.each_value do |verb|
|
14
|
-
define_method "do_#{verb.to_s.upcase}" do |request, response|
|
15
|
-
::EacEnvs::Http::Rspec::EchoServer::RequestProcessor.new(request, response).perform
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'addressable'
|
4
|
-
require 'eac_ruby_utils/core_ext'
|
5
|
-
require 'webrick'
|
6
|
-
require 'webrick/https'
|
7
|
-
|
8
|
-
module EacEnvs
|
9
|
-
module Http
|
10
|
-
module Rspec
|
11
|
-
class EchoServer
|
12
|
-
HOSTNAME = 'localhost'
|
13
|
-
SCHEMES = {
|
14
|
-
http: { Port: 8080 },
|
15
|
-
https: { Port: 8443, SSLEnable: true, SSLCertName: [['CN', HOSTNAME]] }
|
16
|
-
}.freeze
|
17
|
-
|
18
|
-
class << self
|
19
|
-
SCHEMES.each do |scheme, webrick_options|
|
20
|
-
# @return [::EacEnvs::Http::Rspec::EchoServer]
|
21
|
-
define_method scheme do
|
22
|
-
new(scheme, webrick_options)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
common_constructor :scheme, :webrick_options
|
28
|
-
|
29
|
-
def on_active(&block)
|
30
|
-
servlet = webrick_servlet
|
31
|
-
::Thread.abort_on_exception = true
|
32
|
-
servlet_thread = ::Thread.new { servlet.start }
|
33
|
-
begin
|
34
|
-
sleep 0.001 while servlet.status != :Running
|
35
|
-
block.call
|
36
|
-
ensure
|
37
|
-
servlet.shutdown
|
38
|
-
servlet_thread.join
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def root_url
|
43
|
-
::Addressable::URI.new(
|
44
|
-
scheme: scheme.to_s,
|
45
|
-
host: ::EacEnvs::Http::Rspec::EchoServer::HOSTNAME,
|
46
|
-
port: webrick_options.fetch(:Port)
|
47
|
-
)
|
48
|
-
end
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
# @return [EacEnvs::Http::Rspec::EchoServer::WebrickServlet]
|
53
|
-
def webrick_servlet
|
54
|
-
r = ::WEBrick::HTTPServer.new(webrick_options)
|
55
|
-
r.mount '/', ::EacEnvs::Http::Rspec::EchoServer::WebrickServlet
|
56
|
-
r
|
57
|
-
end
|
58
|
-
|
59
|
-
require_sub __FILE__
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_envs/http/request/body_fields'
|
4
|
-
|
5
|
-
::RSpec.describe ::EacEnvs::Http::Request::BodyFields do
|
6
|
-
describe '#to_h' do
|
7
|
-
[
|
8
|
-
[
|
9
|
-
{ field1: 'value1', field2: %w[value2 value3] },
|
10
|
-
{ 'field1' => ['value1'], 'field2' => %w[value2 value3] }
|
11
|
-
], [
|
12
|
-
'field1=value1&field2=value2',
|
13
|
-
nil
|
14
|
-
], [
|
15
|
-
[%w[field1 value1], %w[field2 value2], %w[field2 value3]],
|
16
|
-
{ 'field1' => ['value1'], 'field2' => %w[value2 value3] }
|
17
|
-
]
|
18
|
-
].each do |d|
|
19
|
-
source_body = d[0]
|
20
|
-
expected_result = d[1]
|
21
|
-
context "when source_body is #{source_body}" do
|
22
|
-
let(:instance) { described_class.new(source_body) }
|
23
|
-
|
24
|
-
it do
|
25
|
-
expect(instance.to_h).to eq(expected_result)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
context 'when source_body has a file' do
|
31
|
-
let(:file) do
|
32
|
-
temp = ::EacRubyUtils::Fs::Temp.file
|
33
|
-
temp.write('TEMPORARY')
|
34
|
-
::File.new(temp.to_path)
|
35
|
-
end
|
36
|
-
let(:source_body) { { file1: file } }
|
37
|
-
let(:instance) { described_class.new(source_body) }
|
38
|
-
let(:expected_file) { ::Faraday::Multipart::FilePart.new(file.path, 'text/plain') }
|
39
|
-
|
40
|
-
%w[class original_filename local_path content_type].each do |attr|
|
41
|
-
it do
|
42
|
-
expect(instance.to_h.fetch('file1').first.send(attr)).to eq(expected_file.send(attr))
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_envs/http/error'
|
4
|
-
require 'eac_envs/http/request'
|
5
|
-
require 'eac_envs/http/rspec/echo_server'
|
6
|
-
|
7
|
-
::RSpec.describe ::EacEnvs::Http::Request do
|
8
|
-
let(:http_server) { ::EacEnvs::Http::Rspec::EchoServer.http }
|
9
|
-
|
10
|
-
around { |example| http_server.on_active(&example) }
|
11
|
-
|
12
|
-
before do
|
13
|
-
allow_any_instance_of(::Faraday::Multipart::Middleware).to( # rubocop:disable RSpec/AnyInstance
|
14
|
-
receive(:unique_boundary)
|
15
|
-
.and_return('-----------RubyMultipartPost-0123456789abcdef0123456789abcdef')
|
16
|
-
)
|
17
|
-
end
|
18
|
-
|
19
|
-
include_examples 'source_target_fixtures', __FILE__
|
20
|
-
|
21
|
-
def source_data(source_file)
|
22
|
-
remove_variable_values(
|
23
|
-
::JSON.parse(
|
24
|
-
::RequestBuilder.from_file(http_server.root_url, source_file).result.response.body_str
|
25
|
-
)
|
26
|
-
)
|
27
|
-
end
|
28
|
-
|
29
|
-
def remove_variable_values(obj)
|
30
|
-
if obj.is_a?(::Hash)
|
31
|
-
remove_variable_values_from_hash(obj)
|
32
|
-
elsif obj.is_a?(::Enumerable)
|
33
|
-
remove_variable_values_from_enumerable(obj)
|
34
|
-
end
|
35
|
-
obj
|
36
|
-
end
|
37
|
-
|
38
|
-
def remove_variable_values_from_hash(hash)
|
39
|
-
%w[host hostname ip].each { |key| hash.delete(key) }
|
40
|
-
hash.each_value { |value| remove_variable_values(value) }
|
41
|
-
end
|
42
|
-
|
43
|
-
def remove_variable_values_from_enumerable(enumerable)
|
44
|
-
enumerable.each { |value| remove_variable_values(value) }
|
45
|
-
end
|
46
|
-
|
47
|
-
context 'with self signed https server' do
|
48
|
-
let(:http_server) { ::EacEnvs::Http::Rspec::EchoServer.https }
|
49
|
-
let(:instance) { described_class.new.url(http_server.root_url + '/any/path') }
|
50
|
-
let(:response_body) { request.response.body_str }
|
51
|
-
|
52
|
-
context 'when no additional flag' do
|
53
|
-
let(:request) { instance }
|
54
|
-
|
55
|
-
it do
|
56
|
-
expect { response_body }.to(raise_error(::EacEnvs::Http::Error))
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
context 'when ssl_verify disabled' do
|
61
|
-
let(:request) { instance.ssl_verify(false) }
|
62
|
-
|
63
|
-
it do
|
64
|
-
expect { response_body }.not_to raise_error
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|