Class: ForemanGitTemplates::RepositoryFetcher

Inherits:
Object
  • Object
show all
Defined in:
app/services/foreman_git_templates/repository_fetcher.rb

Defined Under Namespace

Classes: RepositoryFetcherError

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository_url) ⇒ RepositoryFetcher

Returns a new instance of RepositoryFetcher.



7
8
9
# File 'app/services/foreman_git_templates/repository_fetcher.rb', line 7

def initialize(repository_url)
  @repository_url = repository_url
end

Class Method Details

.call(repository_url) ⇒ Object



19
20
21
# File 'app/services/foreman_git_templates/repository_fetcher.rb', line 19

def self.call(repository_url)
  new(repository_url).call
end

Instance Method Details

#callObject



11
12
13
14
15
16
17
# File 'app/services/foreman_git_templates/repository_fetcher.rb', line 11

def call
  Down.download(repository_url)
rescue Down::ResponseError => e
  raise RepositoryFetcherError, "Cannot fetch repository from #{repository_url}. Response code: #{e.response.code}"
rescue Down::Error => e
  raise RepositoryFetcherError, "Cannot fetch repository from #{repository_url}, #{e.message}"
end