avm 0.60.0 → 0.61.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: fbd9a676670802e3c3904a555bc7255ab8637a1b474131e6f39190192d47d64d
4
+ data.tar.gz: 8f743999b2b25fe740cd813356e9104d9b29dcf03968c7a300afb31385babe83
5
5
  SHA512:
6
- metadata.gz: d1a37030086636976394fe3392a2681c4065cb8dbabd32fc1f702193b581372372519ef099b254c7c126f3818cff4715dc1597f2ecab1c65a9953044a20362a0
7
- data.tar.gz: 2a72c35e69480aabe07bc71a00ec8cfaf30854ced09da08b423f88c9229f59e42275a902d9797f12a23ec5305c4893803770425b439035a96e70d3f45be30060
6
+ metadata.gz: 1a96c7da39855abf2991b203b697ff69e61d4bdb4b322bebccf06066df2e59ab843d3bc5ecefc2e3a3011d7c514ec1854635d98e8d116089a55075bd7d07e166
7
+ data.tar.gz: a066bec86aed66c6f2d8bd6f849534551c684340bc61fa67da7a94dd4fdcffc4ffc43b33cb237f184f20a418232587f762bea578f743095fd2eeb2155527c83e
@@ -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
@@ -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
@@ -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.61.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.61.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-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -396,6 +396,7 @@ files:
396
396
  - lib/avm/scms/inflector.rb
397
397
  - lib/avm/scms/interval.rb
398
398
  - lib/avm/scms/null.rb
399
+ - lib/avm/scms/null/commit.rb
399
400
  - lib/avm/self/docker_image.rb
400
401
  - lib/avm/self/instance.rb
401
402
  - lib/avm/self/instance/entry_keys.rb
@@ -410,11 +411,15 @@ files:
410
411
  - lib/avm/sources/base/configuration.rb
411
412
  - lib/avm/sources/base/instance.rb
412
413
  - lib/avm/sources/base/locale.rb
414
+ - lib/avm/sources/base/organizational.rb
413
415
  - lib/avm/sources/base/parent.rb
414
416
  - lib/avm/sources/base/stereotype.rb
415
417
  - lib/avm/sources/base/subs.rb
416
418
  - lib/avm/sources/base/subs_paths.rb
417
419
  - lib/avm/sources/base/testing.rb
420
+ - lib/avm/sources/base/update.rb
421
+ - lib/avm/sources/base/update_sub.rb
422
+ - lib/avm/sources/base/version_bump.rb
418
423
  - lib/avm/sources/configuration.rb
419
424
  - lib/avm/sources/configuration/rubocop.rb
420
425
  - lib/avm/sources/runner.rb