Sha256: b29f86ee06abd612de2c662a6aa251d5b7c317d07b53cdb13516f206e9666fc1

Contents?: true

Size: 1.47 KB

Versions: 47

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

require 'avm/eac_ruby_base1/preferred_version_requirements'
require 'eac_ruby_utils/core_ext'

module Avm
  module EacRubyBase1
    module Sources
      class UpdateDependencyRequirements
        enable_simple_cache
        common_constructor :source, :gem_name

        def perform
          source.scm.commit_if_change(commit_message) { update_code }
        end

        private

        # @return [String]
        def commit_message
          i18n_translate(__method__,
                         name: gem_name,
                         requirements_list: requirements_list.join(', '),
                         __locale: source.locale)
        end

        # @return [Array<String>]
        def requirements_list_uncached
          ::Avm::EacRubyBase1::PreferredVersionRequirements.new(
            source.gemfile_lock_gem_version(gem_name)
          ).to_requirements_list
        end

        def gemspec_uncached
          ::Avm::EacRubyBase1::Rubygems::Gemspec.from_file(source.gemspec_path)
        end

        def parent_bundle
          source.parent.if_present(&:on_sub_updated)
        end

        def update_code
          update_gemspec
          source.bundle.system!
          parent_bundle
        end

        def update_gemspec
          gemspec.dependency(gem_name).version_specs = requirements_list
          gemspec.write(source.gemspec_path)
          source.bundle('exec', 'rubocop', source.gemspec_path).system!
        end
      end
    end
  end
end

Version data entries

47 entries across 47 versions & 2 rubygems

Version Path
avm-eac_ruby_base1-0.31.0 lib/avm/eac_ruby_base1/sources/update_dependency_requirements.rb
eac_tools-0.75.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update_dependency_requirements.rb
eac_tools-0.74.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update_dependency_requirements.rb
eac_tools-0.74.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update_dependency_requirements.rb
eac_tools-0.73.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update_dependency_requirements.rb
eac_tools-0.72.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update_dependency_requirements.rb
eac_tools-0.70.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update_dependency_requirements.rb
eac_tools-0.70.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update_dependency_requirements.rb
eac_tools-0.69.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update_dependency_requirements.rb
eac_tools-0.69.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update_dependency_requirements.rb
eac_tools-0.68.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update_dependency_requirements.rb
eac_tools-0.67.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update_dependency_requirements.rb
eac_tools-0.67.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update_dependency_requirements.rb
eac_tools-0.66.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update_dependency_requirements.rb
avm-eac_ruby_base1-0.30.3 lib/avm/eac_ruby_base1/sources/update_dependency_requirements.rb
eac_tools-0.65.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update_dependency_requirements.rb
eac_tools-0.65.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update_dependency_requirements.rb
eac_tools-0.64.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update_dependency_requirements.rb
eac_tools-0.63.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update_dependency_requirements.rb
eac_tools-0.62.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/update_dependency_requirements.rb