Sha256: 371cb16a90cd81195cd1c4664242c24cbee4fc2f0d8d1d3cfc2f236b6f8920a6

Contents?: true

Size: 1.63 KB

Versions: 18

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true

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

module Avm
  module Projects
    module Stereotypes
      class RubyGem
        class VersionBump
          enable_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_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

18 entries across 18 versions & 1 rubygems

Version Path
avm-tools-0.116.2 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.116.1 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.116.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.115.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.114.2 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.114.1 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.114.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.113.6 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.113.5 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.113.4 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.113.3 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.113.2 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.113.1 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.113.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.112.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.111.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.110.0 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
avm-tools-0.109.1 lib/avm/projects/stereotypes/ruby_gem/version_bump.rb