Sha256: d0f4085250a0c5e9adf144b09534a191fc1bc9a666d9473ce713adfe6be73b8b

Contents?: true

Size: 1.79 KB

Versions: 120

Compression:

Stored size: 1.79 KB

Contents

# frozen_string_literal: true

require 'avm/eac_ruby_base1/rubygems/gemspec'
require 'avm/eac_ruby_base1/sources/update_dependency_requirements'
require 'eac_cli/core_ext'

module Avm
  module EacRubyBase1
    module Sources
      module Runners
        class UpdateDependenciesRequirements
          runner_with :help do
            bool_opt '-a', '--all'
            arg_opt '-e', '--exclude', repeat: true
            pos_arg :gem_name, repeat: true, optional: true
          end

          def run
            start_banner
            update_gemfile_lock
            process_all_gems
          end

          def gemspec
            ::Avm::EacRubyBase1::Rubygems::Gemspec.from_file(
              runner_context.call(:source).gemspec_path
            )
          end

          private

          def exclude?(gem_name)
            parsed.exclude.include?(gem_name)
          end

          def gem_names_uncached
            ::Set.new(parsed.gem_name + gem_names_from_all).reject { |gem_name| exclude?(gem_name) }
              .sort
          end

          def gem_names_from_all
            return [] unless parsed.all?

            gemspec.dependencies.map(&:gem_name)
          end

          def process_all_gems
            gem_names.each do |gem_name|
              infov 'Gem to update', gem_name
              ::Avm::EacRubyBase1::Sources::UpdateDependencyRequirements
                .new(runner_context.call(:source), gem_name).perform
            end
          end

          def start_banner
            runner_context.call(:source_banner)
            infov 'Gems to update', gem_names.count
          end

          def update_gemfile_lock
            infom 'Updating Gemfile\'s lock...'
            runner_context.call(:source).bundle('update').execute!
          end
        end
      end
    end
  end
end

Version data entries

120 entries across 120 versions & 2 rubygems

Version Path
avm-eac_ruby_base1-0.30.3 lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.65.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.65.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.64.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.63.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.62.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.62.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.61.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.61.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
avm-eac_ruby_base1-0.30.2 lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.60.3 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.60.2 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.60.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.60.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.59.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
avm-eac_ruby_base1-0.30.1 lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.58.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.57.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.56.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.56.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb