Class: DependencyTimelineAudit::GemVersion

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gem:, name:) ⇒ GemVersion

Returns a new instance of GemVersion.



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

def initialize(gem:, name:)
  @gem = gem
  @config = gem.config
  @name = name.to_s
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



3
4
5
# File 'lib/dependency-timeline-audit/gem_version.rb', line 3

def config
  @config
end

#gemObject (readonly)

Returns the value of attribute gem.



3
4
5
# File 'lib/dependency-timeline-audit/gem_version.rb', line 3

def gem
  @gem
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/dependency-timeline-audit/gem_version.rb', line 3

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object



11
12
13
14
15
# File 'lib/dependency-timeline-audit/gem_version.rb', line 11

def ==(other)
  return name == other.name if other.is_a?(GemVersion)

  nil
end

#colorObject



31
32
33
34
35
# File 'lib/dependency-timeline-audit/gem_version.rb', line 31

def color
  return :red if outdated?
  return :green if latest?
  :yellow
end

#latest?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/dependency-timeline-audit/gem_version.rb', line 27

def latest?
  gem.latest_version == self
end

#outdated?Boolean

If release date is unknown, leave it as not outdated

Returns:

  • (Boolean)


22
23
24
25
# File 'lib/dependency-timeline-audit/gem_version.rb', line 22

def outdated?
  return false if released_at.nil?
  released_at <= config.outdated_threshold
end

#released_atObject



37
38
39
# File 'lib/dependency-timeline-audit/gem_version.rb', line 37

def released_at
  api.released_at
end

#to_sObject



17
18
19
# File 'lib/dependency-timeline-audit/gem_version.rb', line 17

def to_s
  name.to_s
end