Class: Launchpad::Index

Inherits:
Object
  • Object
show all
Defined in:
lib/launchpad/index.rb

Overview

Provides a diff between local and remote file data by maintaining a cache with pathnames and md5 hex digests.

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Index

Returns a new instance of Index

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :installation_path (String)

    root installation directory.

  • :local_index_path (String)

    where the local index is saved.

  • :remote_index_uri (String)

    uri for the remote index.



12
13
14
15
16
# File 'lib/launchpad/index.rb', line 12

def initialize(options = {})
  @target_dir = Pathname.new options[:target_dir]
  @local_index_path = options[:local_index_path]
  @remote_index_uri = options[:remote_index_uri]
end

Instance Method Details

#diffArray<String>

Returns an array of files that are not present or do not match the remote.

Returns:

  • (Array<String>)

    an array of files that are not present or do not match the remote.



20
21
22
# File 'lib/launchpad/index.rb', line 20

def diff
  (remote - local).map(&:first)
end

#localArray<Array<Pathname, String>>

Returns an array of pathnames and their md5 digests for the local install.

Returns:

  • (Array<Array<Pathname, String>>)

    an array of pathnames and their md5 digests for the local install.



26
27
28
# File 'lib/launchpad/index.rb', line 26

def local
  @local ||= parse_local
end

#remoteArray<Array<Pathname, String>>

Returns an array of remote pathnames and their md5 digests from the patcher.

Returns:

  • (Array<Array<Pathname, String>>)

    an array of remote pathnames and their md5 digests from the patcher.



32
33
34
# File 'lib/launchpad/index.rb', line 32

def remote
  @remote ||= parse_remote
end

#scanself

Updates #local with a full scan of the installation directory.

Returns:

  • (self)


38
39
40
41
42
43
# File 'lib/launchpad/index.rb', line 38

def scan
  @local = []
  recursive_scan
  @local = sort local
  save
end