Class: DependencyTimelineAudit::GemVersion
- Inherits:
-
Object
- Object
- DependencyTimelineAudit::GemVersion
- Defined in:
- lib/dependency-timeline-audit/gem_version.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#gem ⇒ Object
readonly
Returns the value of attribute gem.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #color ⇒ Object
-
#initialize(gem:, name:) ⇒ GemVersion
constructor
A new instance of GemVersion.
- #latest? ⇒ Boolean
-
#outdated? ⇒ Boolean
If release date is unknown, leave it as not outdated.
- #released_at ⇒ Object
- #to_s ⇒ Object
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
#config ⇒ Object (readonly)
Returns the value of attribute config.
3 4 5 |
# File 'lib/dependency-timeline-audit/gem_version.rb', line 3 def config @config end |
#gem ⇒ Object (readonly)
Returns the value of attribute gem.
3 4 5 |
# File 'lib/dependency-timeline-audit/gem_version.rb', line 3 def gem @gem end |
#name ⇒ Object (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 |
#color ⇒ Object
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
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
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_at ⇒ Object
37 38 39 |
# File 'lib/dependency-timeline-audit/gem_version.rb', line 37 def released_at api.released_at end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/dependency-timeline-audit/gem_version.rb', line 17 def to_s name.to_s end |