Sha256: c4ed10791ae62eaaf071ae257bb0e8c91b2c8f010ea281ccaffe6a8318ab49f8

Contents?: true

Size: 1.63 KB

Versions: 26

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true

require 'avm/patches/object/i18n'
require 'eac_ruby_utils/core_ext'

module Avm
  module Projects
    module Stereotypes
      class RubyGem
        class VersionBump
          enable_console_speaker
          common_constructor :instance, :target_version

          def run
            git_checkout
            change_version
            bundle_run
            git_commit
          end

          private

          def bundle_run
            infom 'Running "bundle install"...'
            instance.ruby_gem.bundle('install').execute!
          end

          def change_version
            infom 'Setting project version...'
            instance.version = target_version
          end

          def git_checkout
            return unless instance.respond_to?(:git_repo)

            infom "Checkouting #{changing_files.map(&:to_path).join(', ')}..."
            instance.git_repo.command('checkout', '--',
                                      *changing_files.map(&:to_path)).execute!
          end

          def git_commit
            return unless instance.respond_to?(:git_repo)

            infom "Commiting #{changing_files.map(&:to_path).join(', ')}..."
            instance.git_repo.command('commit', '-m', git_commit_message, '--',
                                      *changing_files.map(&:to_path)).execute!
          end

          def git_commit_message
            translate(__method__, version: target_version, __locale: instance.locale)
          end

          def changing_files
            [instance.ruby_gem.gemfile_lock_path, instance.ruby_gem.version_file_path]
          end
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
avm-tools-0.98.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.97.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.96.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.95.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.94.3 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.94.2 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.94.1 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.94.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.93.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.92.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.91.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.90.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.89.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.88.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.87.1 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.87.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.86.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.85.1 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.85.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.84.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb