Class: GitMulticast::RepositoryFetcher
- Inherits:
-
Object
- Object
- GitMulticast::RepositoryFetcher
show all
- Defined in:
- lib/git_multicast/repository_fetcher.rb,
lib/git_multicast/repository_fetcher/github.rb,
lib/git_multicast/repository_fetcher/bitbucket.rb
Defined Under Namespace
Classes: Bitbucket, Github
Constant Summary
collapse
- FETCHER_ADAPTER_ZIP =
[
[Bitbucket, Adapters::Bitbucket],
[Github, Adapters::Github]
]
Class Method Summary
collapse
Class Method Details
.adapter_by_url(url) ⇒ Object
44
45
46
|
# File 'lib/git_multicast/repository_fetcher.rb', line 44
def self.adapter_by_url(url)
zip_by_url(url).last
end
|
.fetcher_by_url(url) ⇒ Object
40
41
42
|
# File 'lib/git_multicast/repository_fetcher.rb', line 40
def self.fetcher_by_url(url)
zip_by_url(url).first
end
|
.get_all_repos_from_user(username) ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/git_multicast/repository_fetcher.rb', line 13
def self.get_all_repos_from_user(username)
FETCHER_ADAPTER_ZIP.map do |fetcher, adapter|
raw_repos = fetcher.get_all_repos_from_user(username)
raw_repos.map { |raw_repo| adapter.new(raw_repo).adapt }
end.flatten
end
|
.get_repo(url) ⇒ Object
21
22
23
24
|
# File 'lib/git_multicast/repository_fetcher.rb', line 21
def self.get_repo(url)
raw_repo = fetcher_by_url(url).get_repo(url)
adapter_by_url(url).new(raw_repo).adapt
end
|
.get_repo_parent(url) ⇒ Object
26
27
28
|
# File 'lib/git_multicast/repository_fetcher.rb', line 26
def self.get_repo_parent(url)
get_repo(url).parent
end
|
.make_struct(hash) ⇒ Object
48
49
50
|
# File 'lib/git_multicast/repository_fetcher.rb', line 48
def self.make_struct(hash)
RecursiveOpenStruct.new(hash, recurse_over_arrays: true)
end
|
.zip_by_url(url) ⇒ Object
30
31
32
33
34
35
36
37
38
|
# File 'lib/git_multicast/repository_fetcher.rb', line 30
def self.zip_by_url(url)
fetchers_names = FETCHERS.map do |fetcher|
match = fetcher.to_s.match(/Fetcher::(.*)$/)
match[1].downcase if match
end
triples = ([url] * FETCHERS.size).zip(fetchers_names, FETCHER_ADAPTER_ZIP)
triples.find { |u, name, _| u.match name }.last
end
|