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.35.1 lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.96.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
avm-eac_ruby_base1-0.35.0 lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.95.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
avm-eac_ruby_base1-0.34.1 lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.91.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
avm-eac_ruby_base1-0.34.0 lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.91.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
avm-eac_ruby_base1-0.33.1 lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.83.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.82.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.81.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
avm-eac_ruby_base1-0.33.0 lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.80.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.79.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
avm-eac_ruby_base1-0.32.1 lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.78.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
avm-eac_ruby_base1-0.32.0 lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.77.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
eac_tools-0.77.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb