Module: Amp::Repositories::Stores::FilenameCache

Defined in:
lib/amp/repository/store.rb

Overview

FilenameCache

This module handles dealing with Filename Caches - namely, parsing them.

Defined Under Namespace

Classes: FilenameCacheOpener

Class Method Summary collapse

Class Method Details

.parse(opener) ⇒ Object

Parses the filename cache, given an object capable of opening a file relative to the right directory.

Parameters:

  • opener (Amp::Opener)

    An opener initialized to the repo’s directory.



189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/amp/repository/store.rb', line 189

def self.parse(opener)
  return unless File.exist? opener.join("fncache")
  opener.open 'fncache', 'r' do |fp|
    # error handling?
    i = 0
    fp.each_line do |line| #this is how we parse it
      if line.size < 2 || line[-1,1] != "\n"
        raise StoreError.new("invalid fncache entry, line #{i}")
      end
      yield line.chomp
    end
  end
end