eac_tools 0.82.0 → 0.83.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 +45 -40
- data/lib/eac_tools/version.rb +1 -1
- data/sub/avm/avm.gemspec +4 -3
- data/sub/avm/lib/avm/data/rotate.rb +1 -1
- data/sub/avm/lib/avm/launcher/instances/base/publishing.rb +1 -1
- data/sub/avm/lib/avm/registry/from_gems.rb +2 -2
- data/sub/avm/lib/avm/rspec/shared_examples/avm_file_formats_with_fixtures.rb +0 -1
- data/sub/avm/lib/avm/source_generators/base.rb +1 -0
- data/sub/avm/lib/avm/source_generators/runner.rb +6 -0
- data/sub/avm/lib/avm/sources/tests/builder.rb +1 -1
- data/sub/avm/lib/avm/version.rb +1 -1
- data/sub/avm/spec/lib/avm/launcher/instances/base_spec_files/projects/avm-tools_stub/avm-tools.gemspec +1 -0
- data/sub/avm/spec/lib/avm/launcher/instances/base_spec_files/projects/ruby_gem_stub/ruby_gem_stub.gemspec +1 -0
- data/sub/avm-eac_asciidoctor_base0/Gemfile +2 -2
- data/sub/avm-eac_asciidoctor_base0/avm-eac_asciidoctor_base0.gemspec +6 -5
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/header_lines.rb +5 -3
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document.rb +2 -2
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/base/document.rb +2 -2
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/base.rb +1 -3
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/version.rb +1 -1
- data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/file_formats/base_spec.rb +1 -1
- data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/instances/build/document_spec.rb +18 -18
- data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/instances/build/document_spec_files/pre_processed_root_body.adoc +1 -0
- data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/instances/build_spec.rb +3 -3
- data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/source_generators/base_spec.rb +1 -1
- data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/sources/base_spec.rb +2 -2
- data/sub/avm-eac_asciidoctor_base0/spec/rubocop_spec.rb +1 -1
- data/sub/avm-eac_asciidoctor_base0/spec/spec_helper/eac_asciidoctor_base0_stubs.rb +1 -1
- data/sub/avm-eac_asciidoctor_base0/spec/spec_helper.rb +3 -3
- data/sub/avm-eac_python_base0/Gemfile +2 -2
- data/sub/avm-eac_python_base0/avm-eac_python_base0.gemspec +5 -4
- data/sub/avm-eac_python_base0/lib/avm/eac_python_base0/executables.rb +1 -1
- data/sub/avm-eac_python_base0/lib/avm/eac_python_base0/version.rb +1 -1
- data/sub/avm-eac_python_base0/spec/lib/avm/eac_python_base0/file_formats/base_spec.rb +1 -1
- data/sub/avm-eac_python_base0/spec/lib/avm/eac_python_base0/file_formats/base_spec_files/python_code.source +1 -1
- data/sub/avm-eac_python_base0/spec/lib/avm/eac_python_base0/file_formats/base_spec_files/python_code.target +1 -1
- data/sub/avm-eac_python_base0/spec/rubocop_spec.rb +1 -1
- data/sub/avm-eac_python_base0/spec/spec_helper.rb +1 -1
- data/sub/avm-eac_ruby_base1/avm-eac_ruby_base1.gemspec +2 -2
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rubocop_command.rb +2 -1
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/version.rb +1 -1
- metadata +14 -144
- data/sub/eac_cli/Gemfile +0 -8
- data/sub/eac_cli/eac_cli.gemspec +0 -22
- data/sub/eac_cli/lib/eac_cli/config/entry/options.rb +0 -58
- data/sub/eac_cli/lib/eac_cli/config/entry/undefined.rb +0 -31
- data/sub/eac_cli/lib/eac_cli/config/entry.rb +0 -60
- data/sub/eac_cli/lib/eac_cli/config.rb +0 -17
- data/sub/eac_cli/lib/eac_cli/core_ext.rb +0 -6
- data/sub/eac_cli/lib/eac_cli/default_runner.rb +0 -14
- data/sub/eac_cli/lib/eac_cli/definition/alternative.rb +0 -105
- data/sub/eac_cli/lib/eac_cli/definition/argument_option.rb +0 -21
- data/sub/eac_cli/lib/eac_cli/definition/boolean_option.rb +0 -27
- data/sub/eac_cli/lib/eac_cli/definition/error.rb +0 -8
- data/sub/eac_cli/lib/eac_cli/definition/option/initialize_args_parser.rb +0 -48
- data/sub/eac_cli/lib/eac_cli/definition/option.rb +0 -73
- data/sub/eac_cli/lib/eac_cli/definition/option_or_positional.rb +0 -43
- data/sub/eac_cli/lib/eac_cli/definition/positional.rb +0 -53
- data/sub/eac_cli/lib/eac_cli/definition.rb +0 -109
- data/sub/eac_cli/lib/eac_cli/enum.rb +0 -45
- data/sub/eac_cli/lib/eac_cli/old_configs/entry_reader.rb +0 -80
- data/sub/eac_cli/lib/eac_cli/old_configs/password_entry_reader.rb +0 -16
- data/sub/eac_cli/lib/eac_cli/old_configs/read_entry_options.rb +0 -44
- data/sub/eac_cli/lib/eac_cli/old_configs/store_passwords_entry_reader.rb +0 -25
- data/sub/eac_cli/lib/eac_cli/old_configs.rb +0 -35
- data/sub/eac_cli/lib/eac_cli/parser/alternative/any_options.rb +0 -19
- data/sub/eac_cli/lib/eac_cli/parser/alternative/argv.rb +0 -19
- data/sub/eac_cli/lib/eac_cli/parser/alternative/double_dash.rb +0 -24
- data/sub/eac_cli/lib/eac_cli/parser/alternative/long_options.rb +0 -37
- data/sub/eac_cli/lib/eac_cli/parser/alternative/option_argument.rb +0 -29
- data/sub/eac_cli/lib/eac_cli/parser/alternative/options.rb +0 -29
- data/sub/eac_cli/lib/eac_cli/parser/alternative/positionals.rb +0 -30
- data/sub/eac_cli/lib/eac_cli/parser/alternative/short_options.rb +0 -54
- data/sub/eac_cli/lib/eac_cli/parser/alternative.rb +0 -103
- data/sub/eac_cli/lib/eac_cli/parser/collector.rb +0 -55
- data/sub/eac_cli/lib/eac_cli/parser/error.rb +0 -15
- data/sub/eac_cli/lib/eac_cli/parser.rb +0 -34
- data/sub/eac_cli/lib/eac_cli/patches/object/runner_with.rb +0 -26
- data/sub/eac_cli/lib/eac_cli/patches/object.rb +0 -5
- data/sub/eac_cli/lib/eac_cli/patches.rb +0 -4
- data/sub/eac_cli/lib/eac_cli/rspec/setup.rb +0 -42
- data/sub/eac_cli/lib/eac_cli/rspec.rb +0 -9
- data/sub/eac_cli/lib/eac_cli/runner/after_class_methods.rb +0 -38
- data/sub/eac_cli/lib/eac_cli/runner/class_runner.rb +0 -36
- data/sub/eac_cli/lib/eac_cli/runner/context.rb +0 -63
- data/sub/eac_cli/lib/eac_cli/runner/context_responders/base.rb +0 -24
- data/sub/eac_cli/lib/eac_cli/runner/context_responders/parent.rb +0 -27
- data/sub/eac_cli/lib/eac_cli/runner/context_responders/runner.rb +0 -20
- data/sub/eac_cli/lib/eac_cli/runner/context_responders/runner_missing_method.rb +0 -32
- data/sub/eac_cli/lib/eac_cli/runner/context_responders/set.rb +0 -44
- data/sub/eac_cli/lib/eac_cli/runner/context_responders.rb +0 -11
- data/sub/eac_cli/lib/eac_cli/runner/exit.rb +0 -14
- data/sub/eac_cli/lib/eac_cli/runner/for_context.rb +0 -40
- data/sub/eac_cli/lib/eac_cli/runner/instance_methods.rb +0 -45
- data/sub/eac_cli/lib/eac_cli/runner.rb +0 -50
- data/sub/eac_cli/lib/eac_cli/runner_with/confirmation.rb +0 -44
- data/sub/eac_cli/lib/eac_cli/runner_with/help/builder/alternative.rb +0 -63
- data/sub/eac_cli/lib/eac_cli/runner_with/help/builder.rb +0 -81
- data/sub/eac_cli/lib/eac_cli/runner_with/help/layout.rb +0 -40
- data/sub/eac_cli/lib/eac_cli/runner_with/help.rb +0 -53
- data/sub/eac_cli/lib/eac_cli/runner_with/input.rb +0 -36
- data/sub/eac_cli/lib/eac_cli/runner_with/output.rb +0 -58
- data/sub/eac_cli/lib/eac_cli/runner_with/output_item/base_formatter.rb +0 -15
- data/sub/eac_cli/lib/eac_cli/runner_with/output_item/csv_formatter.rb +0 -23
- data/sub/eac_cli/lib/eac_cli/runner_with/output_item/yaml_formatter.rb +0 -18
- data/sub/eac_cli/lib/eac_cli/runner_with/output_item.rb +0 -42
- data/sub/eac_cli/lib/eac_cli/runner_with/output_list/base_formatter.rb +0 -30
- data/sub/eac_cli/lib/eac_cli/runner_with/output_list/csv_formatter.rb +0 -26
- data/sub/eac_cli/lib/eac_cli/runner_with/output_list/yaml_formatter.rb +0 -23
- data/sub/eac_cli/lib/eac_cli/runner_with/output_list.rb +0 -42
- data/sub/eac_cli/lib/eac_cli/runner_with/subcommands/definition_concern.rb +0 -10
- data/sub/eac_cli/lib/eac_cli/runner_with/subcommands.rb +0 -129
- data/sub/eac_cli/lib/eac_cli/runner_with.rb +0 -9
- data/sub/eac_cli/lib/eac_cli/runner_with_set.rb +0 -56
- data/sub/eac_cli/lib/eac_cli/speaker/constants.rb +0 -13
- data/sub/eac_cli/lib/eac_cli/speaker/input_blocked.rb +0 -16
- data/sub/eac_cli/lib/eac_cli/speaker/input_requested.rb +0 -8
- data/sub/eac_cli/lib/eac_cli/speaker/list.rb +0 -61
- data/sub/eac_cli/lib/eac_cli/speaker/options.rb +0 -38
- data/sub/eac_cli/lib/eac_cli/speaker.rb +0 -127
- data/sub/eac_cli/lib/eac_cli/version.rb +0 -5
- data/sub/eac_cli/lib/eac_cli.rb +0 -7
- data/sub/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb +0 -18
- data/sub/eac_cli/spec/lib/eac_cli/old_configs_spec.rb +0 -14
- data/sub/eac_cli/spec/lib/eac_cli/parser/alternative/subcommands_spec.rb +0 -58
- data/sub/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb +0 -89
- data/sub/eac_cli/spec/lib/eac_cli/runner/for_context_spec.rb +0 -79
- data/sub/eac_cli/spec/lib/eac_cli/runner_spec.rb +0 -129
- data/sub/eac_cli/spec/lib/eac_cli/runner_with/confirmation_spec.rb +0 -42
- data/sub/eac_cli/spec/lib/eac_cli/runner_with/help/layout_spec.rb +0 -21
- data/sub/eac_cli/spec/lib/eac_cli/runner_with/help_spec.rb +0 -51
- data/sub/eac_cli/spec/lib/eac_cli/runner_with/output_spec.rb +0 -81
- data/sub/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +0 -98
- data/sub/eac_cli/spec/lib/eac_cli/speaker_spec.rb +0 -32
- data/sub/eac_cli/spec/rubocop_spec.rb +0 -3
- data/sub/eac_cli/spec/spec_helper.rb +0 -4
- data/sub/eac_config/Gemfile +0 -8
- data/sub/eac_config/eac_config.gemspec +0 -19
- data/sub/eac_config/lib/eac_config/entries.rb +0 -35
- data/sub/eac_config/lib/eac_config/entry/not_found_error.rb +0 -13
- data/sub/eac_config/lib/eac_config/entry.rb +0 -64
- data/sub/eac_config/lib/eac_config/entry_path.rb +0 -89
- data/sub/eac_config/lib/eac_config/envvars_node/entry.rb +0 -54
- data/sub/eac_config/lib/eac_config/envvars_node.rb +0 -35
- data/sub/eac_config/lib/eac_config/load_nodes_search.rb +0 -39
- data/sub/eac_config/lib/eac_config/load_path.rb +0 -28
- data/sub/eac_config/lib/eac_config/node.rb +0 -81
- data/sub/eac_config/lib/eac_config/node_entry.rb +0 -28
- data/sub/eac_config/lib/eac_config/node_uri/instanciate_single.rb +0 -29
- data/sub/eac_config/lib/eac_config/node_uri.rb +0 -45
- data/sub/eac_config/lib/eac_config/old_configs/base.rb +0 -43
- data/sub/eac_config/lib/eac_config/old_configs/file.rb +0 -47
- data/sub/eac_config/lib/eac_config/old_configs.rb +0 -75
- data/sub/eac_config/lib/eac_config/paths_hash/entry_key_error.rb +0 -8
- data/sub/eac_config/lib/eac_config/paths_hash/node.rb +0 -67
- data/sub/eac_config/lib/eac_config/paths_hash/path_search.rb +0 -39
- data/sub/eac_config/lib/eac_config/paths_hash.rb +0 -63
- data/sub/eac_config/lib/eac_config/prefixed_path_node/entry.rb +0 -25
- data/sub/eac_config/lib/eac_config/prefixed_path_node.rb +0 -19
- data/sub/eac_config/lib/eac_config/rspec/setup.rb +0 -65
- data/sub/eac_config/lib/eac_config/rspec.rb +0 -9
- data/sub/eac_config/lib/eac_config/version.rb +0 -5
- data/sub/eac_config/lib/eac_config/yaml_file_node/entry.rb +0 -36
- data/sub/eac_config/lib/eac_config/yaml_file_node/self_entries.rb +0 -72
- data/sub/eac_config/lib/eac_config/yaml_file_node.rb +0 -54
- data/sub/eac_config/lib/eac_config.rb +0 -7
- data/sub/eac_config/spec/lib/eac_config/entry_path_spec.rb +0 -30
- data/sub/eac_config/spec/lib/eac_config/envvars_node/entry_spec.rb +0 -14
- data/sub/eac_config/spec/lib/eac_config/envvars_node_spec.rb +0 -51
- data/sub/eac_config/spec/lib/eac_config/old_configs_spec.rb +0 -46
- data/sub/eac_config/spec/lib/eac_config/paths_hash_spec.rb +0 -88
- data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec.rb +0 -88
- data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1.yaml +0 -10
- data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_1.yaml +0 -4
- data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_2/storage1_2_1.yaml +0 -4
- data/sub/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_2.yaml +0 -10
- data/sub/eac_config/spec/rubocop_spec.rb +0 -3
- data/sub/eac_config/spec/spec_helper.rb +0 -4
@@ -1,75 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'active_support/core_ext/string'
|
4
|
-
require 'yaml'
|
5
|
-
require 'eac_config/old_configs/file'
|
6
|
-
require 'eac_ruby_utils/patches/hash/sym_keys_hash'
|
7
|
-
require 'eac_config/paths_hash'
|
8
|
-
require 'eac_ruby_utils/simple_cache'
|
9
|
-
|
10
|
-
module EacConfig
|
11
|
-
# @deprecated Use {EacConfig::YamlFileNode} instead.
|
12
|
-
class OldConfigs
|
13
|
-
include ::EacRubyUtils::SimpleCache
|
14
|
-
|
15
|
-
attr_reader :configs_key, :options
|
16
|
-
|
17
|
-
# Valid options: [:storage_path]
|
18
|
-
def initialize(configs_key, options = {})
|
19
|
-
@configs_key = configs_key
|
20
|
-
@options = options.to_sym_keys_hash.freeze
|
21
|
-
load
|
22
|
-
end
|
23
|
-
|
24
|
-
delegate :clear, to: :file
|
25
|
-
|
26
|
-
delegate :save, to: :file
|
27
|
-
|
28
|
-
delegate :load, to: :file
|
29
|
-
|
30
|
-
def []=(entry_key, entry_value)
|
31
|
-
write_entry(entry_key, entry_value)
|
32
|
-
end
|
33
|
-
|
34
|
-
def write_entry(entry_key, entry_value)
|
35
|
-
file.write(entry_key, entry_value)
|
36
|
-
end
|
37
|
-
|
38
|
-
def [](entry_key)
|
39
|
-
read_entry(entry_key)
|
40
|
-
end
|
41
|
-
|
42
|
-
def read_entry(entry_key)
|
43
|
-
file.read(entry_key)
|
44
|
-
end
|
45
|
-
|
46
|
-
delegate :autosave?, to: :file
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
attr_accessor :data
|
51
|
-
|
52
|
-
def file_uncached
|
53
|
-
::EacConfig::OldConfigs::File.new(
|
54
|
-
storage_path, options
|
55
|
-
)
|
56
|
-
end
|
57
|
-
|
58
|
-
def storage_path_uncached
|
59
|
-
path = options_storage_path || default_storage_path
|
60
|
-
return path if ::File.exist?(path) && ::File.size(path).positive?
|
61
|
-
|
62
|
-
::FileUtils.mkdir_p(::File.dirname(path))
|
63
|
-
::File.write(path, {}.to_yaml)
|
64
|
-
path
|
65
|
-
end
|
66
|
-
|
67
|
-
def options_storage_path
|
68
|
-
options[:storage_path]
|
69
|
-
end
|
70
|
-
|
71
|
-
def default_storage_path
|
72
|
-
::File.join(ENV['HOME'], '.config', configs_key, 'settings.yml')
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
require 'eac_config/paths_hash/entry_key_error'
|
5
|
-
|
6
|
-
module EacConfig
|
7
|
-
class PathsHash
|
8
|
-
class Node
|
9
|
-
PATH_SEARCH_UNENDED_ERROR_MESSAGE = 'Path search is not a Node and is not ended'
|
10
|
-
|
11
|
-
def initialize(source_hash)
|
12
|
-
source_hash.assert_argument(Hash, 'source_hash')
|
13
|
-
@data = source_hash.map { |k, v| [k.to_sym, v.is_a?(Hash) ? Node.new(v) : v] }.to_h
|
14
|
-
end
|
15
|
-
|
16
|
-
def entry?(path_search)
|
17
|
-
return false unless data.key?(path_search.cursor)
|
18
|
-
return true if path_search.ended?
|
19
|
-
return data.fetch(path_search.cursor).entry?(path_search.succeeding) if
|
20
|
-
data.fetch(path_search.cursor).is_a?(Node)
|
21
|
-
|
22
|
-
false # Paths continue and there is not available nodes
|
23
|
-
end
|
24
|
-
|
25
|
-
def fetch(path_search)
|
26
|
-
if data.key?(path_search.cursor)
|
27
|
-
node = data.fetch(path_search.cursor)
|
28
|
-
return (node.is_a?(Node) ? node.to_h : node) if path_search.ended?
|
29
|
-
return nil if node.blank?
|
30
|
-
return node.fetch(path_search.succeeding) if node.is_a?(Node)
|
31
|
-
end
|
32
|
-
|
33
|
-
path_search.raise_error(PATH_SEARCH_UNENDED_ERROR_MESSAGE)
|
34
|
-
end
|
35
|
-
|
36
|
-
def to_h
|
37
|
-
data.transform_values { |v| v.is_a?(Node) ? v.to_h : v }
|
38
|
-
end
|
39
|
-
|
40
|
-
def read_entry(path_search)
|
41
|
-
node = data[path_search.cursor]
|
42
|
-
return (node.is_a?(Node) ? node.to_h : node) if path_search.ended?
|
43
|
-
return nil if node.blank?
|
44
|
-
return node.read_entry(path_search.succeeding) if node.is_a?(Node)
|
45
|
-
|
46
|
-
path_search.raise_error(PATH_SEARCH_UNENDED_ERROR_MESSAGE)
|
47
|
-
end
|
48
|
-
|
49
|
-
def write_entry(path_search, value)
|
50
|
-
if path_search.ended?
|
51
|
-
data[path_search.cursor] = value.is_a?(Hash) ? self.class.new(value) : value
|
52
|
-
else
|
53
|
-
assert_data_node(path_search.cursor).write_entry(path_search.succeeding, value)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
private
|
58
|
-
|
59
|
-
attr_reader :data
|
60
|
-
|
61
|
-
def assert_data_node(key)
|
62
|
-
data[key] = self.class.new({}) unless data[key].is_a?(Node)
|
63
|
-
data[key]
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module EacConfig
|
4
|
-
class PathsHash
|
5
|
-
class PathSearch
|
6
|
-
class << self
|
7
|
-
def parse_entry_key(string)
|
8
|
-
new(::EacConfig::PathsHash.parse_entry_key(string), [])
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
common_constructor :current, :previous do
|
13
|
-
self.current = current.assert_argument(Array, 'current').freeze
|
14
|
-
self.previous = previous.assert_argument(Array, 'previous')
|
15
|
-
raise ::EacConfig::PathsHash::EntryKeyError, 'Current is empty' if current.empty?
|
16
|
-
end
|
17
|
-
|
18
|
-
def cursor
|
19
|
-
current.first
|
20
|
-
end
|
21
|
-
|
22
|
-
def ended?
|
23
|
-
current.count <= 1
|
24
|
-
end
|
25
|
-
|
26
|
-
def raise_error(message)
|
27
|
-
raise ::EacConfig::PathsHash::EntryKeyError, "#{message} (#{self})"
|
28
|
-
end
|
29
|
-
|
30
|
-
def succeeding
|
31
|
-
self.class.new(current[1..-1], previous + [cursor])
|
32
|
-
end
|
33
|
-
|
34
|
-
def to_s
|
35
|
-
"#{self.class}[Current: #{current}, Previous: #{previous}]"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
|
5
|
-
module EacConfig
|
6
|
-
class PathsHash
|
7
|
-
require_sub __FILE__
|
8
|
-
|
9
|
-
class << self
|
10
|
-
def parse_entry_key(entry_key)
|
11
|
-
r = entry_key.to_s.strip
|
12
|
-
raise ::EacConfig::PathsHash::EntryKeyError, 'Entry key cannot start or end with dot' if
|
13
|
-
r.start_with?('.') || r.end_with?('.')
|
14
|
-
|
15
|
-
r = r.split('.').map(&:strip)
|
16
|
-
if r.empty?
|
17
|
-
raise ::EacConfig::PathsHash::EntryKeyError, "Entry key \"#{entry_key}\" is empty"
|
18
|
-
end
|
19
|
-
return r.map(&:to_sym) unless r.any?(&:blank?)
|
20
|
-
|
21
|
-
raise ::EacConfig::PathsHash::EntryKeyError,
|
22
|
-
"Entry key \"#{entry_key}\" has at least one blank part"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
attr_reader :root
|
27
|
-
|
28
|
-
def initialize(source_hash = {})
|
29
|
-
@root = Node.new(source_hash)
|
30
|
-
end
|
31
|
-
|
32
|
-
def [](entry_key)
|
33
|
-
root.read_entry(::EacConfig::PathsHash::PathSearch.parse_entry_key(entry_key))
|
34
|
-
end
|
35
|
-
|
36
|
-
def []=(entry_key, entry_value)
|
37
|
-
root.write_entry(
|
38
|
-
::EacConfig::PathsHash::PathSearch.parse_entry_key(entry_key), entry_value
|
39
|
-
)
|
40
|
-
end
|
41
|
-
|
42
|
-
def fetch(entry_key)
|
43
|
-
root.fetch(::EacConfig::PathsHash::PathSearch.parse_entry_key(entry_key))
|
44
|
-
end
|
45
|
-
|
46
|
-
def key?(entry_key)
|
47
|
-
root.entry?(::EacConfig::PathsHash::PathSearch.parse_entry_key(entry_key))
|
48
|
-
end
|
49
|
-
|
50
|
-
delegate :to_h, to: :root
|
51
|
-
|
52
|
-
# @return [EacConfig::PathsHash
|
53
|
-
def write(entry_key, entry_value)
|
54
|
-
self[entry_key] = entry_value
|
55
|
-
|
56
|
-
self
|
57
|
-
end
|
58
|
-
|
59
|
-
private
|
60
|
-
|
61
|
-
attr_reader :data
|
62
|
-
end
|
63
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_config/node_entry'
|
4
|
-
require 'eac_ruby_utils/core_ext'
|
5
|
-
|
6
|
-
module EacConfig
|
7
|
-
class PrefixedPathNode
|
8
|
-
class Entry < ::EacConfig::NodeEntry
|
9
|
-
enable_simple_cache
|
10
|
-
delegate :found?, :found_node, :secret_value, :value, :value=, :writ_node, to: :full_entry
|
11
|
-
|
12
|
-
# @return [EacConfig::EntryPath]
|
13
|
-
def full_path
|
14
|
-
node.path_prefix + path
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
# @return [EacConfig::NodeEntry]
|
20
|
-
def full_entry_uncached
|
21
|
-
node.from_node.entry(full_path)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_config/entry_path'
|
4
|
-
require 'eac_config/paths_hash'
|
5
|
-
require 'eac_ruby_utils/core_ext'
|
6
|
-
|
7
|
-
module EacConfig
|
8
|
-
class PrefixedPathNode
|
9
|
-
require_sub __FILE__
|
10
|
-
include ::EacConfig::Node
|
11
|
-
common_constructor :from_node, :path_prefix do
|
12
|
-
self.path_prefix = ::EacConfig::EntryPath.assert(path_prefix)
|
13
|
-
end
|
14
|
-
|
15
|
-
def entry(path)
|
16
|
-
::EacConfig::Entry.new(self, path)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
require 'eac_ruby_utils/fs/temp'
|
5
|
-
require 'eac_config/envvars_node'
|
6
|
-
require 'eac_config/node'
|
7
|
-
require 'eac_config/yaml_file_node'
|
8
|
-
|
9
|
-
module EacConfig
|
10
|
-
module Rspec
|
11
|
-
module Setup
|
12
|
-
def self.extended(obj)
|
13
|
-
obj.rspec_config.around do |example|
|
14
|
-
obj.on_envvars_load_path_clean(example)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def on_envvars_load_path_clean(example)
|
19
|
-
old_value = envvars_load_path_entry.value
|
20
|
-
begin
|
21
|
-
envvars_load_path_entry.value = old_value = []
|
22
|
-
example.run
|
23
|
-
ensure
|
24
|
-
envvars_load_path_entry.value = old_value
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def envvars_load_path_entry
|
29
|
-
::EacConfig::EnvvarsNode.new.load_path.entry
|
30
|
-
end
|
31
|
-
|
32
|
-
# Wraps a RSpec example in a EacConfig node using a alternative file.
|
33
|
-
#
|
34
|
-
# @param target_example [RSpec::Core::ExampleGroup] The example to wrap. If not provided,
|
35
|
-
# it is applied to all examples.
|
36
|
-
# @param target_file [Pathname] The file used by the EacConfig node. If not provided, a
|
37
|
-
# temporary file is used.
|
38
|
-
# @param node_builder [Proc] Should return the desired EacConfig node. If not provided, a
|
39
|
-
# EacConfig::YamlFileNode is created.
|
40
|
-
def stub_eac_config_node(target_example = nil, target_file = nil, &node_builder)
|
41
|
-
parent_self = self
|
42
|
-
(target_example || rspec_config).around do |example|
|
43
|
-
parent_self.stub_eac_config_node_on_file(target_file) do |file|
|
44
|
-
::EacConfig::Node
|
45
|
-
.context.on(parent_self.stub_eac_config_node_build(file, &node_builder)) do
|
46
|
-
example.run
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def stub_eac_config_node_build(file, &node_builder)
|
53
|
-
node_builder.present? ? node_builder.call(file) : ::EacConfig::YamlFileNode.new(file)
|
54
|
-
end
|
55
|
-
|
56
|
-
def stub_eac_config_node_on_file(target_file)
|
57
|
-
if target_file
|
58
|
-
yield(target_file.to_pathname)
|
59
|
-
else
|
60
|
-
::EacRubyUtils::Fs::Temp.on_file { |file| yield(file) }
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_config/entry_path'
|
4
|
-
require 'eac_config/node_entry'
|
5
|
-
require 'eac_ruby_utils/core_ext'
|
6
|
-
|
7
|
-
module EacConfig
|
8
|
-
class YamlFileNode
|
9
|
-
class Entry < ::EacConfig::NodeEntry
|
10
|
-
enable_simple_cache
|
11
|
-
|
12
|
-
def found?
|
13
|
-
paths_hash.key?(to_paths_hash_key)
|
14
|
-
end
|
15
|
-
|
16
|
-
def value
|
17
|
-
paths_hash[to_paths_hash_key]
|
18
|
-
end
|
19
|
-
|
20
|
-
def value=(a_value)
|
21
|
-
node.persist_data(paths_hash.write(to_paths_hash_key, a_value).root.to_h)
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
# @return [EacConfig::PathsHash]
|
27
|
-
def paths_hash
|
28
|
-
::EacConfig::PathsHash.new(node.data)
|
29
|
-
end
|
30
|
-
|
31
|
-
def to_paths_hash_key
|
32
|
-
path.parts.join('.')
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_config/entry_path'
|
4
|
-
require 'eac_config/yaml_file_node/entry'
|
5
|
-
require 'eac_ruby_utils/core_ext'
|
6
|
-
require 'eac_ruby_utils/wildcards'
|
7
|
-
|
8
|
-
module EacConfig
|
9
|
-
class YamlFileNode
|
10
|
-
class SelfEntries
|
11
|
-
acts_as_instance_method
|
12
|
-
common_constructor :node, :path do
|
13
|
-
self.path = ::EacConfig::EntryPath.assert(path)
|
14
|
-
end
|
15
|
-
|
16
|
-
# @return [Array<EacConfig::YamlFileNode>]
|
17
|
-
def result
|
18
|
-
head_node.result.map { |found_path| ::EacConfig::YamlFileNode::Entry.new(node, found_path) }
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
# @return [DataNode]
|
24
|
-
def head_node
|
25
|
-
DataNode.new(node.data, ::EacConfig::EntryPath.new, path)
|
26
|
-
end
|
27
|
-
|
28
|
-
class DataNode
|
29
|
-
common_constructor :data_node, :path_from, :path_to do
|
30
|
-
self.data_node = data_node.stringify_keys if data_node.is_a?(::Hash)
|
31
|
-
end
|
32
|
-
|
33
|
-
# @return [DataNode]
|
34
|
-
def child(child_key)
|
35
|
-
self.class.new(data_node.fetch(child_key), path_from.with_last(child_key),
|
36
|
-
path_to.without_first)
|
37
|
-
end
|
38
|
-
|
39
|
-
def children
|
40
|
-
return [] unless data_node.is_a?(::Hash)
|
41
|
-
|
42
|
-
data_node.keys.select { |k| key_matcher.match?(k) }.map { |k| child(k) }
|
43
|
-
end
|
44
|
-
|
45
|
-
# @return [Symbol]
|
46
|
-
def key
|
47
|
-
path_to.first
|
48
|
-
end
|
49
|
-
|
50
|
-
# @return [EacRubyUtils::Wildcards]
|
51
|
-
def key_matcher
|
52
|
-
@key_matcher ||= ::EacRubyUtils::Wildcards.new(key)
|
53
|
-
end
|
54
|
-
|
55
|
-
# @return [Array<EacConfig::EntryPath>]
|
56
|
-
def result
|
57
|
-
(path_to.empty? ? result_from_self : result_from_children)
|
58
|
-
end
|
59
|
-
|
60
|
-
# @return [Array<EacConfig::EntryPath>]
|
61
|
-
def result_from_self
|
62
|
-
[path_from]
|
63
|
-
end
|
64
|
-
|
65
|
-
# @return [Array<EacConfig::EntryPath>]
|
66
|
-
def result_from_children
|
67
|
-
children.flat_map(&:result)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'addressable'
|
4
|
-
require 'eac_config/node'
|
5
|
-
require 'eac_ruby_utils/core_ext'
|
6
|
-
require 'eac_ruby_utils/yaml'
|
7
|
-
|
8
|
-
module EacConfig
|
9
|
-
class YamlFileNode
|
10
|
-
require_sub __FILE__
|
11
|
-
include ::EacConfig::Node
|
12
|
-
enable_simple_cache
|
13
|
-
|
14
|
-
class << self
|
15
|
-
def from_uri(uri)
|
16
|
-
return new(uri.to_addressable.path) if uri.to_addressable.scheme == 'file'
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
common_constructor :path do
|
21
|
-
self.path = path.to_pathname
|
22
|
-
end
|
23
|
-
compare_by :path
|
24
|
-
|
25
|
-
def persist_data(new_data)
|
26
|
-
path.parent.mkpath
|
27
|
-
::EacRubyUtils::Yaml.dump_file(path, new_data)
|
28
|
-
reset_cache(:data)
|
29
|
-
end
|
30
|
-
|
31
|
-
def url
|
32
|
-
::Addressable::URI.parse("file://#{path.expand_path}")
|
33
|
-
end
|
34
|
-
|
35
|
-
def to_s
|
36
|
-
"#{self.class}[#{path}]"
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
def data_uncached
|
42
|
-
r = nil
|
43
|
-
if path.file?
|
44
|
-
r = ::EacRubyUtils::Yaml.load_file(path)
|
45
|
-
elsif path.exist?
|
46
|
-
raise("\"#{path}\" is a not a file")
|
47
|
-
end
|
48
|
-
|
49
|
-
r.is_a?(::Hash) ? r : {}
|
50
|
-
end
|
51
|
-
|
52
|
-
require_sub __FILE__, require_mode: :kernel
|
53
|
-
end
|
54
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_config/entry_path'
|
4
|
-
|
5
|
-
RSpec.describe ::EacConfig::EntryPath do
|
6
|
-
describe '#assert' do
|
7
|
-
{
|
8
|
-
['a.b.c'] => %w[a b c],
|
9
|
-
[['a', 1], 'b', []] => %w[a 1 b],
|
10
|
-
['a', 'b', ['c', 1.2], 'd', 'e.f'] => %w[a b c 1 2 d e f]
|
11
|
-
}.each do |data|
|
12
|
-
source = data[0]
|
13
|
-
expected_parts = data[1]
|
14
|
-
|
15
|
-
context "when source is #{source}" do
|
16
|
-
let(:instance) { described_class.assert(source) }
|
17
|
-
|
18
|
-
it { expect(instance.parts).to eq(expected_parts) }
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
[['a..c'], ['a', ' ']].each do |source|
|
23
|
-
context "when invalid source is #{source}" do
|
24
|
-
it do
|
25
|
-
expect { described_class.assert(source) }.to raise_error(::ArgumentError)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_config/envvars_node/entry'
|
4
|
-
|
5
|
-
RSpec.describe ::EacConfig::EnvvarsNode::Entry do
|
6
|
-
describe '#entry_key_to_envvar_name' do
|
7
|
-
{
|
8
|
-
'a.entry.value' => 'A_ENTRY_VALUE',
|
9
|
-
'appli-cation_0.var_one' => 'APPLICATION_0_VAR_ONE'
|
10
|
-
}.each do |input, expected_result|
|
11
|
-
it { expect(described_class.entry_path_to_envvar_name(input)).to eq(expected_result) }
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_config/envvars_node'
|
4
|
-
require 'eac_ruby_utils/ruby'
|
5
|
-
|
6
|
-
RSpec.describe ::EacConfig::EnvvarsNode do
|
7
|
-
let(:instance) { described_class.new }
|
8
|
-
|
9
|
-
before do
|
10
|
-
ENV['COMMON'] = 'AAA'
|
11
|
-
ENV['BLANK'] = ''
|
12
|
-
ENV.delete('NO_EXIST')
|
13
|
-
end
|
14
|
-
|
15
|
-
context 'with common entry' do
|
16
|
-
let(:entry) { instance.entry('common') }
|
17
|
-
|
18
|
-
it { expect(entry).to be_a(::EacConfig::Entry) }
|
19
|
-
it { expect(entry.value).to eq('AAA') }
|
20
|
-
it { expect(entry.found_node).to eq(instance) }
|
21
|
-
it { expect(entry).to be_found }
|
22
|
-
|
23
|
-
context 'with a clean ruby environment' do
|
24
|
-
let(:entry_value) do
|
25
|
-
::EacRubyUtils::Ruby.on_clean_environment do
|
26
|
-
entry.value
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it { expect(entry_value).to eq('AAA') }
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'with blank entry' do
|
35
|
-
let(:entry) { instance.entry('blank') }
|
36
|
-
|
37
|
-
it { expect(entry).to be_a(::EacConfig::Entry) }
|
38
|
-
it { expect(entry.value).to eq('') }
|
39
|
-
it { expect(entry.found_node).to eq(instance) }
|
40
|
-
it { expect(entry).to be_found }
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'with not existing entry' do
|
44
|
-
let(:entry) { instance.entry('no.exist') }
|
45
|
-
|
46
|
-
it { expect(entry).to be_a(::EacConfig::Entry) }
|
47
|
-
it { expect(entry.value).to eq(nil) }
|
48
|
-
it { expect(entry.found_node).to eq(nil) }
|
49
|
-
it { expect(entry).not_to be_found }
|
50
|
-
end
|
51
|
-
end
|