Class: BundleSafeUpdate::GemChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/bundle_safe_update/gem_checker.rb

Defined Under Namespace

Classes: CheckResult

Constant Summary collapse

DEFAULT_MAX_THREADS =
32

Instance Method Summary collapse

Constructor Details

#initialize(config:, api: nil, lockfile_parser: nil, max_threads: nil) ⇒ GemChecker

Returns a new instance of GemChecker.



9
10
11
12
13
14
# File 'lib/bundle_safe_update/gem_checker.rb', line 9

def initialize(config:, api: nil, lockfile_parser: nil, max_threads: nil)
  @config = config
  @api = api || RubygemsApi.new
  @lockfile_parser = lockfile_parser || LockfileParser.new
  @max_threads = max_threads || DEFAULT_MAX_THREADS
end

Instance Method Details

#check_all(outdated_gems) ⇒ Object



27
28
29
30
31
# File 'lib/bundle_safe_update/gem_checker.rb', line 27

def check_all(outdated_gems)
  return [] if outdated_gems.empty?

  check_all_parallel(outdated_gems)
end

#check_gem(gem_info) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/bundle_safe_update/gem_checker.rb', line 16

def check_gem(gem_info)
  return ignored_result(gem_info) if @config.ignored?(gem_info.name)
  return trusted_source_result(gem_info) if trusted_source?(gem_info.name)
  return trusted_owner_result(gem_info) if trusted_owner?(gem_info.name)

  age_days = @api.version_age_days(gem_info.name, gem_info.newest_version)
  return not_found_result(gem_info) if age_days.nil?

  age_check_result(gem_info, age_days)
end