Class: RightScraper::Repositories::Git

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

Overview

A Git repository.

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, #to_s

Constructor Details

#initialize(*args) ⇒ Git

Initialize repository



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

def initialize(*args)
  super
  @tag = "master" if @tag.nil?
end

Instance Attribute Details

#first_credentialObject Also known as: ssh_key

(String) Optional, git private SSH key content



34
35
36
# File 'lib/right_scraper/repositories/git.rb', line 34

def first_credential
  @first_credential
end

#tagObject Also known as: revision

(String) Optional, tag or branch of repository that should be downloaded



30
31
32
# File 'lib/right_scraper/repositories/git.rb', line 30

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



52
53
54
# File 'lib/right_scraper/repositories/git.rb', line 52

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

#repo_typeObject

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



44
45
46
# File 'lib/right_scraper/repositories/git.rb', line 44

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



79
80
81
# File 'lib/right_scraper/repositories/git.rb', line 79

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

#to_urlObject

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

Returns

URI

URL representing this repository



60
61
62
63
64
65
66
67
# File 'lib/right_scraper/repositories/git.rb', line 60

def to_url
  if first_credential
    uri = add_users_to(url, first_credential)
  else
    uri = URI.parse(url)
  end
  uri
end