avm 0.65.0 → 0.66.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/avm/file_formats/base.rb +8 -41
- data/lib/avm/file_formats/file_result.rb +13 -0
- data/lib/avm/file_formats/unknown.rb +18 -0
- data/lib/avm/registry/file_formats.rb +6 -0
- data/lib/avm/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b052d242bf8dccbe7db34f395acd096c3700c7553ee5c16f590970653ad6274f
|
4
|
+
data.tar.gz: 35f3f1cbb0840d82b8450921f2725b1adf10df833f82f9ec82138bb777b52e74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
30
|
-
|
31
|
-
|
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,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
|
@@ -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
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.
|
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-
|
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
|