Sha256: 4598036a43fb2a77554017df58d6e5309c1ed97d07cf4328871892405be63b0d

Contents?: true

Size: 1.66 KB

Versions: 20

Compression:

Stored size: 1.66 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
            ::I18n.default_locale = instance.locale
            translate(__method__, version: target_version)
          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

20 entries across 20 versions & 1 rubygems

Version Path
avm-tools-0.78.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.77.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.76.1 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.76.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.75.1 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.75.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.74.1 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.74.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.73.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.72.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.71.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.70.2 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.70.1 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.70.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.69.3 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.69.2 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.69.1 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.69.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.68.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.67.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb