Class: Chrysalis::VCS::File::Repository

Inherits:
Repository show all
Defined in:
lib/chrysalis/vcs/file/repository.rb

Overview

Implements support for copying dependencies from a file system.

Repositories of this type are identified by file:// URLs.

Example:

- file:///Users/jaredhanson/Projects/libfoo

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Repository

inherited, retrieve

Constructor Details

#initialize(url, params = {}) ⇒ Repository

Returns a new instance of Repository.



26
27
28
29
# File 'lib/chrysalis/vcs/file/repository.rb', line 26

def initialize(url, params = {})
  @url = url
  @params = params
end

Class Method Details

.retrieves?(url, params = {}) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
23
# File 'lib/chrysalis/vcs/file/repository.rb', line 20

def self.retrieves?(url, params = {})
  uri = URI::parse(url)
  return uri.scheme == 'file'
end

Instance Method Details

#retrieve(to = '.') ⇒ Object

Raises:

  • (IOError)


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/chrysalis/vcs/file/repository.rb', line 31

def retrieve(to = '.')
  target = Pathname.new(to).join(copy_to)
  raise IOError, "Refusing to overwrite existing path. (path: #{target})" if target.exist?

  unless @params[:noop]
    puts ""
    puts "Copying #{@url} ..."
  
    source = URI::parse(@url)
    FileUtils.cp_r(source.path, target)
  end
  
  extract_path = Archive.extract(target.to_s, to, @params)
  WorkingCopy.new(:url => @url,
                  :path => extract_path)
end