Class: RightScraper::Repositories::Download

Inherits:
Base 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, register_url_schemas, registered_url_schemas, registration_module, #repository_hash

Methods inherited from RightScraper::RegisteredBase

query_registered_type, register_class, register_self, registered_types, registration_module

Instance Attribute Details

#first_credentialObject

(String) Optional, username



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

def first_credential
  @first_credential
end

#second_credentialObject

(String) Optional, password



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

def second_credential
  @second_credential
end

#tagObject Also known as: revision

(String) Optional, SHA of contents



46
47
48
# File 'lib/right_scraper/repositories/download.rb', line 46

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



70
71
72
# File 'lib/right_scraper/repositories/download.rb', line 70

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

#repo_typeObject

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



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

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



84
85
86
# File 'lib/right_scraper/repositories/download.rb', line 84

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



54
55
56
# File 'lib/right_scraper/repositories/download.rb', line 54

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



62
63
64
# File 'lib/right_scraper/repositories/download.rb', line 62

def to_url
  add_users_to(url, first_credential, second_credential)
end