ehbrs-tools 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ehbrs/core_ext.rb +4 -0
  3. data/lib/ehbrs/music/album.rb +2 -0
  4. data/{vendor/eac_cli/lib/eac_cli/patches/module.rb → lib/ehbrs/patches.rb} +1 -1
  5. data/lib/ehbrs/runner/fs/selected.rb +79 -0
  6. data/lib/ehbrs/runner/fs/used_space.rb +1 -2
  7. data/lib/ehbrs/runner/music/selected.rb +9 -46
  8. data/lib/ehbrs/tools/version.rb +1 -1
  9. data/lib/ehbrs/videos/unsupported/check_support.rb +12 -8
  10. data/vendor/avm-apps/Gemfile +5 -0
  11. data/vendor/avm-apps/avm-apps.gemspec +18 -0
  12. data/vendor/avm-apps/lib/avm/apps.rb +9 -0
  13. data/vendor/avm-apps/lib/avm/apps/config.rb +19 -0
  14. data/vendor/avm-apps/lib/avm/apps/jobs.rb +11 -0
  15. data/vendor/avm-apps/lib/avm/apps/jobs/base.rb +64 -0
  16. data/vendor/avm-apps/lib/avm/apps/jobs/variables_source.rb +24 -0
  17. data/vendor/avm-apps/lib/avm/apps/sources/configuration.rb +57 -0
  18. data/vendor/avm-apps/lib/avm/apps/sources/configuration/_locale.rb +18 -0
  19. data/vendor/avm-apps/lib/avm/apps/sources/configuration/_rubocop.rb +26 -0
  20. data/vendor/avm-apps/lib/avm/apps/sources/configuration/_tests.rb +29 -0
  21. data/vendor/avm-apps/lib/avm/apps/version.rb +7 -0
  22. data/vendor/avm-apps/spec/rubocop_spec.rb +3 -0
  23. data/vendor/avm-apps/spec/spec_helper.rb +103 -0
  24. data/vendor/eac_cli/eac_cli.gemspec +1 -2
  25. data/vendor/eac_cli/lib/eac_cli/config.rb +16 -0
  26. data/vendor/eac_cli/lib/eac_cli/config/entry.rb +48 -0
  27. data/vendor/eac_cli/lib/eac_cli/config/entry/options.rb +57 -0
  28. data/vendor/eac_cli/lib/eac_cli/config/entry/undefined.rb +26 -0
  29. data/vendor/eac_cli/lib/eac_cli/definition/help_formatter.rb +3 -2
  30. data/vendor/eac_cli/lib/eac_cli/definition/positional_argument.rb +6 -1
  31. data/vendor/eac_cli/lib/eac_cli/old_configs.rb +0 -1
  32. data/vendor/eac_cli/lib/eac_cli/old_configs/entry_reader.rb +2 -2
  33. data/vendor/eac_cli/lib/eac_cli/old_configs_bridge.rb +39 -0
  34. data/vendor/eac_cli/lib/eac_cli/runner.rb +0 -2
  35. data/vendor/eac_cli/lib/eac_cli/runner/after_class_methods.rb +20 -3
  36. data/vendor/eac_cli/lib/eac_cli/runner/instance_methods.rb +5 -1
  37. data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +9 -4
  38. data/vendor/eac_cli/lib/eac_cli/runner_with/help/builder.rb +73 -0
  39. data/vendor/eac_cli/lib/eac_cli/runner_with/help/builder/alternative.rb +56 -0
  40. data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +6 -4
  41. data/vendor/eac_cli/lib/eac_cli/speaker.rb +15 -19
  42. data/vendor/eac_cli/lib/eac_cli/speaker/_constants.rb +1 -1
  43. data/vendor/eac_cli/lib/eac_cli/speaker/list.rb +1 -1
  44. data/vendor/eac_cli/lib/eac_cli/speaker/options.rb +38 -0
  45. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  46. data/vendor/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb +1 -1
  47. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +0 -1
  48. data/vendor/eac_cli/spec/lib/eac_cli/speaker_spec.rb +5 -9
  49. data/vendor/eac_config/Gemfile +5 -0
  50. data/vendor/eac_config/eac_config.gemspec +19 -0
  51. data/vendor/eac_config/lib/eac_config.rb +7 -0
  52. data/vendor/eac_config/lib/eac_config/entry.rb +49 -0
  53. data/vendor/eac_config/lib/eac_config/entry_path.rb +41 -0
  54. data/vendor/eac_config/lib/eac_config/envvars_node.rb +25 -0
  55. data/vendor/eac_config/lib/eac_config/envvars_node/entry.rb +54 -0
  56. data/vendor/eac_config/lib/eac_config/load_nodes_search.rb +39 -0
  57. data/vendor/eac_config/lib/eac_config/load_path.rb +28 -0
  58. data/vendor/eac_config/lib/eac_config/node.rb +67 -0
  59. data/vendor/eac_config/lib/eac_config/node_entry.rb +18 -0
  60. data/vendor/eac_config/lib/eac_config/node_uri.rb +38 -0
  61. data/vendor/eac_config/lib/eac_config/old_configs.rb +75 -0
  62. data/vendor/eac_config/lib/eac_config/old_configs/base.rb +43 -0
  63. data/vendor/eac_config/lib/eac_config/old_configs/file.rb +47 -0
  64. data/vendor/eac_config/lib/eac_config/paths_hash.rb +56 -0
  65. data/vendor/eac_config/lib/eac_config/paths_hash/entry_key_error.rb +8 -0
  66. data/vendor/eac_config/lib/eac_config/paths_hash/node.rb +67 -0
  67. data/vendor/eac_config/lib/eac_config/paths_hash/path_search.rb +39 -0
  68. data/vendor/eac_config/lib/eac_config/version.rb +5 -0
  69. data/vendor/eac_config/lib/eac_config/yaml_file_node.rb +48 -0
  70. data/vendor/eac_config/lib/eac_config/yaml_file_node/entry.rb +37 -0
  71. data/vendor/eac_config/spec/lib/eac_config/entry_path_spec.rb +30 -0
  72. data/vendor/eac_config/spec/lib/eac_config/envvars_node/entry_spec.rb +14 -0
  73. data/vendor/eac_config/spec/lib/eac_config/envvars_node_spec.rb +40 -0
  74. data/vendor/eac_config/spec/lib/eac_config/old_configs_spec.rb +46 -0
  75. data/vendor/eac_config/spec/lib/eac_config/paths_hash_spec.rb +88 -0
  76. data/vendor/eac_config/spec/lib/eac_config/yaml_file_node_spec.rb +52 -0
  77. data/vendor/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1.yaml +6 -0
  78. data/vendor/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_1.yaml +2 -0
  79. data/vendor/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_2.yaml +4 -0
  80. data/vendor/eac_config/spec/lib/eac_config/yaml_file_node_spec_files/storage1_2/storage1_2_1.yaml +2 -0
  81. data/vendor/eac_config/spec/rubocop_spec.rb +3 -0
  82. data/vendor/eac_config/spec/spec_helper.rb +17 -0
  83. data/vendor/eac_ruby_base0/eac_ruby_base0.gemspec +2 -2
  84. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application.rb +23 -9
  85. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application_xdg.rb +34 -0
  86. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/jobs_runner.rb +2 -2
  87. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +19 -7
  88. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/confirmation.rb +8 -1
  89. data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
  90. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/context.rb +31 -0
  91. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/contextualizable.rb +12 -7
  92. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/context.rb +11 -0
  93. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/speaker.rb +9 -0
  94. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/simple_cache.rb +10 -2
  95. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/speaker.rb +16 -0
  96. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/speaker/receiver.rb +57 -0
  97. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/speaker/sender.rb +32 -0
  98. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  99. data/vendor/{eac_cli/spec/lib → eac_ruby_utils/spec/lib/eac_ruby_utils/patches}/module/speaker_spec.rb +2 -2
  100. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/simple_cache_spec.rb +18 -0
  101. metadata +69 -18
  102. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +0 -71
  103. data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder/alternative.rb +0 -50
  104. data/vendor/eac_cli/lib/eac_cli/docopt/runner_context_replacement.rb +0 -15
  105. data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +0 -51
  106. data/vendor/eac_cli/lib/eac_cli/docopt_runner.rb +0 -43
  107. data/vendor/eac_cli/lib/eac_cli/docopt_runner/_class_methods.rb +0 -16
  108. data/vendor/eac_cli/lib/eac_cli/docopt_runner/_doc.rb +0 -23
  109. data/vendor/eac_cli/lib/eac_cli/docopt_runner/_settings.rb +0 -17
  110. data/vendor/eac_cli/lib/eac_cli/docopt_runner/_subcommands.rb +0 -152
  111. data/vendor/eac_cli/lib/eac_cli/patches/module/speaker.rb +0 -10
  112. data/vendor/eac_cli/lib/eac_cli/speaker/_class_methods.rb +0 -37
  113. data/vendor/eac_cli/lib/eac_cli/speaker/node.rb +0 -24
  114. data/vendor/eac_cli/spec/lib/eac_cli/docopt/runner_extension_spec.rb +0 -35
  115. data/vendor/eac_cli/spec/lib/eac_cli/docopt_runner_spec.rb +0 -136
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ea7376b27f5582e0f1c154f3a218de64c6bb27c0d0c9109b6194c2ad1dc779b
4
- data.tar.gz: d7916decd5768e2008e43313669bfd9d605662fb95d13c7fa64d33581b86afac
3
+ metadata.gz: 65c2d3133ff7e4ef5b4525fd989ea39ca9ba76b6993d470d47543a06258f2f9c
4
+ data.tar.gz: 42bc25487ca6b2b1aba7ce315a9a9bc311767d26480b08b7b04ee1e88fbf7b7a
5
5
  SHA512:
6
- metadata.gz: 6798766e6cfbe66142f7ab0100016ddcf34744a2fd8c12e021d00a67d068310fa7e901521daba98a72a9c8bd6c85a9bd5bc7afb0270b4bdf99b646c354e553f1
7
- data.tar.gz: 6ea855740d28d2676f9723cfe86f8ba3c12e29fb5ceda65ec068d3857172ff07d79df72df76332079afdec79f2725cb752179cc35f659c426485d59068e792eb
6
+ metadata.gz: e73a214bae3409ae28b10ecbfdccc70ccc9981af6140a6371ab158b8552cd1564c8346964f6c4dff005b53e3434e162d9a48fc404c2d321d69504c393ea4a372
7
+ data.tar.gz: 6a84239f517e9a985e9890717a6dd6a5e2db3623199913da8165bcdf0a484c264428027a3d5514464b6fe7721cc3ffb54753b58f5a4eb399c8b463ec1effb580
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ehbrs/patches'
4
+ require 'eac_ruby_base0/core_ext'
@@ -22,6 +22,8 @@ module Ehbrs
22
22
  (to_a + [id]).map(&:light_white).join(' | '.blue)
23
23
  end
24
24
 
25
+ delegate :to_path, to: :path
26
+
25
27
  def id
26
28
  [artist, name].join('_').variableize
27
29
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_ruby_utils/require_sub'
4
- ::EacRubyUtils.require_sub(__FILE__)
4
+ ::EacRubyUtils.require_sub __FILE__
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/envs'
4
+ require 'eac_ruby_utils/fs/clearable_directory'
5
+ require 'ehbrs/core_ext'
6
+
7
+ module Ehbrs
8
+ class Runner
9
+ class Fs
10
+ class Selected
11
+ DEFAULT_TRAVERSER_RECURSIVE = true
12
+
13
+ enable_jobs_runner
14
+ runner_with :confirmation, :help, :filesystem_traverser do
15
+ desc 'Seleciona diretórios.'
16
+ arg_opt '-b', '--build-dir', 'Constrói diretório alvo.'
17
+ end
18
+
19
+ def run
20
+ infov 'Recursive', traverser_recursive
21
+ run_jobs :show, :build
22
+ end
23
+
24
+ protected
25
+
26
+ def build_selected_directory(path)
27
+ path
28
+ end
29
+
30
+ def directory_label(directory)
31
+ directory.to_s
32
+ end
33
+
34
+ def directory_target_basename(directory)
35
+ directory.basename.to_path
36
+ end
37
+
38
+ private
39
+
40
+ def build
41
+ infom "Building directory \"#{build_dir}\" with selected..."
42
+ build_dir.clear
43
+ selected_directories.each do |directory|
44
+ ::EacRubyUtils::Envs.local.command(
45
+ 'ln', '-s', directory.to_path,
46
+ build_dir.join(directory_target_basename(directory))
47
+ ).system!
48
+ end
49
+ end
50
+
51
+ def build_dir_uncached
52
+ parsed.build_dir.if_present { |v| ::EacRubyUtils::Fs::ClearableDirectory.new(v) }
53
+ end
54
+
55
+ def run_build?
56
+ build_dir.present? && confirm?('Build?')
57
+ end
58
+
59
+ def selected_directories_uncached
60
+ infom 'Searching selected directories...'
61
+ @selected = []
62
+ run_filesystem_traverser
63
+ @selected.sort
64
+ end
65
+
66
+ def show
67
+ infov 'Directories found', selected_directories.count
68
+ selected_directories.each do |directory|
69
+ puts directory_label(directory)
70
+ end
71
+ end
72
+
73
+ def traverser_check_directory(path)
74
+ @selected << build_selected_directory(path) if path.join('.selected').exist?
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
@@ -93,8 +93,7 @@ module Ehbrs
93
93
  class PathVerbose < PathBase
94
94
  def run
95
95
  infom path.to_s
96
- on_speaker_node do |node|
97
- node.stderr_line_prefix = ' '
96
+ ::EacRubyUtils::Speaker.context.on(::EacCli::Speaker.new(err_line_prefix: ' ')) do
98
97
  banner
99
98
  check
100
99
  end
@@ -1,61 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_base0/patches'
4
- require 'eac_ruby_utils/fs/clearable_directory'
5
3
  require 'ehbrs/music/album'
4
+ require 'ehbrs/runner/fs/selected'
6
5
 
7
6
  module Ehbrs
8
7
  class Runner
9
8
  class Music
10
- class Selected
11
- DEFAULT_TRAVERSER_RECURSIVE = true
9
+ class Selected < ::Ehbrs::Runner::Fs::Selected
10
+ protected
12
11
 
13
- enable_jobs_runner
14
- runner_with :help, :filesystem_traverser do
15
- desc 'Seleciona álbuns de música.'
16
- arg_opt '-b', '--build-dir', 'Constrói diretório de músicas selecionadas.'
12
+ def build_selected_directory(path)
13
+ ::Ehbrs::Music::Album.new(path)
17
14
  end
18
15
 
19
- def run
20
- infov 'Recursive', traverser_recursive
21
- run_jobs :show, :build
16
+ def directory_label(directory)
17
+ directory.to_label
22
18
  end
23
19
 
24
- private
25
-
26
- def build
27
- infom 'Building...'
28
- build_dir.clear
29
- selected_albums.each do |album|
30
- ::EacRubyUtils::Envs.local.command('ln', '-s', album.path,
31
- build_dir.join(album.id)).system!
32
- end
33
- end
34
-
35
- def build_dir_uncached
36
- parsed.build_dir.if_present { |v| ::EacRubyUtils::Fs::ClearableDirectory.new(v) }
37
- end
38
-
39
- def run_build?
40
- build_dir.present?
41
- end
42
-
43
- def selected_albums_uncached
44
- infom 'Searching selected albums...'
45
- @selected = []
46
- run_filesystem_traverser
47
- @selected.sort
48
- end
49
-
50
- def show
51
- infov 'Albums found', selected_albums.count
52
- selected_albums.each do |album|
53
- puts album.to_label
54
- end
55
- end
56
-
57
- def traverser_check_directory(path)
58
- @selected << ::Ehbrs::Music::Album.new(path) if path.join('.selected').exist?
20
+ def directory_target_basename(directory)
21
+ directory.id
59
22
  end
60
23
  end
61
24
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ehbrs
4
4
  module Tools
5
- VERSION = '0.21.0'
5
+ VERSION = '0.22.0'
6
6
  end
7
7
  end
@@ -1,17 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_cli/speaker'
3
+ require 'eac_ruby_utils/core_ext'
4
4
  require 'ehbrs/videos/unsupported/check_result'
5
5
 
6
6
  module Ehbrs
7
7
  module Videos
8
8
  module Unsupported
9
9
  module CheckSupport
10
- extend ::ActiveSupport::Concern
11
-
12
- included do
13
- include ::EacCli::Speaker
14
- include ::EacRubyUtils::SimpleCache
10
+ common_concern do
11
+ enable_simple_cache
12
+ enable_speaker
15
13
  end
16
14
 
17
15
  def aggressions_banner(title)
@@ -58,11 +56,17 @@ module Ehbrs
58
56
  end
59
57
 
60
58
  def pad_speaker
61
- on_speaker_node do |node|
62
- node.stderr_line_prefix = node.stderr_line_prefix.to_s + ' '
59
+ ::EacRubyUtils::Speaker.context.on(::EacCli::Speaker.new(err_line_prefix: ' ')) do
63
60
  yield
64
61
  end
65
62
  end
63
+
64
+ def new_padded_cli_speaker
65
+ ::EacCli::Speaker.new(
66
+ err_line_prefix(::EacRubyUtils::Speaker.context.optional_current
67
+ .if_present('') { |v| v.is_a?(::EacCli::Speaker) ? v.err_line_prefix : '' } + ' ')
68
+ )
69
+ end
66
70
  end
67
71
  end
68
72
  end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
4
+
5
+ require 'avm/apps/version'
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = 'avm-apps'
9
+ s.version = Avm::Apps::VERSION
10
+ s.authors = ['Eduardo H. Bogoni']
11
+ s.summary = 'AVM components for applications.'
12
+
13
+ s.files = Dir['{lib}/**/*']
14
+
15
+ s.add_dependency 'eac_ruby_utils', '~> 0.67'
16
+
17
+ s.add_development_dependency 'eac_ruby_gem_support', '~> 0.2'
18
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Apps
7
+ require_sub __FILE__
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Apps
7
+ class Config
8
+ class << self
9
+ # @deprecated Use EacConfig::Node.context instead.
10
+ # @return [EacRubyUtils::Context<EacConfig::Node>]
11
+ def context
12
+ ::EacConfig::Node.context
13
+ end
14
+
15
+ delegate :current, to: :context
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Apps
7
+ module Jobs
8
+ require_sub __FILE__
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/apps/jobs/variables_source'
4
+ require 'eac_cli/core_ext'
5
+
6
+ module Avm
7
+ module Apps
8
+ module Jobs
9
+ module Base
10
+ common_concern do
11
+ include ::ActiveSupport::Callbacks
12
+
13
+ enable_speaker
14
+ enable_simple_cache
15
+ enable_listable
16
+ common_constructor :instance, :options, default: [{}] do
17
+ if option_list.present?
18
+ self.options = option_list.hash_keys_validate!(options.symbolize_keys)
19
+ end
20
+ end
21
+ define_callbacks(*jobs)
22
+ end
23
+
24
+ module ClassMethods
25
+ def jobs
26
+ const_get('JOBS').dup
27
+ end
28
+ end
29
+
30
+ module InstanceMethods
31
+ def option_list
32
+ nil
33
+ end
34
+
35
+ def run
36
+ start_banner if respond_to?(:start_banner)
37
+ run_jobs
38
+ ::Avm::Result.success('Done!')
39
+ rescue ::Avm::Result::Error => e
40
+ e.to_result
41
+ end
42
+
43
+ def variables_source
44
+ ::Avm::Apps::Jobs::VariablesSource.new(self, instance)
45
+ end
46
+
47
+ protected
48
+
49
+ def run_jobs
50
+ jobs.each do |job|
51
+ run_callbacks job do
52
+ send(job)
53
+ end
54
+ end
55
+ end
56
+
57
+ def jobs
58
+ self.class.jobs
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Apps
7
+ module Jobs
8
+ class VariablesSource
9
+ common_constructor :job, :instance
10
+
11
+ def read_entry(path, options = {})
12
+ entry_from_job(path) || instance.read_entry(path, options)
13
+ end
14
+
15
+ private
16
+
17
+ def entry_from_job(path)
18
+ method = path.gsub('.', '_').underscore
19
+ return job.send(method) if job.respond_to?(method, true)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_config/old_configs'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'yaml'
6
+
7
+ module Avm
8
+ module Apps
9
+ module Sources
10
+ class Configuration < ::EacConfig::OldConfigs
11
+ require_sub __FILE__
12
+
13
+ FILENAMES = %w[.avm.yml .avm.yaml].freeze
14
+
15
+ class << self
16
+ def find_by_path(path)
17
+ path = ::Pathname.new(path.to_s) unless path.is_a?(::Pathname)
18
+ internal_find_path(path.expand_path)
19
+ end
20
+
21
+ def find_in_path(path)
22
+ absolute_pathname = path.to_pathname.expand_path
23
+ if absolute_pathname.directory?
24
+ FILENAMES.each do |filename|
25
+ file = absolute_pathname.join(filename)
26
+ return new(file) if file.exist?
27
+ end
28
+ end
29
+ nil
30
+ end
31
+
32
+ private
33
+
34
+ def internal_find_path(absolute_pathname)
35
+ r = find_in_path(absolute_pathname)
36
+ return r if r.present?
37
+
38
+ internal_find_path(absolute_pathname.dirname) unless absolute_pathname.root?
39
+ end
40
+ end
41
+
42
+ def initialize(path)
43
+ super(nil, storage_path: path)
44
+ end
45
+
46
+ # Utility to read a configuration as a [EacRubyUtils::Envs::Command].
47
+ # @return [EacRubyUtils::Envs::Command]
48
+ def read_command(key)
49
+ read_entry(key).if_present do |v|
50
+ args = v.is_a?(::Enumerable) ? v.map(&:to_s) : ::Shellwords.split(v)
51
+ ::EacRubyUtils::Envs.local.command(args).chdir(::File.dirname(storage_path))
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end