Class: Moku::ReferenceRepo

Inherits:
Object
  • Object
show all
Defined in:
lib/moku/reference_repo.rb

Overview

Responsible for downloading references and converting them to files. Provides an anchor point for features such as reference caching.

Instance Method Summary collapse

Constructor Details

#initialize(dir, runner = Moku.git_runner, max_cache: Moku.ref_cache_max) ⇒ ReferenceRepo

Returns a new instance of ReferenceRepo.

Parameters:

  • dir (Pathname)

    A directory in which to store intermediate files.


12
13
14
15
16
17
# File 'lib/moku/reference_repo.rb', line 12

def initialize(dir, runner = Moku.git_runner, max_cache: Moku.ref_cache_max)
  @dir = Pathname.new(dir).tap(&:mkpath)
  @runner = runner
  @max_cache = (max_cache - 1) || 1
  # -1 because we prune before building, so we won't reach it until max + 1.
end

Instance Method Details

#resolve(ref) ⇒ Pathname

Download the given archive reference, unpack it, and return the contents without metadata.

Parameters:

Returns:

  • (Pathname)

    The directory path


23
24
25
26
# File 'lib/moku/reference_repo.rb', line 23

def resolve(ref)
  cleanup!
  checkout(ref, dir_for(ref)).dir
end