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.66.0 lib/avm/projects/stereotypes/ruby_gem/update.rb
avm-tools-0.65.0 lib/avm/projects/stereotypes/ruby_gem/update.rb
avm-tools-0.64.2 lib/avm/projects/stereotypes/ruby_gem/update.rb
avm-tools-0.64.1 lib/avm/projects/stereotypes/ruby_gem/update.rb
avm-tools-0.64.0 lib/avm/projects/stereotypes/ruby_gem/update.rb
avm-tools-0.63.0 lib/avm/projects/stereotypes/ruby_gem/update.rb
avm-tools-0.62.4 lib/avm/projects/stereotypes/ruby_gem/update.rb
avm-tools-0.62.3 lib/avm/projects/stereotypes/ruby_gem/update.rb
avm-tools-0.62.2 lib/avm/projects/stereotypes/ruby_gem/update.rb
avm-tools-0.62.1 lib/avm/projects/stereotypes/ruby_gem/update.rb
avm-tools-0.62.0 lib/avm/projects/stereotypes/ruby_gem/update.rb
avm-tools-0.61.0 lib/avm/projects/stereotypes/ruby_gem/update.rb
avm-tools-0.60.0 lib/avm/projects/stereotypes/ruby_gem/update.rb