Class: RightScraper::Repositories::Git
- Inherits:
-
Base
- Object
- RightScraper::RegisteredBase
- Base
- RightScraper::Repositories::Git
- Defined in:
- lib/right_scraper/repositories/git.rb
Overview
A Git repository.
Instance Attribute Summary collapse
-
#first_credential ⇒ Object
(also: #ssh_key)
(String) Optional, git private SSH key content.
-
#tag ⇒ Object
(also: #revision)
(String) Optional, tag or branch of repository that should be downloaded.
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.
-
#initialize(*args) ⇒ Git
constructor
Initialize repository.
-
#repo_type ⇒ Object
(String) Type of the repository, here ‘git’.
-
#retriever(options) ⇒ Object
Instantiate retriever for this kind of repository.
-
#to_url ⇒ Object
Convert this repository to a URL in the style of resource URLs.
Methods inherited from Base
#==, #equal_repo?, from_hash, register_url_schemas, registered_url_schemas, registration_module, #repository_hash, #to_s
Methods inherited from RightScraper::RegisteredBase
query_registered_type, register_class, register_self, registered_types, registration_module
Constructor Details
#initialize(*args) ⇒ Git
Initialize repository
41 42 43 44 |
# File 'lib/right_scraper/repositories/git.rb', line 41 def initialize(*args) super @tag = "master" if @tag.nil? end |
Instance Attribute Details
#first_credential ⇒ Object Also known as: ssh_key
(String) Optional, git private SSH key content
37 38 39 |
# File 'lib/right_scraper/repositories/git.rb', line 37 def first_credential @first_credential end |
#tag ⇒ Object Also known as: revision
(String) Optional, tag or branch of repository that should be downloaded
33 34 35 |
# File 'lib/right_scraper/repositories/git.rb', line 33 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
55 56 57 |
# File 'lib/right_scraper/repositories/git.rb', line 55 def checkout_hash digest("#{PROTOCOL_VERSION}\000#{repo_type}\000#{url}\000#{tag}") end |
#repo_type ⇒ Object
(String) Type of the repository, here ‘git’.
47 48 49 |
# File 'lib/right_scraper/repositories/git.rb', line 47 def repo_type :git 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::Git)
-
Retriever for this repository
82 83 84 |
# File 'lib/right_scraper/repositories/git.rb', line 82 def retriever() RightScraper::Retrievers::Git.new(self, ) end |
#to_url ⇒ Object
Convert this repository to a URL in the style of resource URLs.
Returns
- URI
-
URL representing this repository
63 64 65 66 67 68 69 70 |
# File 'lib/right_scraper/repositories/git.rb', line 63 def to_url if first_credential uri = add_users_to(url, first_credential) else uri = URI.parse(url) end uri end |