avm 0.60.0 → 0.62.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: 8ee7bf9c423e00a5bbd0e070ab0f1a191f338e80c794fde0609a3463c7307d78
4
- data.tar.gz: cdb1a486aadcb408fee1123c133f54c5d46fa912be903f49ed547166027b62a2
3
+ metadata.gz: dbbec67d9fc5bb02ab4df825b7ab2d7a41d8f8beceb6d9615e4d24e60f6add09
4
+ data.tar.gz: 7201af31fe31837eb6723183b610f846f2e315226e5a3d3ccf5766f52519a0f6
5
5
  SHA512:
6
- metadata.gz: d1a37030086636976394fe3392a2681c4065cb8dbabd32fc1f702193b581372372519ef099b254c7c126f3818cff4715dc1597f2ecab1c65a9953044a20362a0
7
- data.tar.gz: 2a72c35e69480aabe07bc71a00ec8cfaf30854ced09da08b423f88c9229f59e42275a902d9797f12a23ec5305c4893803770425b439035a96e70d3f45be30060
6
+ metadata.gz: dbacefed0fe370148ac0e51e4d268fe135c1011c2645923acce1eec543140deec81933d1fb6b3464d62edc17349b0069e3dc14a023b3f141e620122a91b1d349
7
+ data.tar.gz: d9fce3973197919cc053f1b30cf26d1b98a407d43e290c2f0b3ac852ffab57359b9570839c188d73587a8721ae48b561a7fa5f43a2ba53eb3dc822c5ff1de2da
@@ -14,7 +14,7 @@ module Avm
14
14
  end
15
15
 
16
16
  def class_name
17
- file_format.file_resource_name(path)
17
+ file_format.file_resource_name(relative_path)
18
18
  end
19
19
 
20
20
  def commit_message
@@ -16,6 +16,13 @@ module Avm
16
16
  raise_abstract_method __method__
17
17
  end
18
18
 
19
+ # @param commit_to_reset [Avm::Scms::Commit]
20
+ # @param commit_info [Avm::Scms::CommitInfo]
21
+ # @return [Avm::Scms::Commit]
22
+ def reset_and_commit(_commit_to_reset, _commit_info)
23
+ raise_abstract_method __method__
24
+ end
25
+
19
26
  # @param commit_info [Avm::Scms::CommitInfo]
20
27
  # @return [Avm::Scms::Commit]
21
28
  def run_commit(_commit_info)
@@ -5,6 +5,19 @@ require 'eac_ruby_utils/core_ext'
5
5
  module Avm
6
6
  module Scms
7
7
  class CommitInfo
8
+ class << self
9
+ # @param source [Avm::Scms::CommitInfo, String]
10
+ # @return [Avm::Scms::CommitInfo]
11
+ def assert(source)
12
+ return source if source.is_a?(self)
13
+ return new if source.nil?
14
+ return new.message(source) if source.is_a?(::String)
15
+ return assert(source.call) if source.is_a?(::Proc)
16
+
17
+ raise "Unmapped assertion for #{source.to_debug}"
18
+ end
19
+ end
20
+
8
21
  enable_immutable
9
22
 
10
23
  immutable_accessor :fixup, :message
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/scms/base'
4
+ require 'avm/scms/commit'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avm
8
+ module Scms
9
+ class Null < ::Avm::Scms::Base
10
+ class Commit < ::Avm::Scms::Commit
11
+ common_constructor :scm
12
+ end
13
+ end
14
+ end
15
+ end
data/lib/avm/scms/null.rb CHANGED
@@ -6,6 +6,13 @@ require 'eac_ruby_utils/core_ext'
6
6
  module Avm
7
7
  module Scms
8
8
  class Null < ::Avm::Scms::Base
9
+ require_sub __FILE__
10
+
11
+ # @return [Avm::Scms::Null::Commit]
12
+ def head_commit
13
+ @head_commit ||= Avm::Scms::Null::Commit.new(self)
14
+ end
15
+
9
16
  def update
10
17
  # Do nothing
11
18
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Sources
7
+ module AutoCommit
8
+ class ForFile
9
+ common_constructor :source, :path, :rules
10
+
11
+ delegate :run, to: :scm_auto_commit
12
+
13
+ # @return [Pathname]
14
+ def path_for_auto_commit
15
+ path.relative_path_from(source_for_auto_commit.path)
16
+ end
17
+
18
+ # @return [Avm::Scms::AutoCommit::ForFile]
19
+ def scm_auto_commit
20
+ ::Avm::Scms::AutoCommit::ForFile.new(source_for_auto_commit.scm, path_for_auto_commit,
21
+ rules)
22
+ end
23
+
24
+ # @return [Avm::Sources::Base]
25
+ def source_for_auto_commit
26
+ source.sub_for_path(path) || source
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Sources
7
+ module AutoCommit
8
+ require_sub __FILE__
9
+ end
10
+ end
11
+ end
@@ -22,6 +22,13 @@ module Avm
22
22
  configuration.entry(*entry_args)
23
23
  end
24
24
 
25
+ # The possible absolute paths for configuration files.
26
+ #
27
+ # @return [Array<Pathname>]
28
+ def configuration_paths
29
+ CONFIGURATION_FILENAMES.map { |filename| path.join(filename) }
30
+ end
31
+
25
32
  # @return [EacRubyUtils::Envs::Command, nil]
26
33
  def configuration_value_to_env_command(value)
27
34
  return value if value.is_a?(::EacRubyUtils::Envs::Command)
@@ -51,10 +58,10 @@ module Avm
51
58
 
52
59
  # @return [EacConfig::YamlFileNode]
53
60
  def configuration_uncached
54
- CONFIGURATION_FILENAMES.each do |filename|
55
- configuration_with_filename(filename, true)
61
+ configuration_paths.each do |config_path|
62
+ configuration_with_filename(config_path, true)
56
63
  end
57
- configuration_with_filename(CONFIGURATION_FILENAMES.first, false)
64
+ configuration_with_filename(configuration_paths.first, false)
58
65
  end
59
66
 
60
67
  # @return [String]
@@ -68,9 +75,8 @@ module Avm
68
75
  end
69
76
 
70
77
  # @return [EacConfig::YamlFileNode, nil]
71
- def configuration_with_filename(filename, needs_exist)
72
- file_path = path.join(filename)
73
- return ::EacConfig::YamlFileNode.new(file_path) if !needs_exist || file_path.exist?
78
+ def configuration_with_filename(config_path, needs_exist)
79
+ return ::EacConfig::YamlFileNode.new(config_path) if !needs_exist || config_path.exist?
74
80
 
75
81
  nil
76
82
  end
@@ -20,6 +20,13 @@ module Avm
20
20
  def default_locale
21
21
  ::I18n.default_locale
22
22
  end
23
+
24
+ # @param entry_suffix [String]
25
+ # @param values [Hash]
26
+ # @return [String]
27
+ def i18n_translate(entry_suffix, values = {})
28
+ self.class.i18n_translate(entry_suffix, values.merge(__locale: locale))
29
+ end
23
30
  end
24
31
  end
25
32
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Sources
7
+ class Base
8
+ module Organizational
9
+ DEFAULT_ORGANIZATIONAL = false
10
+ ORGANIZATIONAL_KEY = 'organizational'
11
+
12
+ # @return [Boolean]
13
+ def organizational?
14
+ if organizational_entry.found?
15
+ organizational_entry.value.to_bool
16
+ else
17
+ default_organizational
18
+ end
19
+ end
20
+
21
+ def organizational_entry
22
+ configuration.entry(ORGANIZATIONAL_KEY)
23
+ end
24
+
25
+ # @return [Boolean]
26
+ def default_organizational
27
+ DEFAULT_ORGANIZATIONAL
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -12,6 +12,11 @@ module Avm
12
12
  SUBS_EXCLUDE_PATHS_DEFAULT = [].freeze
13
13
  SUBS_INCLUDE_PATHS_DEFAULT = ['sub/*'].freeze
14
14
 
15
+ # @return [Avm::Sources::Base, nil]
16
+ def sub_for_path(path)
17
+ subs.lazy.map { |sub| path.expand_path.child_of?(sub.path) ? sub : nil }.find(&:present?)
18
+ end
19
+
15
20
  # @return [Enumerable<Avm::Sources::Base>]
16
21
  def subs
17
22
  subs_paths_to_search
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Sources
7
+ class Base
8
+ module Update
9
+ # To override in subclasses.
10
+ def on_sub_updated
11
+ # Do nothing
12
+ end
13
+
14
+ def update
15
+ update_self
16
+ update_subs
17
+ end
18
+
19
+ def update_self
20
+ scm.commit_if_change(-> { update_self_commit_message }) do
21
+ update_self_content
22
+ parent.if_present(&:on_sub_updated)
23
+ end
24
+ end
25
+
26
+ # Update source self content.
27
+ #
28
+ # To override in subclasses.
29
+ def update_self_content
30
+ # Do nothing
31
+ end
32
+
33
+ def update_self_commit_message
34
+ i18n_translate(__method__)
35
+ end
36
+
37
+ def update_subs
38
+ subs.each { |sub| update_sub(sub) }
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Sources
7
+ class Base
8
+ class UpdateSub
9
+ enable_method_class
10
+
11
+ common_constructor :source, :sub
12
+
13
+ def result
14
+ update_version
15
+ return unless sub.organizational?
16
+
17
+ sub.update
18
+ end
19
+
20
+ private
21
+
22
+ def update_version
23
+ base_commit = source.scm.head_commit
24
+ sub.scm.update
25
+ on_update_version_commit_change(base_commit) unless base_commit == source.scm.head_commit
26
+ end
27
+
28
+ def on_update_version_commit_change(base_commit)
29
+ source.on_sub_updated if no_scm_updated?
30
+ source.scm.reset_and_commit(base_commit, update_version_commit_info)
31
+ end
32
+
33
+ def no_scm_updated?
34
+ source.scm.head_commit.no_scm_changed_files.any?
35
+ end
36
+
37
+ # @param commit_info [Avm::Scms::CommitInfo]
38
+ def update_version_commit_info
39
+ Avm::Scms::CommitInfo.new.message(
40
+ no_scm_updated? ? update_version_no_scm_message : update_version_scm_message
41
+ )
42
+ end
43
+
44
+ # @return [String]
45
+ def update_version_no_scm_message
46
+ source.i18n_translate(__method__, application_id: sub.application_id,
47
+ path: sub.relative_path, version: sub.version)
48
+ end
49
+
50
+ # @return [String]
51
+ def update_version_scm_message
52
+ sub.scm.i18n_translate(__method__)
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/sources/base'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Sources
8
+ class Base
9
+ module VersionBump
10
+ # @return [Avm::Scms::Commit, nil]
11
+ def version_bump(target_version)
12
+ scm.commit_if_change(version_bump_commit_message(target_version)) do
13
+ version_bump_do_changes(target_version)
14
+ parent.if_present(&:on_sub_updated)
15
+ end
16
+ end
17
+
18
+ # @return [String]
19
+ def version_bump_commit_message(target_version)
20
+ i18n_translate(__method__, version: target_version, __locale: locale)
21
+ end
22
+
23
+ def version_bump_do_changes(_target_version)
24
+ raise_abstract_method(__METHOD__)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -23,7 +23,7 @@ module Avm
23
23
  self.options = ::Avm::Sources::Base.lists.option.hash_keys_validate!(options)
24
24
  end
25
25
 
26
- abstract_methods :update, :valid?
26
+ abstract_methods :valid?
27
27
 
28
28
  # @return [EacRubyUtils::Envs::LocalEnv]
29
29
  def env
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.60.0'
4
+ VERSION = '0.62.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.60.0
4
+ version: 0.62.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-01-09 00:00:00.000000000 Z
11
+ date: 2023-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -106,20 +106,14 @@ dependencies:
106
106
  requirements:
107
107
  - - "~>"
108
108
  - !ruby/object:Gem::Version
109
- version: '0.110'
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- version: 0.110.1
109
+ version: '0.111'
113
110
  type: :runtime
114
111
  prerelease: false
115
112
  version_requirements: !ruby/object:Gem::Requirement
116
113
  requirements:
117
114
  - - "~>"
118
115
  - !ruby/object:Gem::Version
119
- version: '0.110'
120
- - - ">="
121
- - !ruby/object:Gem::Version
122
- version: 0.110.1
116
+ version: '0.111'
123
117
  - !ruby/object:Gem::Dependency
124
118
  name: eac_templates
125
119
  requirement: !ruby/object:Gem::Requirement
@@ -396,6 +390,7 @@ files:
396
390
  - lib/avm/scms/inflector.rb
397
391
  - lib/avm/scms/interval.rb
398
392
  - lib/avm/scms/null.rb
393
+ - lib/avm/scms/null/commit.rb
399
394
  - lib/avm/self/docker_image.rb
400
395
  - lib/avm/self/instance.rb
401
396
  - lib/avm/self/instance/entry_keys.rb
@@ -405,16 +400,22 @@ files:
405
400
  - lib/avm/source_generators/option_list.rb
406
401
  - lib/avm/source_generators/runner.rb
407
402
  - lib/avm/sources.rb
403
+ - lib/avm/sources/auto_commit.rb
404
+ - lib/avm/sources/auto_commit/for_file.rb
408
405
  - lib/avm/sources/base.rb
409
406
  - lib/avm/sources/base/application.rb
410
407
  - lib/avm/sources/base/configuration.rb
411
408
  - lib/avm/sources/base/instance.rb
412
409
  - lib/avm/sources/base/locale.rb
410
+ - lib/avm/sources/base/organizational.rb
413
411
  - lib/avm/sources/base/parent.rb
414
412
  - lib/avm/sources/base/stereotype.rb
415
413
  - lib/avm/sources/base/subs.rb
416
414
  - lib/avm/sources/base/subs_paths.rb
417
415
  - lib/avm/sources/base/testing.rb
416
+ - lib/avm/sources/base/update.rb
417
+ - lib/avm/sources/base/update_sub.rb
418
+ - lib/avm/sources/base/version_bump.rb
418
419
  - lib/avm/sources/configuration.rb
419
420
  - lib/avm/sources/configuration/rubocop.rb
420
421
  - lib/avm/sources/runner.rb