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.



4
5
6
# File 'lib/compact_index/versions_file.rb', line 4

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

Instance Method Details

#contents(gems = nil) ⇒ Object



8
9
10
11
12
# File 'lib/compact_index/versions_file.rb', line 8

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

#update_with(gems) ⇒ Object



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

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

#updated_atObject



14
15
16
17
18
19
20
# File 'lib/compact_index/versions_file.rb', line 14

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