Class: DependencyTimelineAudit::GemCache

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gem_info) ⇒ GemCache

Returns a new instance of GemCache.



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

def initialize(gem_info)
  @versions = gem_info || []
end

Instance Attribute Details

#versionsObject (readonly)

Returns the value of attribute versions.



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

def versions
  @versions
end

Instance Method Details

#latest_versionObject



9
10
11
12
# File 'lib/dependency-timeline-audit/gem_cache.rb', line 9

def latest_version
  latest = versions.first # The first entry is the latest version
  version_number = latest['number']
end

#to_hObject



20
21
22
# File 'lib/dependency-timeline-audit/gem_cache.rb', line 20

def to_h
  versions
end

#version(version_number) ⇒ Object

Find the version that matches the requested version string



15
16
17
18
# File 'lib/dependency-timeline-audit/gem_cache.rb', line 15

def version(version_number)
  version_info = versions.find { |v| v['number'] == version_number }
  GemVersionCache.new(version_info)
end