Class: RightScraper::Repositories::Download
- 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
-
#first_credential ⇒ Object
(String) Optional, username.
-
#second_credential ⇒ Object
(String) Optional, password.
-
#tag ⇒ Object
(also: #revision)
(String) Optional, SHA of contents.
Attributes inherited from Base
#display_name, #resources_path, #url
Instance Method Summary collapse
-
#checkout_hash ⇒ Object
Return a unique identifier for this revision in this repository.
-
#repo_type ⇒ Object
(String) Type of the repository, here ‘download’.
-
#retriever(options) ⇒ Object
Instantiate retriever for this kind of repository.
-
#to_s ⇒ Object
Unique representation for this repo, should resolve to the same string for repos that should be cloned in same directory.
-
#to_url ⇒ Object
Convert this repository to a URL in the style of resource URLs.
Methods inherited from Base
#==, #equal_repo?, from_hash, #repository_hash
Instance Attribute Details
#first_credential ⇒ Object
(String) Optional, username
36 37 38 |
# File 'lib/right_scraper/repositories/download.rb', line 36 def first_credential @first_credential end |
#second_credential ⇒ Object
(String) Optional, password
39 40 41 |
# File 'lib/right_scraper/repositories/download.rb', line 39 def second_credential @second_credential end |
#tag ⇒ Object 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_hash ⇒ Object
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_type ⇒ Object
(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() RightScraper::Retrievers::Download.new(self, ) end |
#to_s ⇒ Object
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_url ⇒ Object
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 |