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

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>



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

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

#localArray<Array<Pathname, String>>



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

def local
  @local ||= parse_local
end

#remoteArray<Array<Pathname, String>>



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.



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

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