Class: Geet::Github::RemoteRepository

Inherits:
Object
  • Object
show all
Defined in:
lib/geet/github/remote_repository.rb

Overview

A remote repository. Currently only provides the parent path.

It’s a difficult choice whether to independently use the repository path, or relying on the one stored in the ApiInterface. The former design is conceptually cleaner, but it practically (as of the current design) introduces duplication. All in all, for simplicity, the latter design is chosen, but is subject to redesign.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_interface, parent_path: nil) ⇒ RemoteRepository

Returns a new instance of RemoteRepository.



17
18
19
20
# File 'lib/geet/github/remote_repository.rb', line 17

def initialize(api_interface, parent_path: nil)
  @api_interface = api_interface
  @parent_path = parent_path
end

Instance Attribute Details

#parent_pathObject (readonly)

Nil if the repository is not a fork.



15
16
17
# File 'lib/geet/github/remote_repository.rb', line 15

def parent_path
  @parent_path
end

Class Method Details

.find(api_interface) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/geet/github/remote_repository.rb', line 26

def self.find(api_interface)
  api_path = "/repos/#{api_interface.repository_path}"

  response = api_interface.send_request(api_path)

  parent_path = response['parent']&.fetch("full_name")

  self.new(api_interface, parent_path: parent_path)
end