ehbrs-tools 0.21.0 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ehbrs/core_ext.rb +4 -0
- data/lib/ehbrs/music/album.rb +2 -0
- data/{vendor/eac_cli/lib/eac_cli/patches/module.rb → lib/ehbrs/patches.rb} +1 -1
- data/lib/ehbrs/runner/fs/selected.rb +79 -0
- data/lib/ehbrs/runner/fs/used_space.rb +1 -2
- data/lib/ehbrs/runner/music/selected.rb +9 -46
- data/lib/ehbrs/tools/version.rb +1 -1
- data/lib/ehbrs/videos/unsupported/check_support.rb +12 -8
- data/vendor/avm-apps/Gemfile +5 -0
- data/vendor/avm-apps/avm-apps.gemspec +18 -0
- data/vendor/avm-apps/lib/avm/apps.rb +9 -0
- data/vendor/avm-apps/lib/avm/apps/config.rb +19 -0
- data/vendor/avm-apps/lib/avm/apps/jobs.rb +11 -0
- data/vendor/avm-apps/lib/avm/apps/jobs/base.rb +64 -0
- data/vendor/avm-apps/lib/avm/apps/jobs/variables_source.rb +24 -0
- data/vendor/avm-apps/lib/avm/apps/sources/configuration.rb +57 -0
- data/vendor/avm-apps/lib/avm/apps/sources/configuration/_locale.rb +18 -0
- data/vendor/avm-apps/lib/avm/apps/sources/configuration/_rubocop.rb +26 -0
- data/vendor/avm-apps/lib/avm/apps/sources/configuration/_tests.rb +29 -0
- data/vendor/avm-apps/lib/avm/apps/version.rb +7 -0
- data/vendor/avm-apps/spec/rubocop_spec.rb +3 -0
- data/vendor/avm-apps/spec/spec_helper.rb +103 -0
- data/vendor/eac_cli/eac_cli.gemspec +1 -2
- data/vendor/eac_cli/lib/eac_cli/config.rb +16 -0
- data/vendor/eac_cli/lib/eac_cli/config/entry.rb +48 -0
- data/vendor/eac_cli/lib/eac_cli/config/entry/options.rb +57 -0
- data/vendor/eac_cli/lib/eac_cli/config/entry/undefined.rb +26 -0
- data/vendor/eac_cli/lib/eac_cli/definition/help_formatter.rb +3 -2
- data/vendor/eac_cli/lib/eac_cli/definition/positional_argument.rb +6 -1
- data/vendor/eac_cli/lib/eac_cli/old_configs.rb +0 -1
- data/vendor/eac_cli/lib/eac_cli/old_configs/entry_reader.rb +2 -2
- data/vendor/eac_cli/lib/eac_cli/old_configs_bridge.rb +39 -0
- data/vendor/eac_cli/lib/eac_cli/runner.rb +0 -2
- data/vendor/eac_cli/lib/eac_cli/runner/after_class_methods.rb +20 -3
- data/vendor/eac_cli/lib/eac_cli/runner/instance_methods.rb +5 -1
- data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +9 -4
- data/vendor/eac_cli/lib/eac_cli/runner_with/help/builder.rb +73 -0
- data/vendor/eac_cli/lib/eac_cli/runner_with/help/builder/alternative.rb +56 -0
- data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +6 -4
- data/vendor/eac_cli/lib/eac_cli/speaker.rb +15 -19
- data/vendor/eac_cli/lib/eac_cli/speaker/_constants.rb +1 -1
- data/vendor/eac_cli/lib/eac_cli/speaker/list.rb +1 -1
- data/vendor/eac_cli/lib/eac_cli/speaker/options.rb +38 -0
- data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
- data/vendor/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb +1 -1
- data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +0 -1
- data/vendor/eac_cli/spec/lib/eac_cli/speaker_spec.rb +5 -9
- data/vendor/eac_config/Gemfile +5 -0
- data/vendor/eac_config/eac_config.gemspec +19 -0
- data/vendor/eac_config/lib/eac_config.rb +7 -0
- data/vendor/eac_config/lib/eac_config/entry.rb +49 -0
- data/vendor/eac_config/lib/eac_config/entry_path.rb +41 -0
- data/vendor/eac_config/lib/eac_config/envvars_node.rb +25 -0
- data/vendor/eac_config/lib/eac_config/envvars_node/entry.rb +54 -0
- data/vendor/eac_config/lib/eac_config/load_nodes_search.rb +39 -0
- data/vendor/eac_config/lib/eac_config/load_path.rb +28 -0
- data/vendor/eac_config/lib/eac_config/node.rb +67 -0
- data/vendor/eac_config/lib/eac_config/node_entry.rb +18 -0
- data/vendor/eac_config/lib/eac_config/node_uri.rb +38 -0
- data/vendor/eac_config/lib/eac_config/old_configs.rb +75 -0
- data/vendor/eac_config/lib/eac_config/old_configs/base.rb +43 -0
- data/vendor/eac_config/lib/eac_config/old_configs/file.rb +47 -0
- data/vendor/eac_config/lib/eac_config/paths_hash.rb +56 -0
- data/vendor/eac_config/lib/eac_config/paths_hash/entry_key_error.rb +8 -0
- data/vendor/eac_config/lib/eac_config/paths_hash/node.rb +67 -0
- data/vendor/eac_config/lib/eac_config/paths_hash/path_search.rb +39 -0
- data/vendor/eac_config/lib/eac_config/version.rb +5 -0
- data/vendor/eac_config/lib/eac_config/yaml_file_node.rb +48 -0
- data/vendor/eac_config/lib/eac_config/yaml_file_node/entry.rb +37 -0
- data/vendor/eac_config/spec/lib/eac_config/entry_path_spec.rb +30 -0
- data/vendor/eac_config/spec/lib/eac_config/envvars_node/entry_spec.rb +14 -0
- data/vendor/eac_config/spec/lib/eac_config/envvars_node_spec.rb +40 -0
- data/vendor/eac_config/spec/lib/eac_config/old_configs_spec.rb +46 -0
- data/vendor/eac_config/spec/lib/eac_config/paths_hash_spec.rb +88 -0
- data/vendor/eac_config/spec/lib/eac_config/yaml_file_node_spec.rb +52 -0
- data/vendor/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1.yaml +6 -0
- data/vendor/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_1.yaml +2 -0
- data/vendor/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_2.yaml +4 -0
- data/vendor/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_2/storage1_2_1.yaml +2 -0
- data/vendor/eac_config/spec/rubocop_spec.rb +3 -0
- data/vendor/eac_config/spec/spec_helper.rb +17 -0
- data/vendor/eac_ruby_base0/eac_ruby_base0.gemspec +2 -2
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application.rb +23 -9
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application_xdg.rb +34 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/jobs_runner.rb +2 -2
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +19 -7
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/confirmation.rb +8 -1
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/context.rb +31 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/contextualizable.rb +12 -7
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/context.rb +11 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/speaker.rb +9 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/simple_cache.rb +10 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/speaker.rb +16 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/speaker/receiver.rb +57 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/speaker/sender.rb +32 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/vendor/{eac_cli/spec/lib → eac_ruby_utils/spec/lib/eac_ruby_utils/patches}/module/speaker_spec.rb +2 -2
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/simple_cache_spec.rb +18 -0
- metadata +69 -18
- data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +0 -71
- data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder/alternative.rb +0 -50
- data/vendor/eac_cli/lib/eac_cli/docopt/runner_context_replacement.rb +0 -15
- data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +0 -51
- data/vendor/eac_cli/lib/eac_cli/docopt_runner.rb +0 -43
- data/vendor/eac_cli/lib/eac_cli/docopt_runner/_class_methods.rb +0 -16
- data/vendor/eac_cli/lib/eac_cli/docopt_runner/_doc.rb +0 -23
- data/vendor/eac_cli/lib/eac_cli/docopt_runner/_settings.rb +0 -17
- data/vendor/eac_cli/lib/eac_cli/docopt_runner/_subcommands.rb +0 -152
- data/vendor/eac_cli/lib/eac_cli/patches/module/speaker.rb +0 -10
- data/vendor/eac_cli/lib/eac_cli/speaker/_class_methods.rb +0 -37
- data/vendor/eac_cli/lib/eac_cli/speaker/node.rb +0 -24
- data/vendor/eac_cli/spec/lib/eac_cli/docopt/runner_extension_spec.rb +0 -35
- data/vendor/eac_cli/spec/lib/eac_cli/docopt_runner_spec.rb +0 -136
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/blank_not_blank'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
require 'eac_config/paths_hash'
|
6
|
+
|
7
|
+
module EacConfig
|
8
|
+
class OldConfigs
|
9
|
+
class Base
|
10
|
+
enable_simple_cache
|
11
|
+
|
12
|
+
common_constructor :data, default: [{}] do
|
13
|
+
self.data = ::EacConfig::PathsHash.new(data)
|
14
|
+
end
|
15
|
+
|
16
|
+
def []=(entry_key, entry_value)
|
17
|
+
write(entry_key, entry_value)
|
18
|
+
end
|
19
|
+
|
20
|
+
def [](entry_key)
|
21
|
+
read(entry_key)
|
22
|
+
end
|
23
|
+
|
24
|
+
def clear
|
25
|
+
replace({})
|
26
|
+
end
|
27
|
+
|
28
|
+
def read(entry_key)
|
29
|
+
return nil unless data.key?(entry_key)
|
30
|
+
|
31
|
+
data.fetch(entry_key).if_present(::EacRubyUtils::BlankNotBlank.instance)
|
32
|
+
end
|
33
|
+
|
34
|
+
def replace(new_data)
|
35
|
+
self.data = ::EacConfig::PathsHash.new(new_data)
|
36
|
+
end
|
37
|
+
|
38
|
+
def write(entry_key, entry_value)
|
39
|
+
data[entry_key] = entry_value
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_config/old_configs/base'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
module EacConfig
|
7
|
+
class OldConfigs
|
8
|
+
class File < ::EacConfig::OldConfigs::Base
|
9
|
+
attr_reader :path, :options
|
10
|
+
|
11
|
+
# Valid options: [:autosave]
|
12
|
+
def initialize(path, options = {})
|
13
|
+
@path = path
|
14
|
+
@options = options.to_sym_keys_hash.freeze
|
15
|
+
super(raw_data_from_file)
|
16
|
+
end
|
17
|
+
|
18
|
+
def save
|
19
|
+
::FileUtils.mkdir_p(::File.dirname(path))
|
20
|
+
::File.write(path, data.to_h.to_yaml)
|
21
|
+
end
|
22
|
+
|
23
|
+
def load
|
24
|
+
replace(raw_data_from_file)
|
25
|
+
end
|
26
|
+
|
27
|
+
def write(entry_key, entry_value)
|
28
|
+
super
|
29
|
+
save if autosave?
|
30
|
+
end
|
31
|
+
|
32
|
+
def autosave?
|
33
|
+
options[:autosave] ? true : false
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def raw_data_from_file
|
39
|
+
if ::File.exist?(path) && ::File.size(path).positive?
|
40
|
+
::YAML.load_file(path)
|
41
|
+
else
|
42
|
+
{}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,56 @@
|
|
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
|
+
private
|
53
|
+
|
54
|
+
attr_reader :data
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,67 @@
|
|
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.map { |k, v| [k, v.is_a?(Node) ? v.to_h : v] }.to_h
|
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
|
@@ -0,0 +1,39 @@
|
|
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
|
@@ -0,0 +1,48 @@
|
|
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
|
+
|
13
|
+
class << self
|
14
|
+
def from_uri(uri)
|
15
|
+
return new(uri.to_addressable.path) if uri.to_addressable.scheme == 'file'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
common_constructor :path do
|
20
|
+
self.path = path.to_pathname
|
21
|
+
end
|
22
|
+
|
23
|
+
def data
|
24
|
+
@data ||= ::EacRubyUtils::Yaml.load_file(assert_path) || {}
|
25
|
+
end
|
26
|
+
|
27
|
+
def persist_data(new_data)
|
28
|
+
path.parent.mkpath
|
29
|
+
::EacRubyUtils::Yaml.dump_file(path, new_data)
|
30
|
+
@data = nil
|
31
|
+
end
|
32
|
+
|
33
|
+
def url
|
34
|
+
::Addressable::URI.parse("file://#{path.expand_path}")
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def assert_path
|
40
|
+
unless path.file?
|
41
|
+
raise("\"#{path}\" is a not a file") if path.exist?
|
42
|
+
|
43
|
+
persist_data({})
|
44
|
+
end
|
45
|
+
path
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,37 @@
|
|
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
|
+
paths_hash[to_paths_hash_key] = a_value
|
22
|
+
node.persist_data(paths_hash.root.to_h)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
# @return [EacConfig::PathsHash]
|
28
|
+
def paths_hash_uncached
|
29
|
+
::EacConfig::PathsHash.new(node.data)
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_paths_hash_key
|
33
|
+
path.parts.join('.')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,30 @@
|
|
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
|
@@ -0,0 +1,14 @@
|
|
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
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_config/envvars_node'
|
4
|
+
|
5
|
+
RSpec.describe ::EacConfig::EnvvarsNode do
|
6
|
+
let(:instance) { described_class.new }
|
7
|
+
|
8
|
+
before do
|
9
|
+
ENV['COMMON'] = 'AAA'
|
10
|
+
ENV['BLANK'] = ''
|
11
|
+
ENV.delete('NO_EXIST')
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'with common entry' do
|
15
|
+
let(:entry) { instance.entry('common') }
|
16
|
+
|
17
|
+
it { expect(entry).to be_a(::EacConfig::Entry) }
|
18
|
+
it { expect(entry.value).to eq('AAA') }
|
19
|
+
it { expect(entry.found_node).to eq(instance) }
|
20
|
+
it { expect(entry).to be_found }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'with blank entry' do
|
24
|
+
let(:entry) { instance.entry('blank') }
|
25
|
+
|
26
|
+
it { expect(entry).to be_a(::EacConfig::Entry) }
|
27
|
+
it { expect(entry.value).to eq('') }
|
28
|
+
it { expect(entry.found_node).to eq(instance) }
|
29
|
+
it { expect(entry).to be_found }
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'with not existing entry' do
|
33
|
+
let(:entry) { instance.entry('no.exist') }
|
34
|
+
|
35
|
+
it { expect(entry).to be_a(::EacConfig::Entry) }
|
36
|
+
it { expect(entry.value).to eq(nil) }
|
37
|
+
it { expect(entry.found_node).to eq(nil) }
|
38
|
+
it { expect(entry).not_to be_found }
|
39
|
+
end
|
40
|
+
end
|