Class: RightScraper::Repositories::Download

Inherits:
Base
  • Object
show all
Defined in:
lib/right_scraper/repositories/download.rb

Overview

A repository that is just an archive file hanging off a web server somewhere. This version uses a command line curl to download the archive, and command line tar to extract it.

Instance Attribute Summary collapse

Attributes inherited from Base

#display_name, #resources_path, #url

Instance Method Summary collapse

Methods inherited from Base

#==, #equal_repo?, from_hash, #repository_hash

Instance Attribute Details

#first_credentialObject

(String) Optional, username



36
37
38
# File 'lib/right_scraper/repositories/download.rb', line 36

def first_credential
  @first_credential
end

#second_credentialObject

(String) Optional, password



39
40
41
# File 'lib/right_scraper/repositories/download.rb', line 39

def second_credential
  @second_credential
end

#tagObject Also known as: revision

(String) Optional, SHA of contents



42
43
44
# File 'lib/right_scraper/repositories/download.rb', line 42

def tag
  @tag
end

Instance Method Details

#checkout_hashObject

Return a unique identifier for this revision in this repository.

Returns

String

opaque unique ID for this revision in this repository



66
67
68
# File 'lib/right_scraper/repositories/download.rb', line 66

def checkout_hash
  digest("#{PROTOCOL_VERSION}\000#{repo_type}\000#{url}\000#{tag}")
end

#repo_typeObject

(String) Type of the repository, here ‘download’.



31
32
33
# File 'lib/right_scraper/repositories/download.rb', line 31

def repo_type
  :download
end

#retriever(options) ⇒ Object

Instantiate retriever for this kind of repository

Options

:max_bytes

Maximum number of bytes to read

:max_seconds

Maximum number of seconds to spend reading

:basedir

Destination directory, use temp dir if not specified

:logger

Logger to use

Return

retriever(Retrivers::Download)

Retriever for this repository



80
81
82
# File 'lib/right_scraper/repositories/download.rb', line 80

def retriever(options)
  RightScraper::Retrievers::Download.new(self, options)
end

#to_sObject

Unique representation for this repo, should resolve to the same string for repos that should be cloned in same directory

Returns

res(String)

Unique representation for this repo



50
51
52
# File 'lib/right_scraper/repositories/download.rb', line 50

def to_s
  res = "download #{url}"
end

#to_urlObject

Convert this repository to a URL in the style of resource URLs.

Returns

URI

URL representing this repository



58
59
60
# File 'lib/right_scraper/repositories/download.rb', line 58

def to_url
  add_users_to(url, first_credential, second_credential)
end