avm 0.50.0 → 0.51.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: 47575dee73ad5721c2ef69d1c6edb61a7b59f61f6fb61052e59d0382df258ec4
4
- data.tar.gz: e7ac9159bce593101db01a63fbb890f6a22a899f278cc23f4049f99f9938a158
3
+ metadata.gz: c7d526aa03c069d29d98545ce6d90ff1336592ad1c74a432c88430feb4cc71a6
4
+ data.tar.gz: f1b4f72746cd60c762df317eb415a91810de688bf58bc24d1ab261f085974b52
5
5
  SHA512:
6
- metadata.gz: ba4d0decd31a62c03ef96f66a91e19e7753ef3482808390dd9b4281d23ba5a061d1d35ab9d484de30602237935dde705ad672cfb1b18eff3c8bfdef1044c00e4
7
- data.tar.gz: a6f11d49400b9e181741966cda6c140227972e10f34da65546674ffe6432385529e969413584540aa6340e744a532b1d5ad2812d057c0255f0a6b78697a73dbb
6
+ metadata.gz: db1371c99c4d393a1b47cb09275a9fb6c9acb094706119b2db2a83131e87b75a85210b097e76dd053f35b892680713e493b2a2277767b66b0885e5c0434f713a
7
+ data.tar.gz: c2f242bddf30a01e4db4f4aaaffa7878863df455a04023d928ab611951cd2a73b4343cea0bcb312c44db96b98488a4337894f90cf23aba6972f28bf4ab571ee9
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_fs/file_info'
4
+ require 'ostruct'
5
+
6
+ module Avm
7
+ module FileFormats
8
+ class Base
9
+ enable_abstract_methods
10
+
11
+ def apply(files)
12
+ old_content = Hash[files.map { |f| [f, File.read(f)] }]
13
+ ::Avm::Files::Formatter::Utf8Assert.assert_files(files) { internal_apply(files) }
14
+ files.map { |f| build_file_result(f, old_content[f]) }
15
+ end
16
+
17
+ def name
18
+ self.class.name.demodulize
19
+ end
20
+
21
+ def match?(file)
22
+ match_by_filename?(file) || match_by_type?(file)
23
+ end
24
+
25
+ def valid_basenames
26
+ constant_or_array('VALID_BASENAMES')
27
+ end
28
+
29
+ def valid_types
30
+ constant_or_array('VALID_TYPES')
31
+ end
32
+
33
+ private
34
+
35
+ def constant_or_array(name)
36
+ return [] unless self.class.const_defined?(name)
37
+
38
+ self.class.const_get(name)
39
+ end
40
+
41
+ def build_file_result(file, old_content)
42
+ ::OpenStruct.new(file: file, format: self.class,
43
+ changed: (old_content != File.read(file)))
44
+ end
45
+
46
+ def match_by_filename?(file)
47
+ valid_basenames.any? do |valid_basename|
48
+ file.basename.fnmatch?(valid_basename)
49
+ end
50
+ end
51
+
52
+ def match_by_type?(file)
53
+ info = ::EacFs::FileInfo.new(file)
54
+ return unless info.content_type.type == 'text'
55
+
56
+ valid_types.include?(info.content_type.subtype)
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module FileFormats
7
+ require_sub __FILE__
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/registry/from_gems'
4
+
5
+ module Avm
6
+ module Registry
7
+ class FileFormats < ::Avm::Registry::FromGems
8
+ end
9
+ end
10
+ end
data/lib/avm/registry.rb CHANGED
@@ -7,8 +7,8 @@ module Avm
7
7
  module Registry
8
8
  require_sub __FILE__
9
9
  enable_listable
10
- lists.add_symbol :category, :application_stereotypes, :instances, :launcher_stereotypes,
11
- :runners, :scms, :source_generators, :sources
10
+ lists.add_symbol :category, :application_stereotypes, :file_formats, :instances,
11
+ :launcher_stereotypes, :runners, :scms, :source_generators, :sources
12
12
 
13
13
  class << self
14
14
  enable_simple_cache
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.50.0'
4
+ VERSION = '0.51.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.50.0
4
+ version: 0.51.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: 2022-10-16 00:00:00.000000000 Z
11
+ date: 2022-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_cli
@@ -64,20 +64,14 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '0.12'
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- version: 0.12.3
67
+ version: '0.13'
71
68
  type: :runtime
72
69
  prerelease: false
73
70
  version_requirements: !ruby/object:Gem::Requirement
74
71
  requirements:
75
72
  - - "~>"
76
73
  - !ruby/object:Gem::Version
77
- version: '0.12'
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- version: 0.12.3
74
+ version: '0.13'
81
75
  - !ruby/object:Gem::Dependency
82
76
  name: eac_ruby_utils
83
77
  requirement: !ruby/object:Gem::Requirement
@@ -271,6 +265,8 @@ files:
271
265
  - lib/avm/entries/keys_constants_set.rb
272
266
  - lib/avm/entries/uri_builder.rb
273
267
  - lib/avm/executables.rb
268
+ - lib/avm/file_formats.rb
269
+ - lib/avm/file_formats/base.rb
274
270
  - lib/avm/instances.rb
275
271
  - lib/avm/instances/base.rb
276
272
  - lib/avm/instances/base/auto_values.rb
@@ -317,6 +313,7 @@ files:
317
313
  - lib/avm/registry/application_stereotypes.rb
318
314
  - lib/avm/registry/application_stereotypes/build_available.rb
319
315
  - lib/avm/registry/application_stereotypes/stereotype_builder.rb
316
+ - lib/avm/registry/file_formats.rb
320
317
  - lib/avm/registry/from_gems.rb
321
318
  - lib/avm/registry/instances.rb
322
319
  - lib/avm/registry/launcher_stereotypes.rb