Sha256: 60ec4fd26256b5ff00c1b07e25d8022d4d8060e54c3031805479f6bb95336ed6

Contents?: true

Size: 1.19 KB

Versions: 23

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

module Geet
  module Github
    # 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.
    #
    class RemoteRepository
      # Nil if the repository is not a fork.
      #
      attr_reader :parent_path

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

      # Get the repository parent path.
      #
      # https://docs.github.com/en/rest/reference/repos#get-a-repository
      #
      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
    end # module RemoteRepository
  end # module GitHub
end # module Geet

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
geet-0.22.0 lib/geet/github/remote_repository.rb
geet-0.21.0 lib/geet/github/remote_repository.rb
geet-0.19.0 lib/geet/github/remote_repository.rb
geet-0.18.0 lib/geet/github/remote_repository.rb
geet-0.17.0 lib/geet/github/remote_repository.rb
geet-0.16.0 lib/geet/github/remote_repository.rb
geet-0.15.0 lib/geet/github/remote_repository.rb
geet-0.14.0 lib/geet/github/remote_repository.rb
geet-0.13.0 lib/geet/github/remote_repository.rb
geet-0.12.0 lib/geet/github/remote_repository.rb
geet-0.11.0 lib/geet/github/remote_repository.rb
geet-0.10.0 lib/geet/github/remote_repository.rb
geet-0.9.0 lib/geet/github/remote_repository.rb
geet-0.8.0 lib/geet/github/remote_repository.rb
geet-0.7.0 lib/geet/github/remote_repository.rb
geet-0.6.0 lib/geet/github/remote_repository.rb
geet-0.5.0 lib/geet/github/remote_repository.rb
geet-0.4.4 lib/geet/github/remote_repository.rb
geet-0.4.3 lib/geet/github/remote_repository.rb
geet-0.4.2 lib/geet/github/remote_repository.rb