Sha256: cbe77754f21e4f72d7d63a1979d2b71c602c92b8eeab83767432bc725c64d568

Contents?: true

Size: 1.58 KB

Versions: 5

Compression:

Stored size: 1.58 KB

Contents

# frozen_string_literal: true

module Avm
  module EacRubyBase1
    module SourceStereotypes
      class Update
        class SubUpdate
          enable_simple_cache
          enable_speaker
          common_constructor :source_update, :sub do
            perform
          end
          delegate :source, to: :source_update

          protected

          def on_scm_updated(commit)
            if commit.no_scm_changed_files.any?
              commit = commit.reword(no_scm_update_commit_message)
              source.scm.commit_if_change { source_update.bundle_update }
                    .if_present { |v| v.merge_with(commit) }
            else
              commit.reword(scm_update_commit_message)
            end
          end

          def perform
            update_scm.if_present { |commit| on_scm_updated(commit) }
          end

          def ruby_gem_uncached
            ::EacRubyGemsUtils::Gem.new(sub.path)
          end

          def no_scm_update_commit_message
            source_update.i18n_translate(__method__, __locale: source.locale,
                                                     name: ruby_gem.name,
                                                     version: ruby_gem.version)
          end

          def scm_update_commit_message
            source_update.i18n_translate(__method__, __locale: source.locale)
          end

          # @return [Avm::Scms::Commit]
          def update_scm
            infom "Updating \"#{sub}\"..."
            source.scm.commit_if_change do
              sub.scm.update
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
avm-eac_ruby_base1-0.2.0 lib/avm/eac_ruby_base1/source_stereotypes/update/sub_update.rb
avm-tools-0.110.0 vendor/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_stereotypes/update/sub_update.rb
avm-tools-0.109.1 vendor/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_stereotypes/update/sub_update.rb
avm-eac_ruby_base1-0.1.0 lib/avm/eac_ruby_base1/source_stereotypes/update/sub_update.rb
avm-tools-0.109.0 vendor/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_stereotypes/update/sub_update.rb