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,81 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
require 'eac_ruby_utils/yaml'
|
5
|
-
require 'fileutils'
|
6
|
-
|
7
|
-
module EacFs
|
8
|
-
class StorageTree
|
9
|
-
CONTENT_FILE_NAME = '__content__'
|
10
|
-
|
11
|
-
attr_reader :path
|
12
|
-
|
13
|
-
def initialize(*path_parts)
|
14
|
-
raise ArgumentError, "\"#{path_parts}\" is empty" if path_parts.empty?
|
15
|
-
|
16
|
-
@path = ::File.expand_path(::File.join(*path_parts.map(&:to_s)))
|
17
|
-
end
|
18
|
-
|
19
|
-
def clear
|
20
|
-
return unless stored?
|
21
|
-
|
22
|
-
::File.unlink(content_path)
|
23
|
-
end
|
24
|
-
|
25
|
-
def read
|
26
|
-
return nil unless stored?
|
27
|
-
|
28
|
-
::File.read(content_path)
|
29
|
-
end
|
30
|
-
|
31
|
-
def read_or_store
|
32
|
-
write(yield) unless stored?
|
33
|
-
|
34
|
-
read
|
35
|
-
end
|
36
|
-
|
37
|
-
# @return [Object]
|
38
|
-
def read_or_store_yaml(use_cache = true)
|
39
|
-
write_yaml(yield) unless stored? && use_cache
|
40
|
-
|
41
|
-
read_yaml
|
42
|
-
end
|
43
|
-
|
44
|
-
# @return [Object, nil]
|
45
|
-
def read_yaml
|
46
|
-
r = read
|
47
|
-
r.nil? ? nil : ::EacRubyUtils::Yaml.load(r)
|
48
|
-
end
|
49
|
-
|
50
|
-
def write(value)
|
51
|
-
assert_directory_on_path
|
52
|
-
::File.write(content_path, value)
|
53
|
-
value
|
54
|
-
end
|
55
|
-
|
56
|
-
def write_yaml(object)
|
57
|
-
write(::EacRubyUtils::Yaml.dump(object))
|
58
|
-
object
|
59
|
-
end
|
60
|
-
|
61
|
-
def child(*child_path_parts)
|
62
|
-
self.class.new(path, *child_path_parts)
|
63
|
-
end
|
64
|
-
|
65
|
-
def stored?
|
66
|
-
::File.exist?(content_path)
|
67
|
-
end
|
68
|
-
|
69
|
-
def content_path
|
70
|
-
::File.join(path, CONTENT_FILE_NAME)
|
71
|
-
end
|
72
|
-
|
73
|
-
private
|
74
|
-
|
75
|
-
def assert_directory_on_path
|
76
|
-
raise "#{path} is a file" if ::File.file?(path)
|
77
|
-
|
78
|
-
::FileUtils.mkdir_p(path)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_fs/traverser'
|
4
|
-
|
5
|
-
module EacFs
|
6
|
-
module Traversable
|
7
|
-
PROP_METHOD_PREFIX = 'traverser_'
|
8
|
-
BOOLEAN_PROPS = %i[hidden_directories recursive sort].freeze
|
9
|
-
PATH_PROPS = %i[check_directory check_file].freeze
|
10
|
-
|
11
|
-
class << self
|
12
|
-
def prop_method_name(prop)
|
13
|
-
"#{PROP_METHOD_PREFIX}#{prop}"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
PATH_PROPS.each do |method|
|
18
|
-
define_method(::EacFs::Traversable.prop_method_name(method)) do |_path|
|
19
|
-
nil
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
BOOLEAN_PROPS.each do |method|
|
24
|
-
define_method(::EacFs::Traversable.prop_method_name(method)) do
|
25
|
-
false
|
26
|
-
end
|
27
|
-
|
28
|
-
define_method("#{::EacFs::Traversable.prop_method_name(method)}?") do
|
29
|
-
send(method_name)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def traverser_check_path(path)
|
34
|
-
traverser_new.check_path(path)
|
35
|
-
end
|
36
|
-
|
37
|
-
def traverser_new
|
38
|
-
r = ::EacFs::Traverser.new
|
39
|
-
(BOOLEAN_PROPS + PATH_PROPS).each do |prop|
|
40
|
-
r.send("#{prop}=", method(::EacFs::Traversable.prop_method_name(prop)))
|
41
|
-
end
|
42
|
-
r
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,76 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module EacFs
|
4
|
-
class Traverser
|
5
|
-
attr_accessor :check_directory, :check_file, :recursive, :hidden_directories, :sort
|
6
|
-
|
7
|
-
def initialize(options = {})
|
8
|
-
options.each do |accessor, value|
|
9
|
-
send("#{accessor}=", value)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def check_path(path)
|
14
|
-
path = ::Pathname.new(path.to_s) unless path.is_a?(::Pathname)
|
15
|
-
internal_check_path(path, 0)
|
16
|
-
end
|
17
|
-
|
18
|
-
def hidden_directories?
|
19
|
-
boolean_value(hidden_directories)
|
20
|
-
end
|
21
|
-
|
22
|
-
def recursive?
|
23
|
-
boolean_value(recursive)
|
24
|
-
end
|
25
|
-
|
26
|
-
def sort?
|
27
|
-
boolean_value(sort)
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def boolean_value(source_value)
|
33
|
-
source_value = source_value.call if source_value.respond_to?(:call)
|
34
|
-
source_value ? true : false
|
35
|
-
end
|
36
|
-
|
37
|
-
def each_child(dir, &block)
|
38
|
-
if sort?
|
39
|
-
dir.each_child.sort_by { |p| [p.to_s] }.each(&block)
|
40
|
-
else
|
41
|
-
dir.each_child(&block)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def process_directory?(level)
|
46
|
-
level.zero? || recursive?
|
47
|
-
end
|
48
|
-
|
49
|
-
def inner_check_directory(dir, level)
|
50
|
-
return unless process_directory?(level)
|
51
|
-
|
52
|
-
user_check_directory(dir)
|
53
|
-
each_child(dir) do |e|
|
54
|
-
next unless !e.basename.to_s.start_with?('.') || hidden_directories?
|
55
|
-
|
56
|
-
internal_check_path(e, level + 1)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def internal_check_path(path, level)
|
61
|
-
if path.file?
|
62
|
-
user_check_file(path)
|
63
|
-
elsif path.directory?
|
64
|
-
inner_check_directory(path, level)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def user_check_file(path)
|
69
|
-
check_file&.call(path)
|
70
|
-
end
|
71
|
-
|
72
|
-
def user_check_directory(path)
|
73
|
-
check_directory&.call(path)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
data/sub/eac_fs/lib/eac_fs.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'active_support/core_ext/object/blank'
|
4
|
-
require 'eac_fs/storage_tree'
|
5
|
-
|
6
|
-
RSpec.describe ::EacFs::StorageTree do
|
7
|
-
let(:tmpdir) { ::Dir.mktmpdir }
|
8
|
-
let(:instance) { described_class.new(tmpdir, 'instance') }
|
9
|
-
|
10
|
-
it { expect(instance.read).to be_blank }
|
11
|
-
it { expect(instance.stored?).to eq(false) }
|
12
|
-
|
13
|
-
context 'when instance is writed' do
|
14
|
-
before { instance.write('STUB') }
|
15
|
-
|
16
|
-
it { expect(instance.read).to eq('STUB') }
|
17
|
-
it { expect(instance.stored?).to eq(true) }
|
18
|
-
|
19
|
-
context 'when instance is cleared' do
|
20
|
-
before { instance.clear }
|
21
|
-
|
22
|
-
it { expect(instance.read).to be_blank }
|
23
|
-
it { expect(instance.stored?).to eq(false) }
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '#child' do
|
28
|
-
let(:child) { instance.child('child') }
|
29
|
-
|
30
|
-
it { expect(child.path).to match(/\A#{::Regexp.quote(instance.path)}/) }
|
31
|
-
end
|
32
|
-
end
|
data/sub/eac_rest/Gemfile
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
4
|
-
|
5
|
-
require 'eac_rest/version'
|
6
|
-
|
7
|
-
Gem::Specification.new do |s|
|
8
|
-
s.name = 'eac_rest'
|
9
|
-
s.version = EacRest::VERSION
|
10
|
-
s.authors = ['Eduardo H. Bogoni']
|
11
|
-
s.summary = 'A REST helper for Ruby.'
|
12
|
-
|
13
|
-
s.files = Dir['{lib}/**/*']
|
14
|
-
|
15
|
-
s.add_dependency 'eac_envs-http', '~> 0.4', '>= 0.4.1'
|
16
|
-
s.add_dependency 'eac_fs', '~> 0.16'
|
17
|
-
s.add_dependency 'eac_ruby_utils', '~> 0.119', '>= 0.119.1'
|
18
|
-
|
19
|
-
s.add_development_dependency 'aranha-parsers', '~> 0.15'
|
20
|
-
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.5.1'
|
21
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_rest/helper'
|
4
|
-
require 'eac_rest/request'
|
5
|
-
require 'eac_ruby_utils/core_ext'
|
6
|
-
|
7
|
-
module EacRest
|
8
|
-
# Abstract methods
|
9
|
-
# * self.issue_get_url_suffix(provider_issue_id)
|
10
|
-
class Api
|
11
|
-
DEFAULT_ROOT_ENTITY_CLASS_NAME_SUFFIX = 'Root'
|
12
|
-
|
13
|
-
require_sub __FILE__, include_modules: true
|
14
|
-
attr_accessor :ssl_verify
|
15
|
-
common_constructor :root_url, :username, :password, default: [nil, nil] do
|
16
|
-
self.ssl_verify = true
|
17
|
-
end
|
18
|
-
|
19
|
-
# @param entity_class [Class]
|
20
|
-
# @param url_suffix [String]
|
21
|
-
# @return [EacRest::Entity]
|
22
|
-
def entity(entity_class, data_or_id, options = {})
|
23
|
-
entity_class.new(self, data_or_id, options)
|
24
|
-
end
|
25
|
-
|
26
|
-
def request(service_url_suffix, headers = {}, &body_data_proc)
|
27
|
-
r = ::EacRest::Request.new(build_service_url(service_url_suffix),
|
28
|
-
body_data_proc).ssl_verify(ssl_verify)
|
29
|
-
headers.each { |name, value| r = r.header(name, value) }
|
30
|
-
r = r.autenticate(username, password) if username.present?
|
31
|
-
r
|
32
|
-
end
|
33
|
-
|
34
|
-
def request_json(service_url_suffix, headers = {}, &body_data_proc)
|
35
|
-
request(service_url_suffix, headers.merge('Accept' => 'application/json')) do |body_data|
|
36
|
-
r = body_data.is_a?(::Enumerable) ? body_data : ::JSON.parse(body_data)
|
37
|
-
r = body_data_proc.call(r) if body_data_proc
|
38
|
-
r
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# @return [Addressable::URI]
|
43
|
-
def build_service_url(suffix)
|
44
|
-
::EacRest::Helper.url_join(root_url, suffix)
|
45
|
-
end
|
46
|
-
|
47
|
-
# @return [EacRest::Entity]
|
48
|
-
def root_entity
|
49
|
-
@root_entity ||= root_entity_class.new(self, nil)
|
50
|
-
end
|
51
|
-
|
52
|
-
# @return [Class]
|
53
|
-
def root_entity_class
|
54
|
-
self.class.const_get(DEFAULT_ROOT_ENTITY_CLASS_NAME_SUFFIX)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
|
5
|
-
module EacRest
|
6
|
-
class Entity
|
7
|
-
module Data
|
8
|
-
common_concern
|
9
|
-
|
10
|
-
# @return [Hash]
|
11
|
-
def data
|
12
|
-
if internal_data.blank?
|
13
|
-
self.internal_data = data_or_id_data? ? data_or_id : data_from_id
|
14
|
-
end
|
15
|
-
|
16
|
-
internal_data
|
17
|
-
end
|
18
|
-
|
19
|
-
# @return [Boolean]
|
20
|
-
def data_or_id_data?
|
21
|
-
data_or_id.is_a?(::Hash)
|
22
|
-
end
|
23
|
-
|
24
|
-
# @return [Hash]
|
25
|
-
def data_from_id
|
26
|
-
raise_abstract_method __method__
|
27
|
-
end
|
28
|
-
|
29
|
-
# @return [Object]
|
30
|
-
def id
|
31
|
-
data_or_id_data? ? id_from_data : data_or_id
|
32
|
-
end
|
33
|
-
|
34
|
-
# @return [Object]
|
35
|
-
def id_from_data
|
36
|
-
raise_abstract_method __method__
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
attr_accessor :internal_data
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_rest/helper'
|
4
|
-
require 'eac_ruby_utils/core_ext'
|
5
|
-
|
6
|
-
module EacRest
|
7
|
-
class Entity
|
8
|
-
module Fetching
|
9
|
-
# @return [Addressable::URI]
|
10
|
-
def entity_root_url_suffix
|
11
|
-
parent_entity.if_present('', &:entity_root_url_suffix).to_uri
|
12
|
-
end
|
13
|
-
|
14
|
-
# @return [EacRest::Request]
|
15
|
-
def request(url_suffix)
|
16
|
-
api.request(::EacRest::Helper.url_join(entity_root_url_suffix, url_suffix))
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
|
5
|
-
module EacRest
|
6
|
-
class Entity
|
7
|
-
enable_abstract_methods
|
8
|
-
enable_simple_cache
|
9
|
-
enable_listable
|
10
|
-
lists.add_symbol :option, :parent
|
11
|
-
common_constructor :api, :data_or_id, :options, default: [{}] do
|
12
|
-
self.options = ::EacRest::Entity.lists.option.hash_keys_validate!(options)
|
13
|
-
end
|
14
|
-
|
15
|
-
class << self
|
16
|
-
def from_array_data(api, array_data, *args)
|
17
|
-
array_data.map { |item_data| new(api, item_data, *args) }
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
# @param entity_class [Class]
|
22
|
-
# @param url_suffix [String]
|
23
|
-
# @return [EacRest::Entity]
|
24
|
-
def child_entity(entity_class, data_or_id, options = {})
|
25
|
-
api.entity(entity_class, data_or_id, options.merge(OPTION_PARENT => self))
|
26
|
-
end
|
27
|
-
|
28
|
-
# @return [EacRest::Entity, nil]
|
29
|
-
def parent_entity
|
30
|
-
options[OPTION_PARENT]
|
31
|
-
end
|
32
|
-
|
33
|
-
require_sub __FILE__, include_modules: :include
|
34
|
-
end
|
35
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
|
5
|
-
module EacRest
|
6
|
-
module Helper
|
7
|
-
# @param parts [Array<Addressable::URI>]
|
8
|
-
# @return [Addressable::URI]
|
9
|
-
def url_join(*parts)
|
10
|
-
left = parts.shift
|
11
|
-
left = url_join_pair(left, parts.shift) while parts.any?
|
12
|
-
left
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
# @param left [Addressable::URI]
|
18
|
-
# @param right [Addressable::URI]
|
19
|
-
# @return [Addressable::URI]
|
20
|
-
def url_join_pair(left, right)
|
21
|
-
r = ::Addressable::URI.parse(right)
|
22
|
-
return r if r.scheme.present?
|
23
|
-
|
24
|
-
s = ::Addressable::URI.parse(right)
|
25
|
-
r = ::Addressable::URI.parse(left)
|
26
|
-
r.path += s.path
|
27
|
-
r.query_values = r.query_values(::Array).if_present([]) +
|
28
|
-
s.query_values(::Array).if_present([])
|
29
|
-
r
|
30
|
-
end
|
31
|
-
|
32
|
-
extend self
|
33
|
-
end
|
34
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_envs/http/request'
|
4
|
-
require 'eac_rest/response'
|
5
|
-
require 'eac_ruby_utils/core_ext'
|
6
|
-
|
7
|
-
module EacRest
|
8
|
-
class Request
|
9
|
-
attr_reader :internal_request
|
10
|
-
|
11
|
-
# @param url [EacEnvs::Http::Request, String]
|
12
|
-
# @param response_body_data_proc [Proc, nil]
|
13
|
-
def initialize(url, response_body_data_proc = nil)
|
14
|
-
if url.is_a?(::EacEnvs::Http::Request)
|
15
|
-
@internal_request = url
|
16
|
-
else
|
17
|
-
@internal_request = ::EacEnvs::Http::Request.new.url(url)
|
18
|
-
response_body_data_proc.if_present do |v|
|
19
|
-
@internal_request = @internal_request.response_body_data_proc(v)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
delegate :sanitized_verb, :url, to: :internal_request
|
25
|
-
|
26
|
-
{
|
27
|
-
auth: 0, body_data: 0, header: 1, headers: 0, ssl_verify: 0, verb: 0
|
28
|
-
}.each do |method_name, read_args_count|
|
29
|
-
define_method method_name do |*args|
|
30
|
-
if args.count <= read_args_count
|
31
|
-
internal_request.send(method_name, *args)
|
32
|
-
else
|
33
|
-
self.class.new(internal_request.send(method_name, *args))
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
# @return [EacRest::Request]
|
39
|
-
def autenticate(username, password)
|
40
|
-
self.class.new(internal_request.basic_auth(username, password))
|
41
|
-
end
|
42
|
-
|
43
|
-
# @return [EacRest::Response]
|
44
|
-
def response
|
45
|
-
::EacRest::Response.new(self)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_rest/error'
|
4
|
-
require 'eac_envs/http/error'
|
5
|
-
require 'eac_ruby_utils/core_ext'
|
6
|
-
|
7
|
-
module EacRest
|
8
|
-
class Response < ::StandardError
|
9
|
-
common_constructor :request
|
10
|
-
delegate :body_data_proc, to: :request
|
11
|
-
|
12
|
-
def internal_response
|
13
|
-
@internal_response ||= request.internal_request.response
|
14
|
-
end
|
15
|
-
|
16
|
-
%i[body_data body_data_or_raise body_str body_str_or_raise header headers
|
17
|
-
link links raise_unless_200 status to_s url].each do |method_name|
|
18
|
-
define_method method_name do |*args, &block|
|
19
|
-
internal_response.send(method_name, *args, &block)
|
20
|
-
rescue ::EacEnvs::Http::Error
|
21
|
-
raise ::EacRest::Error
|
22
|
-
rescue ::EacEnvs::Http::Response
|
23
|
-
raise self
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_rest/api'
|
4
|
-
require 'eac_envs/http/rspec/echo_server'
|
5
|
-
|
6
|
-
::RSpec.describe ::EacRest::Api do
|
7
|
-
let(:instance) { described_class.new(http_server.root_url) }
|
8
|
-
let(:http_server) { ::EacEnvs::Http::Rspec::EchoServer.http }
|
9
|
-
|
10
|
-
around do |example|
|
11
|
-
http_server.on_active(&example)
|
12
|
-
end
|
13
|
-
|
14
|
-
before do
|
15
|
-
allow_any_instance_of(::Faraday::Multipart::Middleware).to( # rubocop:disable RSpec/AnyInstance
|
16
|
-
receive(:unique_boundary)
|
17
|
-
.and_return('-----------RubyMultipartPost-0123456789abcdef0123456789abcdef')
|
18
|
-
)
|
19
|
-
end
|
20
|
-
|
21
|
-
include_examples 'source_target_fixtures', __FILE__
|
22
|
-
|
23
|
-
def source_data(source_file)
|
24
|
-
remove_variable_values(
|
25
|
-
::JSON.parse(
|
26
|
-
::RequestBuilder.from_file(instance, source_file).result.response.body_str
|
27
|
-
)
|
28
|
-
)
|
29
|
-
end
|
30
|
-
|
31
|
-
def remove_variable_values(obj)
|
32
|
-
if obj.is_a?(::Hash)
|
33
|
-
remove_variable_values_from_hash(obj)
|
34
|
-
elsif obj.is_a?(::Enumerable)
|
35
|
-
remove_variable_values_from_enumerable(obj)
|
36
|
-
end
|
37
|
-
obj
|
38
|
-
end
|
39
|
-
|
40
|
-
def remove_variable_values_from_hash(hash)
|
41
|
-
%w[host hostname ip].each { |key| hash.delete(key) }
|
42
|
-
hash.each_value { |value| remove_variable_values(value) }
|
43
|
-
end
|
44
|
-
|
45
|
-
def remove_variable_values_from_enumerable(enumerable)
|
46
|
-
enumerable.each { |value| remove_variable_values(value) }
|
47
|
-
end
|
48
|
-
|
49
|
-
context 'with self signed https server' do
|
50
|
-
let(:http_server) { ::EacEnvs::Http::Rspec::EchoServer.https }
|
51
|
-
let(:instance) { described_class.new(http_server.root_url) }
|
52
|
-
let(:request_base) { instance.request('/any/path') }
|
53
|
-
let(:response_body) { request.response.body_str }
|
54
|
-
|
55
|
-
context 'when no additional flag' do
|
56
|
-
let(:request) { request_base }
|
57
|
-
|
58
|
-
it do
|
59
|
-
expect { response_body }.to(raise_error(::EacRest::Error))
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
context 'when ssl_verify disabled' do
|
64
|
-
let(:request) { request_base.ssl_verify(false) }
|
65
|
-
|
66
|
-
it do
|
67
|
-
expect { response_body }.not_to raise_error
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|