Class: DependencyTimelineAudit::Check

Inherits:
Object
  • Object
show all
Defined in:
lib/dependency-timeline-audit/check.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config:) ⇒ Check

Returns a new instance of Check.



7
8
9
# File 'lib/dependency-timeline-audit/check.rb', line 7

def initialize(config:)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/dependency-timeline-audit/check.rb', line 5

def config
  @config
end

Instance Method Details

#checkObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dependency-timeline-audit/check.rb', line 11

def check
  outdated_versions = []
  locked_gems.each do |gem|
    outdated_versions.push(gem) if gem.locked_version.outdated?
    gem.print_info if config.verbose
  end

  print "\n" if config.verbose

  if outdated_versions.any?
    TextFormat.color = :red
    puts "Outdated gems detected!"
    puts " - #{outdated_versions.join(', ')}"

    exit(1) # Failure
  else
    puts "All gems are within the accepted threshold!"

    exit(0) # Success
  end
end