avm-apps 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21c38190171f331e3c572affdde713613a1936d9a170deefe5e99ba6294f6533
4
- data.tar.gz: b487a949b8b7d7bd0d8041b53ab721b16ee938c86e74725ccda035f4a1d7f137
3
+ metadata.gz: c74837dcc74369568039a4e571df1d71369339ffa2a3c98fb2164c1a35410c58
4
+ data.tar.gz: 4a0ddaa74956140e2c6872ea32bd41cad513824fada240e98fab5b5d422cec36
5
5
  SHA512:
6
- metadata.gz: d1d52df0027bc8d705cf98c91fbb7803a400a4fd815500e95abd2ae9f1de80bd904dd66f8a1a2c9b940b86af6b7c9895c7c5d5e97e893e9b202e4a68974c10b8
7
- data.tar.gz: c51b962a769b57b63b9213bb72b17b3a91bdb1801e404ce425dc3b9432b27e76a8064ca80aa76e38181dcb59546caf5c8cf736bfde2ce52aa632851531c95cbd
6
+ metadata.gz: b1e7fecf325f191275d5b6f85fec3b4ad49bc2d646e76cc52c1776b8e8805ba74f670ee79968cdaea27c30c45443811956ad3d89c3866c4248e6cfb5351a2aeb
7
+ data.tar.gz: 80195404e9361a694cd4afc8fd3919cf392fc1338588ec5d5ac7eb7a8bbb3db53cebd4507bff76222ecfe8f7e4da14a9fde4092cf155d365275c46aebada0dd4
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/configs'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'yaml'
6
+
7
+ module Avm
8
+ module Apps
9
+ module Sources
10
+ class Configuration < ::EacRubyUtils::Configs
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
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/patches/eac_ruby_gems_utils/gem'
4
+ require 'i18n'
5
+
6
+ module Avm
7
+ module Apps
8
+ module Sources
9
+ class Configuration < ::EacRubyUtils::Configs
10
+ LOCALE_KEY = :locale
11
+
12
+ def locale
13
+ read_entry(LOCALE_KEY) || ::I18n.default_locale
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Apps
5
+ module Sources
6
+ class Configuration < ::EacRubyUtils::Configs
7
+ RUBOCOP_COMMAND_KEY = 'ruby.rubocop.command'
8
+ RUBOCOP_GEMFILE_KEY = 'ruby.rubocop.gemfile'
9
+
10
+ def rubocop_command
11
+ read_command(RUBOCOP_COMMAND_KEY)
12
+ end
13
+
14
+ def rubocop_gemfile
15
+ gemfile_path = read_entry(RUBOCOP_GEMFILE_KEY)
16
+ return nil if gemfile_path.blank?
17
+
18
+ gemfile_path = gemfile_path.to_pathname.expand_path(storage_path.parent)
19
+ return gemfile_path if gemfile_path.file?
20
+
21
+ raise "Gemfile path \"#{gemfile_path}\" does not exist or is not a file"
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/patches/eac_ruby_gems_utils/gem'
4
+
5
+ module Avm
6
+ module Apps
7
+ module Sources
8
+ class Configuration < ::EacRubyUtils::Configs
9
+ BUNDLE_TEST_COMMAND_KEY = 'test.bundle_command'
10
+ TEST_COMMAND_KEY = 'test.command'
11
+
12
+ def any_test_command
13
+ bundle_test_command || test_command
14
+ end
15
+
16
+ def test_command
17
+ read_command(TEST_COMMAND_KEY)
18
+ end
19
+
20
+ def bundle_test_command
21
+ read_entry(BUNDLE_TEST_COMMAND_KEY).if_present do |v|
22
+ args = v.is_a?(::Enumerable) ? v.map(&:to_s) : ::Shellwords.split(v)
23
+ ::EacRubyGemsUtils::Gem.new(::File.dirname(storage_path)).bundle(*args).chdir_root
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Apps
5
- VERSION = '0.1.1'
5
+ VERSION = '0.2.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-apps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo H. Bogoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-06 00:00:00.000000000 Z
11
+ date: 2021-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_ruby_utils
@@ -54,6 +54,10 @@ files:
54
54
  - lib/avm/apps/jobs.rb
55
55
  - lib/avm/apps/jobs/base.rb
56
56
  - lib/avm/apps/jobs/variables_source.rb
57
+ - lib/avm/apps/sources/configuration.rb
58
+ - lib/avm/apps/sources/configuration/_locale.rb
59
+ - lib/avm/apps/sources/configuration/_rubocop.rb
60
+ - lib/avm/apps/sources/configuration/_tests.rb
57
61
  - lib/avm/apps/version.rb
58
62
  homepage:
59
63
  licenses: []