Sha256: 842c01bf0415fda2c705e36bd8732a1e7076270d8bdac92846c10488a2ef2f56

Contents?: true

Size: 1.61 KB

Versions: 33

Compression:

Stored size: 1.61 KB

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'

module Avm
  module Projects
    module Stereotypes
      class RubyGem
        class Update
          enable_console_speaker
          common_constructor :instance

          def run
            gemfile_lock_checkout
            bundle_update
            gemfile_lock_commit
          end

          private

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

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

            infom 'Checkouting Gemfile.lock...'
            instance.git_repo.command('checkout', '--',
                                      instance.ruby_gem.gemfile_lock_path.to_path).execute!
          end

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

            if gemfile_lock_changed?
              infom 'Commiting Gemfile.lock...'
              instance.git_repo.command('commit', '-m', gemfile_lock_commit_message, '--',
                                        instance.ruby_gem.gemfile_lock_path).execute!
            else
              infom 'Gemfile.lock did not change'
            end
          end

          def gemfile_lock_commit_message
            'Todas as gems: atualiza.'
          end

          def gemfile_lock_changed?
            instance.git_repo.dirty_file?(instance.ruby_gem.gemfile_lock_path)
          end
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

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