avm 0.65.0 → 0.66.1
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/launcher/publish/base.rb +6 -1
- 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: 1dd452a1cb233171f982fb3da213367417fd59f801dd1313f069f3bfc7ad6037
|
4
|
+
data.tar.gz: b6e05b77f939fa23af9cdf2c999b1e82f3f0dc18323393e62a38410cd012c363
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6eebe945bf1be89d66779f9db42474cdefc734ca13d994301ba7f11df97b0087941c1c7c967e0973d32d99df8b70c4ecfcdb95296dac76a865398430ca4da409
|
7
|
+
data.tar.gz: 5d347b0d68044bec6cee52df488fbe0ed4d3f760a1eaee225d1de4be7529e8b51dde5141e46bc530cfef31cdff372ee25b7ae064fc958113ecf94634e2c47412
|
@@ -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
|
@@ -34,7 +34,12 @@ module Avm
|
|
34
34
|
def check_with_rescue
|
35
35
|
internal_check
|
36
36
|
rescue ::Avm::Launcher::Errors::Base => e
|
37
|
-
::Avm::Launcher::Publish::CheckResult.blocked("Error: #{e}")
|
37
|
+
::Avm::Launcher::Publish::CheckResult.blocked("Error: #{error_message(e)}")
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [String]
|
41
|
+
def error_message(error)
|
42
|
+
error.to_s + error.cause.if_present('') { |v| " / Caused by: #{error_message(v)}" }
|
38
43
|
end
|
39
44
|
end
|
40
45
|
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.1
|
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-05 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
|