avm-tools 0.75.1 → 0.76.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: 4600b008c9ecc3f3aaa220ec18cac2199559787186710d80e6cd1fda6f39cf97
4
- data.tar.gz: a8f6c806934616363ef26f4acc6e486a0f3fd215867e013c588256c20e077086
3
+ metadata.gz: 523777fd378f3ba655e65b12e452660f192e2875791439146808c472ee5cd982
4
+ data.tar.gz: 253dabfb78beaefa4b40dcfe6f669ae0e74761cb63a2e3418fda41ca8e107d2f
5
5
  SHA512:
6
- metadata.gz: d10aa9242ee96189a7f43ab7ba1d1dc8cda2c7bb9961566ed7c2bf2a2a33d4c285eb1a42eb747342e2a6d2a1f5130e4681871dbc92cf9716978914216c922a12
7
- data.tar.gz: 6eab4907c7e01156c4a7394e0ffa1503a1a8cdc3dce4e4f05aabd105b66c0576baecd6b30f0779e01565c78db3603614e8e75426b3cead19751d7bef2de582db
6
+ metadata.gz: 7208ff787a4d219d9a66b9e6e978dbf51cb142ea6af94b4347f9fc7f56c478962113b775896d52351fc35bea6fad3b796c9d5387af70c491a56542cd42872d25
7
+ data.tar.gz: 77004875dc073ea43aca01a5a3c4bbbf178fed773056bae70206745ce6d677ebfdf797871a0e5a8196eac1fd30774ab49e0e6b7503009abc22e0f278e5e6aaf0
@@ -10,7 +10,11 @@ module Avm
10
10
  require_sub __FILE__
11
11
  enable_simple_cache
12
12
  enable_console_speaker
13
- common_constructor :source_paths, :options
13
+ enable_listable
14
+ lists.add_symbol :option, :apply, :recursive, :verbose
15
+ common_constructor :source_paths, :options, default: [{}] do
16
+ options.assert_valid_keys(self.class.lists.option.values)
17
+ end
14
18
 
15
19
  FORMATS = %w[ruby php html python xml json generic_plain].freeze
16
20
 
@@ -27,7 +31,7 @@ module Avm
27
31
  infom "Applying #{@formats_files.count} format(s)... "
28
32
  @formats_files.each do |format, files|
29
33
  infom "Applying format #{format.name} (Files matched: #{files.count})..."
30
- next unless options.fetch(:apply)
34
+ next unless options[OPTION_APPLY]
31
35
 
32
36
  @result += format.apply(files)
33
37
  end
@@ -35,7 +39,7 @@ module Avm
35
39
 
36
40
  def traverser_check_file(file)
37
41
  format = find_format(file)
38
- infov file, format ? format.class : '-' if options.fetch(:verbose)
42
+ infov file, format ? format.class : '-' if options[OPTION_VERBOSE]
39
43
  return unless format
40
44
 
41
45
  @formats_files[format] ||= []
@@ -79,7 +83,7 @@ module Avm
79
83
  end
80
84
 
81
85
  def traverser_recursive
82
- options.fetch(:recursive)
86
+ options[OPTION_RECURSIVE]
83
87
  end
84
88
  end
85
89
  end
@@ -5,6 +5,7 @@ require 'eac_ruby_utils/core_ext'
5
5
  module Avm
6
6
  module Git
7
7
  class AutoCommitPath
8
+ require_sub __FILE__, include_modules: true
8
9
  enable_console_speaker
9
10
  common_constructor :git, :path do
10
11
  self.path = path.to_pathname
@@ -31,10 +32,7 @@ module Avm
31
32
  end
32
33
 
33
34
  def class_name
34
- CLASS_NAME_PATTERNS.each do |pattern|
35
- pattern.if_match(relative_path.to_path, false) { |m| return m[1].camelize }
36
- end
37
- raise "No pattern matched \"#{relative_path}\""
35
+ ruby_class_name || relative_path.to_path
38
36
  end
39
37
 
40
38
  def commit_message
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Git
7
+ class AutoCommitPath
8
+ module Ruby
9
+ RUBY_CLASS_NAME_PATTERNS = [%r{lib/((?!.*/lib/).+)\.rb\z}, %r{app/[^/]+/(.+)\.rb\z}].freeze
10
+
11
+ def ruby_class_name
12
+ RUBY_CLASS_NAME_PATTERNS.each do |pattern|
13
+ pattern.if_match(relative_path.to_path, false) { |m| return m[1].camelize }
14
+ end
15
+ nil
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -32,8 +32,9 @@ module Avm
32
32
  end
33
33
 
34
34
  def formatter_options
35
- { apply: options.fetch('--apply'), recursive: !options.fetch('--no-recursive'),
36
- verbose: options.fetch('--verbose') }
35
+ { ::Avm::Files::Formatter::OPTION_APPLY => options.fetch('--apply'),
36
+ ::Avm::Files::Formatter::OPTION_RECURSIVE => !options.fetch('--no-recursive'),
37
+ ::Avm::Files::Formatter::OPTION_VERBOSE => options.fetch('--verbose') }
37
38
  end
38
39
 
39
40
  def git
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/git/auto_commit_path'
4
+ require 'avm/files/formatter'
4
5
  require 'eac_cli/default_runner'
5
6
 
6
7
  module Avm
@@ -13,12 +14,14 @@ module Avm
13
14
  runner_definition do
14
15
  desc 'Commit with message based in content commited.'
15
16
  bool_opt '-d', '--dirty', 'Select dirty files.'
17
+ bool_opt '-f', '--format', 'Format files before commit.'
16
18
  pos_arg 'paths', repeat: true, optional: true
17
19
  end
18
20
 
19
21
  def run
20
22
  clear_stage
21
23
  banner
24
+ format_files
22
25
  run_paths
23
26
  end
24
27
 
@@ -39,6 +42,14 @@ module Avm
39
42
  context(:git).dirty_files.map { |d| context(:git).root_path.join / d.path }
40
43
  end
41
44
 
45
+ def format_files
46
+ return unless options.fetch('--format')
47
+
48
+ infom 'Formating files...'
49
+ ::Avm::Files::Formatter.new(paths.map(&:path),
50
+ ::Avm::Files::Formatter::OPTION_APPLY => true).run
51
+ end
52
+
42
53
  def paths_uncached
43
54
  (options.fetch('<paths>')
44
55
  .map { |p| p.to_pathname.expand_path } + dirty_paths)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.75.1'
5
+ VERSION = '0.76.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.75.1
4
+ version: 0.76.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-11-10 00:00:00.000000000 Z
11
+ date: 2020-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -369,6 +369,7 @@ files:
369
369
  - lib/avm/fs_cache.rb
370
370
  - lib/avm/git.rb
371
371
  - lib/avm/git/auto_commit_path.rb
372
+ - lib/avm/git/auto_commit_path/ruby.rb
372
373
  - lib/avm/git/commit.rb
373
374
  - lib/avm/git/commit/class_methods.rb
374
375
  - lib/avm/git/commit/deploy.rb