avm-tools 0.35.0 → 0.36.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: b2dfc6aad10cade7a84fad01d04a2ca982bfeb9d20f8c5efcf1253c14876d964
4
- data.tar.gz: b5a79cb9c4d62f8cefb1954fd79ee353ab928f9a2b1042e681a962390762bfe3
3
+ metadata.gz: bd0fc54aa88d5a418257e41542446fd247ecacc10764babfc6b1c74c329c4560
4
+ data.tar.gz: 163c224656cb2db01b66c756e186ea57f532fba2d225334f77573f18dfbce52e
5
5
  SHA512:
6
- metadata.gz: a3c5a134d6bff614af0aa153248c3952b5f043b590b666e2d3421a1477b2a180c69c2af864773e558af825d1f6e720ee8d56fbb13dd2c8c71782be3dedc7ba71
7
- data.tar.gz: 47734387f9fbb75a13c734b96bf2c45d5fcd8baf464db24a0af32fc3e2c9e4813c60ffd3d3ff53237770db341ff8a1baf6c847e24909d3813cc5dcb44b1656e9
6
+ metadata.gz: 66bfb3911d0cf5ea1c84a4ccbb6df1f9e80a4f28819b364a54835259d3561068a09f49a874221789e53a3bb46cb616bcef4bb25407f1431ee930f389dd55177b
7
+ data.tar.gz: 8585671f0d8aaa316124354b9390beedc7667e49a667be6db76a744590a2cb74cdda96691111bac2e7c20808b1bf61286ece822bb68ca48affd4679a5d192331
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/configs'
4
+ require 'yaml'
5
+
6
+ module Avm
7
+ module Instances
8
+ class Configuration < ::EacRubyUtils::Configs
9
+ FILENAMES = %w[.avm.yml .avm.yaml].freeze
10
+
11
+ class << self
12
+ def find_by_path(path)
13
+ path = ::Pathname.new(path.to_s).expand_path unless path.is_a?(::Pathname)
14
+ if path.directory?
15
+ FILENAMES.each do |filename|
16
+ file = path.join(filename)
17
+ return new(file) if file.exist?
18
+ end
19
+ end
20
+ find_by_path(path.dirname) unless path.root?
21
+ end
22
+ end
23
+
24
+ def initialize(path)
25
+ super(nil, storage_path: path)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,7 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_ruby_utils/core_ext'
4
+
3
5
  module Avm
4
6
  module Ruby
7
+ require_sub __FILE__
8
+
5
9
  class << self
6
10
  def on_clean_environment
7
11
  on_clean_envvars('BUNDLE', 'RUBY') { yield }
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_ruby_utils/on_clean_ruby_environment'
5
+
6
+ module Avm
7
+ module Ruby
8
+ class Rubocop
9
+ require_sub __FILE__
10
+ enable_console_speaker
11
+ enable_simple_cache
12
+ common_constructor :base_path, :rubocop_args
13
+ set_callback :initialize, :after do
14
+ @base_path = ::Pathname.new(base_path.to_s) unless base_path.is_a?(::Pathname)
15
+ end
16
+
17
+ def run
18
+ start_banner
19
+ run_rubocop
20
+ end
21
+
22
+ private
23
+
24
+ def cmd(*args)
25
+ ::EacRubyUtils::Envs.local.command(*args)
26
+ end
27
+
28
+ def rubocop_command_uncached
29
+ %w[env configured gemfile].each do |s|
30
+ cmd = send("#{s}_rubocop_command")
31
+ return cmd if cmd.present?
32
+ end
33
+ cmd('rubocop')
34
+ end
35
+
36
+ def rubocop_command_with_args
37
+ rubocop_command.append(rubocop_args)
38
+ end
39
+
40
+ def rubocop_version_uncached
41
+ ::EacRubyUtils.on_clean_ruby_environment do
42
+ rubocop_command.append(['--version']).execute!.strip
43
+ end
44
+ end
45
+
46
+ def run_rubocop
47
+ ::EacRubyUtils.on_clean_ruby_environment { rubocop_command_with_args.system }
48
+ end
49
+
50
+ def start_banner
51
+ infov 'Rubocop version', rubocop_version
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/instances/configuration'
4
+
5
+ module Avm
6
+ module Ruby
7
+ class Rubocop
8
+ def configured_rubocop_command_uncached
9
+ configured_rubocop_command_by_command || configured_rubocop_command_by_gemfile
10
+ end
11
+
12
+ def configured_rubocop_command_by_command
13
+ rubocop_command = configuration.if_present { |v| v.read_entry('ruby.rubocop.command') }
14
+ return nil unless rubocop_command.present?
15
+
16
+ args = if rubocop_command.is_a?(::Enumerable)
17
+ rubocop_command.map(&:to_s)
18
+ else
19
+ ::Shellwords.split(rubocop_command)
20
+ end
21
+ cmd(args).chdir(::File.dirname(configuration.storage_path))
22
+ end
23
+
24
+ def configured_rubocop_command_by_gemfile
25
+ gemfile_path = configuration.if_present { |v| v.read_entry('ruby.rubocop.gemfile') }
26
+ return nil unless gemfile_path.present?
27
+
28
+ rubocop_command_by_gemfile_path(
29
+ ::Pathname.new(gemfile_path).expand_path(configuration.storage_path.dirname)
30
+ )
31
+ end
32
+
33
+ private
34
+
35
+ def configuration_uncached
36
+ ::Avm::Instances::Configuration.find_by_path(base_path)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_ruby_utils/on_clean_ruby_environment'
5
+
6
+ module Avm
7
+ module Ruby
8
+ class Rubocop
9
+ RUBOCOP_COMMAND_ENVVAR_NAME = 'RUBOCOP_COMMAND'
10
+
11
+ def env_rubocop_command
12
+ ENV[RUBOCOP_COMMAND_ENVVAR_NAME].present? ? cmd(ENV[RUBOCOP_COMMAND_ENVVAR_NAME]) : nil
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_gems_utils/gem'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'eac_ruby_utils/on_clean_ruby_environment'
6
+
7
+ module Avm
8
+ module Ruby
9
+ class Rubocop
10
+ def gemfile_rubocop_command
11
+ return nil unless rubocop_gemfile?
12
+
13
+ rubocop_command_by_gemfile_path(mygem.gemfile_path)
14
+ end
15
+
16
+ def rubocop_command_by_gemfile_path(path)
17
+ mygem.bundle('exec', 'rubocop').envvar('BUNDLE_GEMFILE', path.to_s)
18
+ end
19
+
20
+ def rubocop_gemfile?
21
+ return false unless mygem.present?
22
+
23
+ mygem.bundle('install').execute!
24
+ mygem.gemfile_lock_gem_version('rubocop').present?
25
+ end
26
+
27
+ private
28
+
29
+ def mygem_uncached
30
+ find_gem(base_path)
31
+ end
32
+
33
+ def find_gem(path)
34
+ r = ::EacRubyGemsUtils::Gem.new(path)
35
+ return r if r.gemfile_path.exist?
36
+ return find_gem(path.dirname) unless path.root?
37
+ end
38
+ end
39
+ end
40
+ end
@@ -22,13 +22,17 @@ module Avm
22
22
  Options:
23
23
  -h --help Show this screen.
24
24
  -V --version Show version.
25
+ -q --quiet Quiet mode.
25
26
  DOCOPT
26
27
 
27
28
  def run
28
- if options.fetch('--version')
29
- out(::Avm::Tools::VERSION + "\n")
30
- else
31
- run_with_subcommand
29
+ on_speaker_node do |node|
30
+ node.stderr = ::StringIO.new if options.fetch('--quiet')
31
+ if options.fetch('--version')
32
+ out(::Avm::Tools::VERSION + "\n")
33
+ else
34
+ run_with_subcommand
35
+ end
32
36
  end
33
37
  end
34
38
  end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/console/docopt_runner'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Tools
8
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
9
+ class Ruby < ::EacRubyUtils::Console::DocoptRunner
10
+ require_sub __FILE__
11
+
12
+ DOC = <<~DOCOPT
13
+ Ruby utilities for AVM.
14
+
15
+ Usage:
16
+ __PROGRAM__ [options] __SUBCOMMANDS__
17
+ __PROGRAM__ -h | --help
18
+
19
+ Options:
20
+ -h --help Show this screen.
21
+ DOCOPT
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/ruby/rubocop'
4
+ require 'eac_ruby_utils/console/docopt_runner'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avm
8
+ module Tools
9
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
10
+ class Ruby < ::EacRubyUtils::Console::DocoptRunner
11
+ class Rubocop < ::EacRubyUtils::Console::DocoptRunner
12
+ include ::EacRubyUtils::Console::Speaker
13
+ include ::EacRubyUtils::SimpleCache
14
+
15
+ DOC = <<~DOCOPT
16
+ Runs Rubocop (https://rubygems.org/gems/rubocop).
17
+
18
+ Usage:
19
+ __PROGRAM__ [options] [<rubocop-args>...]
20
+ __PROGRAM__ -h | --help
21
+
22
+ Options:
23
+ -h --help Show this screen.
24
+ -C=<path> Caminho para executar o Rubocop [default: .].
25
+ DOCOPT
26
+
27
+ def run
28
+ ::Avm::Ruby::Rubocop.new(path, rubocop_args).run
29
+ end
30
+
31
+ private
32
+
33
+ def path
34
+ ::Pathname.new(options.fetch('-C')).expand_path
35
+ end
36
+
37
+ def rubocop_args
38
+ r = options.fetch('<rubocop-args>')
39
+ r.shift if r.first == '--'
40
+ r
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.35.0'
5
+ VERSION = '0.36.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.35.0
4
+ version: 0.36.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-06 00:00:00.000000000 Z
11
+ date: 2020-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -70,6 +70,20 @@ dependencies:
70
70
  - - ">="
71
71
  - !ruby/object:Gem::Version
72
72
  version: 0.6.1
73
+ - !ruby/object:Gem::Dependency
74
+ name: eac_ruby_gems_utils
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '0.2'
80
+ type: :runtime
81
+ prerelease: false
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - "~>"
85
+ - !ruby/object:Gem::Version
86
+ version: '0.2'
73
87
  - !ruby/object:Gem::Dependency
74
88
  name: eac_ruby_utils
75
89
  requirement: !ruby/object:Gem::Requirement
@@ -225,6 +239,7 @@ files:
225
239
  - lib/avm/instances/base/auto_values/system.rb
226
240
  - lib/avm/instances/base/auto_values/web.rb
227
241
  - lib/avm/instances/base/dockerizable.rb
242
+ - lib/avm/instances/configuration.rb
228
243
  - lib/avm/instances/entries.rb
229
244
  - lib/avm/instances/entries/entry_reader.rb
230
245
  - lib/avm/instances/entry_keys.rb
@@ -234,6 +249,10 @@ files:
234
249
  - lib/avm/path_string.rb
235
250
  - lib/avm/result.rb
236
251
  - lib/avm/ruby.rb
252
+ - lib/avm/ruby/rubocop.rb
253
+ - lib/avm/ruby/rubocop/_configured.rb
254
+ - lib/avm/ruby/rubocop/_envvar.rb
255
+ - lib/avm/ruby/rubocop/_gemfile.rb
237
256
  - lib/avm/self.rb
238
257
  - lib/avm/self/docker_image.rb
239
258
  - lib/avm/self/instance.rb
@@ -297,6 +316,8 @@ files:
297
316
  - lib/avm/tools/runner/git/issue.rb
298
317
  - lib/avm/tools/runner/git/issue/complete.rb
299
318
  - lib/avm/tools/runner/git/revisions_test.rb
319
+ - lib/avm/tools/runner/ruby.rb
320
+ - lib/avm/tools/runner/ruby/rubocop.rb
300
321
  - lib/avm/tools/runner/self.rb
301
322
  - lib/avm/tools/runner/self/docker.rb
302
323
  - lib/avm/tools/version.rb