Class: Avm::Instances::Configuration
- Inherits:
-
EacRubyUtils::Configs
- Object
- EacRubyUtils::Configs
- Avm::Instances::Configuration
- Defined in:
- lib/avm/instances/configuration.rb,
lib/avm/instances/configuration/_tests.rb,
lib/avm/instances/configuration/_rubocop.rb
Constant Summary collapse
- FILENAMES =
%w[.avm.yml .avm.yaml].freeze
- BUNDLE_TEST_COMMAND_KEY =
'test.bundle_command'
- TEST_COMMAND_KEY =
'test.command'
- RUBOCOP_COMMAND_KEY =
'ruby.rubocop.command'
- RUBOCOP_GEMFILE_KEY =
'ruby.rubocop.gemfile'
Class Method Summary collapse
Instance Method Summary collapse
- #any_test_command ⇒ Object
- #bundle_test_command ⇒ Object
-
#initialize(path) ⇒ Configuration
constructor
A new instance of Configuration.
-
#read_command(key) ⇒ EacRubyUtils::Envs::Command
Utility to read a configuration as a [EacRubyUtils::Envs::Command].
- #rubocop_command ⇒ Object
- #rubocop_gemfile ⇒ Object
- #test_command ⇒ Object
Constructor Details
#initialize(path) ⇒ Configuration
Returns a new instance of Configuration.
33 34 35 |
# File 'lib/avm/instances/configuration.rb', line 33 def initialize(path) super(nil, storage_path: path) end |
Class Method Details
.find_by_path(path) ⇒ Object
15 16 17 18 |
# File 'lib/avm/instances/configuration.rb', line 15 def find_by_path(path) path = ::Pathname.new(path.to_s) unless path.is_a?(::Pathname) internal_find_path(path.) end |
Instance Method Details
#any_test_command ⇒ Object
11 12 13 |
# File 'lib/avm/instances/configuration/_tests.rb', line 11 def any_test_command bundle_test_command || test_command end |
#bundle_test_command ⇒ Object
19 20 21 22 23 24 |
# File 'lib/avm/instances/configuration/_tests.rb', line 19 def bundle_test_command read_entry(BUNDLE_TEST_COMMAND_KEY).if_present do |v| args = v.is_a?(::Enumerable) ? v.map(&:to_s) : ::Shellwords.split(v) ::EacRubyGemsUtils::Gem.new(::File.dirname(storage_path)).bundle(*args).chdir_root end end |
#read_command(key) ⇒ EacRubyUtils::Envs::Command
Utility to read a configuration as a [EacRubyUtils::Envs::Command].
39 40 41 42 43 44 |
# File 'lib/avm/instances/configuration.rb', line 39 def read_command(key) read_entry(key).if_present do |v| args = v.is_a?(::Enumerable) ? v.map(&:to_s) : ::Shellwords.split(v) ::EacRubyUtils::Envs.local.command(args).chdir(::File.dirname(storage_path)) end end |
#rubocop_command ⇒ Object
9 10 11 |
# File 'lib/avm/instances/configuration/_rubocop.rb', line 9 def rubocop_command read_command(RUBOCOP_COMMAND_KEY) end |
#rubocop_gemfile ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/avm/instances/configuration/_rubocop.rb', line 13 def rubocop_gemfile gemfile_path = read_entry(RUBOCOP_GEMFILE_KEY) return nil if gemfile_path.blank? gemfile_path = gemfile_path.to_pathname.(storage_path.parent) return gemfile_path if gemfile_path.file? raise "Gemfile path \"#{gemfile_path}\" does not exist or is not a file" end |
#test_command ⇒ Object
15 16 17 |
# File 'lib/avm/instances/configuration/_tests.rb', line 15 def test_command read_command(TEST_COMMAND_KEY) end |