avm 0.64.2 → 0.66.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: cfbe828fa402574c8d87792d855971448ab931e26ecfb1ed15ea50acc81169e6
4
- data.tar.gz: 3a1c0bc8719b29f23cb8e8b195430ca875592b8f01902e1cddcd80ac64943774
3
+ metadata.gz: b052d242bf8dccbe7db34f395acd096c3700c7553ee5c16f590970653ad6274f
4
+ data.tar.gz: 35f3f1cbb0840d82b8450921f2725b1adf10df833f82f9ec82138bb777b52e74
5
5
  SHA512:
6
- metadata.gz: 7fb5104275aa21de8f5b647cd035df7ddf7cf5a5525138d1485643d931257974de2bcf3adbc735212b7c2e4e3958a4079ebd14d6a9bee1c319f0f9fa4984a90e
7
- data.tar.gz: 71880eff3e7920658456b8e5e7fe7998b53ea27c5fed3c612008147ad55e65c12268b6f6a67608fa6c89e684d57711114d803bcbfefe5cd16de1370914f5ffbc
6
+ metadata.gz: 1d3e9166ff3862d74e3d5087509c2fb0efbf5d96072eb6acde907ceb88eb14c4be73b7b4b6e0a36081feeefd893050c5bb18abc99b06e3bf983485c20a9af7ea
7
+ data.tar.gz: 0c1245bdf1e60ccee7bd6f270d7962f2e7eac458c802a728d395f0fb72e8e62e79535a9a0a3e5921bd8f7254bfa907ab7fafbc9a54e765d842aefa6973c3baa6
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avm/file_formats/utf8_assert'
4
3
  require 'eac_fs/file_info'
5
4
  require 'ostruct'
6
5
 
@@ -10,10 +9,10 @@ module Avm
10
9
  enable_abstract_methods
11
10
  compare_by :class
12
11
 
13
- def apply(files)
14
- old_content = Hash[files.map { |f| [f, File.read(f)] }]
15
- ::Avm::FileFormats::Utf8Assert.assert_files(files) { internal_apply(files) }
16
- files.map { |f| build_file_result(f, old_content[f]) }
12
+ # @params files [Enumerable<Pathname>]
13
+ # @return [Enumerable<Avm::FileFormats::FileResult>]
14
+ def apply(_files)
15
+ raise_abstract_method __method__
17
16
  end
18
17
 
19
18
  # @param path [Pathname]
@@ -26,42 +25,10 @@ module Avm
26
25
  self.class.name.demodulize
27
26
  end
28
27
 
29
- def match?(file)
30
- match_by_filename?(file) || match_by_type?(file)
31
- end
32
-
33
- def valid_basenames
34
- constant_or_array('VALID_BASENAMES')
35
- end
36
-
37
- def valid_types
38
- constant_or_array('VALID_TYPES')
39
- end
40
-
41
- private
42
-
43
- def constant_or_array(name)
44
- return [] unless self.class.const_defined?(name)
45
-
46
- self.class.const_get(name)
47
- end
48
-
49
- def build_file_result(file, old_content)
50
- ::OpenStruct.new(file: file, format: self.class,
51
- changed: (old_content != File.read(file)))
52
- end
53
-
54
- def match_by_filename?(file)
55
- valid_basenames.any? do |valid_basename|
56
- file.basename.fnmatch?(valid_basename)
57
- end
58
- end
59
-
60
- def match_by_type?(file)
61
- info = ::EacFs::FileInfo.new(file)
62
- return unless info.content_type.type == 'text'
63
-
64
- valid_types.include?(info.content_type.subtype)
28
+ # @param file [Pathname]
29
+ # @return [Boolean]
30
+ def match?(_file)
31
+ raise_abstract_method __method__
65
32
  end
66
33
  end
67
34
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/file_formats/utf8_assert'
4
+ require 'eac_fs/file_info'
5
+ require 'ostruct'
6
+
7
+ module Avm
8
+ module FileFormats
9
+ class FileResult
10
+ common_constructor :file, :format, :changed
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/file_formats/base'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module FileFormats
8
+ class Unknown < ::Avm::FileFormats::Base
9
+ # @params files [Enumerable<Pathname>]
10
+ # @return [Enumerable<Avm::FileFormats::FileResult>]
11
+ def apply(files)
12
+ files.map do |file|
13
+ ::Avm::FileFormats::FileResult.new(file, self.class, false)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -7,8 +7,9 @@ module Avm
7
7
  class Base
8
8
  module AutoValues
9
9
  module Database
10
+ LOCAL_ADDRESS = '127.0.0.1'
10
11
  DEFAULT_EXTRA = ''
11
- DEFAULT_HOSTNAME = '127.0.0.1'
12
+ DEFAULT_HOSTNAME = LOCAL_ADDRESS
12
13
  DEFAULT_LIMIT = 5
13
14
  DEFAULT_PORTS = {
14
15
  'postgresql' => 5432,
@@ -19,8 +20,16 @@ module Avm
19
20
  DEFAULT_SYSTEM = 'postgresql'
20
21
  DEFAULT_TIMEOUT = 5000
21
22
 
22
- def auto_database_extra
23
- database_auto_common('hostname') || DEFAULT_EXTRA
23
+ %w[extra hostname limit system timeout].each do |attr|
24
+ define_method "auto_database_#{attr}" do
25
+ database_auto_common(attr) || self.class.const_get("default_#{attr}".upcase)
26
+ end
27
+ end
28
+
29
+ %w[username password].each do |attr|
30
+ define_method "auto_database_#{attr}" do
31
+ database_auto_common(attr) || id
32
+ end
24
33
  end
25
34
 
26
35
  def auto_database_name
@@ -28,34 +37,10 @@ module Avm
28
37
  ::Avm::Instances::EntryKeys::DATABASE_NAME) || id
29
38
  end
30
39
 
31
- def auto_database_hostname
32
- database_auto_common('hostname') || DEFAULT_HOSTNAME
33
- end
34
-
35
- def auto_database_limit
36
- database_auto_common('limit') || DEFAULT_LIMIT
37
- end
38
-
39
- def auto_database_password
40
- database_auto_common('password') || id
41
- end
42
-
43
40
  def auto_database_port
44
41
  database_auto_common('port') || database_port_by_system
45
42
  end
46
43
 
47
- def auto_database_username
48
- database_auto_common('username') || id
49
- end
50
-
51
- def auto_database_system
52
- database_auto_common('system') || DEFAULT_SYSTEM
53
- end
54
-
55
- def auto_database_timeout
56
- database_auto_common('timeout') || DEFAULT_TIMEOUT
57
- end
58
-
59
44
  private
60
45
 
61
46
  def database_auto_common(suffix)
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/file_formats/unknown'
3
4
  require 'avm/registry/from_gems'
4
5
 
5
6
  module Avm
@@ -9,6 +10,11 @@ module Avm
9
10
  def class_detect(klass, detect_args)
10
11
  klass.new if klass.new.match?(detect_args.first)
11
12
  end
13
+
14
+ # @return [Avm::FileFormats::Base, Avm::FileFormats::Unknown]
15
+ def detect_optional(*registered_initialize_args)
16
+ super || ::Avm::FileFormats::Unknown.new
17
+ end
12
18
  end
13
19
  end
14
20
  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.64.2'
4
+ VERSION = '0.66.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.64.2
4
+ version: 0.66.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: 2023-03-31 00:00:00.000000000 Z
11
+ date: 2023-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -279,7 +279,9 @@ files:
279
279
  - lib/avm/executables.rb
280
280
  - lib/avm/file_formats.rb
281
281
  - lib/avm/file_formats/base.rb
282
+ - lib/avm/file_formats/file_result.rb
282
283
  - lib/avm/file_formats/search_formatter.rb
284
+ - lib/avm/file_formats/unknown.rb
283
285
  - lib/avm/file_formats/utf8_assert.rb
284
286
  - lib/avm/instances.rb
285
287
  - lib/avm/instances/base.rb
@@ -287,7 +289,6 @@ files:
287
289
  - lib/avm/instances/base/auto_values/data.rb
288
290
  - lib/avm/instances/base/auto_values/database.rb
289
291
  - lib/avm/instances/base/auto_values/mailer.rb
290
- - lib/avm/instances/base/auto_values/ruby.rb
291
292
  - lib/avm/instances/base/auto_values/source.rb
292
293
  - lib/avm/instances/base/dockerizable.rb
293
294
  - lib/avm/instances/base/entry_keys.rb
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Avm
4
- module Instances
5
- class Base
6
- module AutoValues
7
- module Ruby
8
- def auto_ruby_version
9
- inherited_entry_value(::Avm::Instances::EntryKeys::INSTALL_ID, 'ruby.version')
10
- end
11
- end
12
- end
13
- end
14
- end
15
- end