avm-tools 0.41.0 → 0.42.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: 1e421bc1935d15d29a51fc7ff4331d038ca161f502e00db2a87c0e390ddb02f2
4
- data.tar.gz: a3dae44bc30d89174b6dd025116b44d78651bf8af9ca0fde05ee22078fee5f2a
3
+ metadata.gz: 21c01866f9d3e2aaa7d30b254740a63daf91dcec77fc4da08b8eb0505832aeb0
4
+ data.tar.gz: d9c0e0771add271642abb587119b4f887b40667882192612a40406c1fc8dca8a
5
5
  SHA512:
6
- metadata.gz: 974d24b1a41919d84d50db87ea5b726c6b238eaf95cab4cc658201b3f6f4c704ad586804d1fcb2b61199f33f7ba45ef7998472ed188b0a37674db26827750acd
7
- data.tar.gz: f211f0671c85e381f1a2b1edfcb53a816b420512f12f92cd9be376a2d05b63f92226e6ead605a3f177caf581d798681472592331ea05ef2ca81d4a23495a74ad
6
+ metadata.gz: cb36cadc8af5d05e032a5f0fa83a9af30400ef3636d9d2696e41063ad9f6fb0ad947e013a966452e692628b045986d0586c905280f1b98a4e5baa50055f92fa9
7
+ data.tar.gz: ddb1cbcd59038ce2374a0952eb1d2289da3f0dc621c48334f422d0b7347616702f82f880205afe8a4dda28ca552916032b0119a66b68fdc2aba0bb730962d5c5
@@ -11,7 +11,7 @@ module Avm
11
11
  enable_console_speaker
12
12
  common_constructor :source_paths, :options
13
13
 
14
- FORMATS = %w[html php python json generic_plain].freeze
14
+ FORMATS = %w[ruby html php python json generic_plain].freeze
15
15
 
16
16
  def run
17
17
  clear
@@ -19,11 +19,11 @@ module Avm
19
19
  end
20
20
 
21
21
  def match?(file)
22
- match_by_extension?(file) || match_by_type?(file)
22
+ match_by_filename?(file) || match_by_type?(file)
23
23
  end
24
24
 
25
- def valid_extensions
26
- constant_or_array('VALID_EXTENSIONS')
25
+ def valid_basenames
26
+ constant_or_array('VALID_BASENAMES')
27
27
  end
28
28
 
29
29
  def valid_types
@@ -43,9 +43,9 @@ module Avm
43
43
  changed: (old_content != File.read(file)))
44
44
  end
45
45
 
46
- def match_by_extension?(file)
47
- valid_extensions.any? do |valid_extension|
48
- file.extname.ends_with?(valid_extension)
46
+ def match_by_filename?(file)
47
+ valid_basenames.any? do |valid_basename|
48
+ file.basename.fnmatch?(valid_basename)
49
49
  end
50
50
  end
51
51
 
@@ -7,8 +7,8 @@ module Avm
7
7
  class Formatter
8
8
  module Formats
9
9
  class GenericPlain < ::Avm::Files::Formatter::Formats::Base
10
- VALID_EXTENSIONS = %w[.bat .css.coffee .java .js .rb .scss .sql .tex .url .yml
11
- .yaml].freeze
10
+ VALID_BASENAMES = %w[*.bat *.css.coffee *.java *.js *.rb *.scss *.sql *.tex *.url *.yml
11
+ *.yaml].freeze
12
12
 
13
13
  VALID_TYPES = %w[plain x-shellscript].freeze
14
14
 
@@ -8,7 +8,7 @@ module Avm
8
8
  class Formatter
9
9
  module Formats
10
10
  class Html < ::Avm::Files::Formatter::Formats::GenericPlain
11
- VALID_EXTENSIONS = %w[.html .html.erb].freeze
11
+ VALID_BASENAMES = %w[*.html *.html.erb].freeze
12
12
  VALID_TYPES = ['html'].freeze
13
13
 
14
14
  def file_apply(path)
@@ -7,13 +7,9 @@ module Avm
7
7
  class Formatter
8
8
  module Formats
9
9
  class Json < ::Avm::Files::Formatter::Formats::GenericPlain
10
- VALID_EXTENSIONS = %w[.json].freeze
10
+ VALID_BASENAMES = %w[*.json].freeze
11
11
  VALID_TYPES = [].freeze
12
12
 
13
- def match?(file)
14
- super || json_file?(file)
15
- end
16
-
17
13
  def file_apply(file)
18
14
  ::File.write(file, ::JSON.pretty_generate(::JSON.parse(::File.read(file))))
19
15
  end
@@ -7,7 +7,7 @@ module Avm
7
7
  class Formatter
8
8
  module Formats
9
9
  class Php < ::Avm::Files::Formatter::Formats::GenericPlain
10
- VALID_EXTENSIONS = %w[.php].freeze
10
+ VALID_BASENAMES = %w[*.php].freeze
11
11
  VALID_TYPES = ['x-php'].freeze
12
12
 
13
13
  def file_apply(file)
@@ -7,7 +7,7 @@ module Avm
7
7
  class Formatter
8
8
  module Formats
9
9
  class Python < ::Avm::Files::Formatter::Formats::GenericPlain
10
- VALID_EXTENSIONS = %w[.py].freeze
10
+ VALID_BASENAMES = %w[*.py].freeze
11
11
  VALID_TYPES = ['x-python'].freeze
12
12
 
13
13
  def internal_apply(files)
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/files/formatter/formats/generic_plain'
4
+ require 'avm/ruby/rubocop'
5
+
6
+ module Avm
7
+ module Files
8
+ class Formatter
9
+ module Formats
10
+ class Ruby < ::Avm::Files::Formatter::Formats::GenericPlain
11
+ VALID_BASENAMES = %w[*.gemspec *.rake *.rb Gemfile Rakefile].freeze
12
+ VALID_TYPES = ['x-ruby'].freeze
13
+
14
+ def internal_apply(files)
15
+ ::Avm::Ruby::Rubocop.new('.', ['-a', '--ignore-parent-exclusion'] + files).run
16
+ super(files)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -10,14 +10,20 @@ module Avm
10
10
 
11
11
  class << self
12
12
  def find_by_path(path)
13
- path = ::Pathname.new(path.to_s).expand_path unless path.is_a?(::Pathname)
14
- if path.directory?
13
+ path = ::Pathname.new(path.to_s) unless path.is_a?(::Pathname)
14
+ internal_find_path(path.expand_path)
15
+ end
16
+
17
+ private
18
+
19
+ def internal_find_path(absolute_pathname)
20
+ if absolute_pathname.directory?
15
21
  FILENAMES.each do |filename|
16
- file = path.join(filename)
22
+ file = absolute_pathname.join(filename)
17
23
  return new(file) if file.exist?
18
24
  end
19
25
  end
20
- find_by_path(path.dirname) unless path.root?
26
+ internal_find_path(absolute_pathname.dirname) unless absolute_pathname.root?
21
27
  end
22
28
  end
23
29
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.41.0'
5
+ VERSION = '0.42.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.41.0
4
+ version: 0.42.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
@@ -237,6 +237,7 @@ files:
237
237
  - lib/avm/files/formatter/formats/json.rb
238
238
  - lib/avm/files/formatter/formats/php.rb
239
239
  - lib/avm/files/formatter/formats/python.rb
240
+ - lib/avm/files/formatter/formats/ruby.rb
240
241
  - lib/avm/files/formatter/utf8_assert.rb
241
242
  - lib/avm/files/info.rb
242
243
  - lib/avm/files/rotate.rb