Class: CompactIndex::VersionsFile

Inherits:
Object
  • Object
show all
Defined in:
lib/compact_index/versions_file.rb

Instance Method Summary collapse

Constructor Details

#initialize(file = nil) ⇒ VersionsFile

Returns a new instance of VersionsFile.



6
7
8
# File 'lib/compact_index/versions_file.rb', line 6

def initialize(file = nil)
  @path = file || "/versions.list"
end

Instance Method Details

#contents(gems = nil, args = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/compact_index/versions_file.rb', line 10

def contents(gems = nil, args = {})
  if args[:calculate_checksums]
    gems = calculate_checksums(gems)
  end

  out = File.read(@path)
  out << parse_gems(gems) if gems
  out
end

#update_with(gems) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/compact_index/versions_file.rb', line 28

def update_with(gems)
  if File.exists?(@path) && !File.zero?(@path)
    update(gems)
  else
    create(gems)
  end
end

#updated_atObject



20
21
22
23
24
25
26
# File 'lib/compact_index/versions_file.rb', line 20

def updated_at
  if File.exists? @path
    DateTime.parse(File.mtime(@path).to_s)
  else
    Time.at(0)
  end
end