avm 0.59.0 → 0.60.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e515ae3c2a7c5ce6fa8d620589e359aeb2568edd75b554932adb0a666f0ff8f
4
- data.tar.gz: 0ca8ac3456a4f99106d7e91d9429936365707b9ff68e20c0f8f36ba19074fc39
3
+ metadata.gz: 8ee7bf9c423e00a5bbd0e070ab0f1a191f338e80c794fde0609a3463c7307d78
4
+ data.tar.gz: cdb1a486aadcb408fee1123c133f54c5d46fa912be903f49ed547166027b62a2
5
5
  SHA512:
6
- metadata.gz: c3afecc85ab9c116a136758af1a0e8dbf889665eb09a6348f6be0c0e62da42bbd1073c64c19b4c3cece99bc57aae1d40faf645810c2f00fa9d2b9256ffc9d815
7
- data.tar.gz: 9771384b7caf46ad06478e2dc6d3d6a1a1f525baf66fdef65fb4e49e22fa4be258bc786372208e9ed8b572bb978c33ad11b9a8f8ae605522c0dbc1deab194213
6
+ metadata.gz: d1a37030086636976394fe3392a2681c4065cb8dbabd32fc1f702193b581372372519ef099b254c7c126f3818cff4715dc1597f2ecab1c65a9953044a20362a0
7
+ data.tar.gz: 2a72c35e69480aabe07bc71a00ec8cfaf30854ced09da08b423f88c9229f59e42275a902d9797f12a23ec5305c4893803770425b439035a96e70d3f45be30060
@@ -8,6 +8,7 @@ module Avm
8
8
  module FileFormats
9
9
  class Base
10
10
  enable_abstract_methods
11
+ compare_by :class
11
12
 
12
13
  def apply(files)
13
14
  old_content = Hash[files.map { |f| [f, File.read(f)] }]
@@ -15,6 +16,12 @@ module Avm
15
16
  files.map { |f| build_file_result(f, old_content[f]) }
16
17
  end
17
18
 
19
+ # @param path [Pathname]
20
+ # @return [Avm::FileFormats::FileWith]
21
+ def file_resource_name(path)
22
+ path.to_pathname.to_path
23
+ end
24
+
18
25
  def name
19
26
  self.class.name.demodulize
20
27
  end
@@ -50,19 +50,9 @@ module Avm
50
50
  @result = []
51
51
  end
52
52
 
53
+ # @return [Avm::FileFormats::Base, nil]
53
54
  def find_format(file)
54
- formats.each do |c|
55
- return c if c.match?(file)
56
- end
57
- nil
58
- end
59
-
60
- def formats_uncached
61
- formats_from_registry
62
- end
63
-
64
- def formats_from_registry
65
- ::Avm::Registry.file_formats.available.reverse.map(&:new)
55
+ ::Avm::Registry.file_formats.detect_optional(file)
66
56
  end
67
57
 
68
58
  def search_files
@@ -5,6 +5,10 @@ require 'avm/registry/from_gems'
5
5
  module Avm
6
6
  module Registry
7
7
  class FileFormats < ::Avm::Registry::FromGems
8
+ # @return [Avm::FileFormats::Base]
9
+ def class_detect(klass, detect_args)
10
+ klass.new if klass.new.match?(detect_args.first)
11
+ end
8
12
  end
9
13
  end
10
14
  end
@@ -7,8 +7,8 @@ module Avm
7
7
  module Rspec
8
8
  module Setup
9
9
  require_sub __FILE__
10
- EXAMPLES = %w[avm_file_formats_with_fixtures avm_source_generated entries_values
11
- in_avm_registry not_in_avm_registry].freeze
10
+ EXAMPLES = %w[avm_file_formats_with_fixtures avm_file_format_file_resource_name
11
+ avm_source_generated entries_values in_avm_registry not_in_avm_registry].freeze
12
12
 
13
13
  def self.extended(obj)
14
14
  obj.setup_examples
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ ::RSpec.shared_examples 'avm_file_format_file_resource_name' do |input_expected|
6
+ describe '#file_resource_name' do
7
+ input_expected.each do |path, expected_resource_name|
8
+ context "when path is \"#{path}\"" do
9
+ let(:instance) { described_class.new }
10
+
11
+ it { expect(instance.file_resource_name(path)).to eq(expected_resource_name) }
12
+ end
13
+ end
14
+ end
15
+ end
@@ -7,13 +7,14 @@ module Avm
7
7
  module AutoCommit
8
8
  class FileResourceName
9
9
  require_sub __FILE__, include_modules: true
10
+ enable_simple_cache
10
11
  common_constructor :source_root, :path do
11
12
  self.source_root = source_root.to_pathname
12
13
  self.path = path.to_pathname
13
14
  end
14
15
 
15
16
  def class_name
16
- ruby_class_name || relative_path.to_path
17
+ file_format.file_resource_name(path)
17
18
  end
18
19
 
19
20
  def commit_message
@@ -25,6 +26,13 @@ module Avm
25
26
  def relative_path
26
27
  path.expand_path.relative_path_from(source_root.expand_path)
27
28
  end
29
+
30
+ private
31
+
32
+ # @return [Avm::FileFormats::Base]
33
+ def file_format_uncached
34
+ ::Avm::Registry.file_formats.detect(path)
35
+ end
28
36
  end
29
37
  end
30
38
  end
data/lib/avm/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Avm
4
- VERSION = '0.59.0'
4
+ VERSION = '0.60.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.59.0
4
+ version: 0.60.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo H. Bogoni
@@ -369,6 +369,7 @@ files:
369
369
  - lib/avm/rspec/setup.rb
370
370
  - lib/avm/rspec/setup/launcher.rb
371
371
  - lib/avm/rspec/setup/source_generator.rb
372
+ - lib/avm/rspec/shared_examples/avm_file_format_file_resource_name.rb
372
373
  - lib/avm/rspec/shared_examples/avm_file_formats_with_fixtures.rb
373
374
  - lib/avm/rspec/shared_examples/avm_source_generated.rb
374
375
  - lib/avm/rspec/shared_examples/entries_values.rb
@@ -378,7 +379,6 @@ files:
378
379
  - lib/avm/scms.rb
379
380
  - lib/avm/scms/auto_commit.rb
380
381
  - lib/avm/scms/auto_commit/file_resource_name.rb
381
- - lib/avm/scms/auto_commit/file_resource_name/ruby.rb
382
382
  - lib/avm/scms/auto_commit/for_file.rb
383
383
  - lib/avm/scms/auto_commit/rules.rb
384
384
  - lib/avm/scms/auto_commit/rules/base.rb
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module Avm
6
- module Scms
7
- module AutoCommit
8
- class FileResourceName
9
- module Ruby
10
- RUBY_CLASS_NAME_PATTERNS = [%r{lib/((?!.*/lib/).+)\.rb\z},
11
- %r{app/[^/]+/(.+)\.rb\z}].freeze
12
-
13
- def ruby_class_name
14
- RUBY_CLASS_NAME_PATTERNS.each do |pattern|
15
- pattern.if_match(relative_path.to_path, false) { |m| return m[1].camelize }
16
- end
17
- nil
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end