Class: Ace::Git::Providers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/git/providers/base.rb

Overview

Abstract provider contract implemented by provider packages.

The core defines the interface and the normalized evidence types; implementations own all provider CLI invocation, output parsing, and authentication verification. The core itself never executes a provider CLI and never parses provider output.

Subclasses receive the resolved server identity and may accept two optional constructor keywords (see for):

  • timeout: operation timeout in seconds
  • runner: injectable command runner for tests; a callable receiving keyword arguments (args:, timeout:, env:) and returning a Hash with :stdout, :stderr, :exit_code

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server:, timeout: nil, runner: nil) ⇒ Base

Returns a new instance of Base.

Parameters:

  • server (ResolvedServer) —

    resolved server identity

  • timeout (Integer, nil) (defaults to: nil) —

    operation timeout (default: config)

  • runner (Proc, nil) (defaults to: nil) —

    injectable command runner for tests



25
26
27
28
29
# File 'lib/ace/git/providers/base.rb', line 25

def initialize(server:, timeout: nil, runner: nil)
  @server = server
  @timeout = timeout || Ace::Git.network_timeout
  @runner = runner
end

Instance Attribute Details

#server ⇒ Object (readonly)

Returns the value of attribute server.



20
21
22
# File 'lib/ace/git/providers/base.rb', line 20

def server
  @server
end

#timeout ⇒ Object (readonly)

Returns the value of attribute timeout.



20
21
22
# File 'lib/ace/git/providers/base.rb', line 20

def timeout
  @timeout
end

Instance Method Details

#authenticated? ⇒ Boolean

Returns true when the provider CLI is authenticated.

Returns:

  • (Boolean) —

    true when the provider CLI is authenticated

Raises:

  • (NotImplementedError)


42
43
44
# File 'lib/ace/git/providers/base.rb', line 42

def authenticated?
  raise NotImplementedError, "Providers must implement #{self.class}#authenticated?"
end

#available? ⇒ Boolean

Returns true when the provider CLI binary is installed.

Returns:

  • (Boolean) —

    true when the provider CLI binary is installed

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/ace/git/providers/base.rb', line 32

def available?
  raise NotImplementedError, "Providers must implement #{self.class}#available?"
end

#check_authenticated! ⇒ Object

Raises:



47
48
49
# File 'lib/ace/git/providers/base.rb', line 47

def check_authenticated!
  raise NotImplementedError, "Providers must implement #{self.class}#check_authenticated!"
end

#check_available! ⇒ Object

Raises:



37
38
39
# File 'lib/ace/git/providers/base.rb', line 37

def check_available!
  raise NotImplementedError, "Providers must implement #{self.class}#check_available!"
end

#checks(ref:) ⇒ Array<ProviderCheck>

Fetch check/CI status evidence for a reference.

Parameters:

  • ref (String) —

    commit sha or branch name

Returns:

Raises:

  • (NotImplementedError)


96
97
98
# File 'lib/ace/git/providers/base.rb', line 96

def checks(ref:)
  raise NotImplementedError, "Providers must implement #{self.class}#checks"
end

#issue(number:) ⇒ ProviderIssue

Fetch one issue.

Parameters:

  • number (Integer, String) —

    issue number

Returns:

Raises:

  • (NotImplementedError)


88
89
90
# File 'lib/ace/git/providers/base.rb', line 88

def issue(number:)
  raise NotImplementedError, "Providers must implement #{self.class}#issue"
end

#pull_request(number:) ⇒ ProviderPullRequest

Fetch one pull request.

Parameters:

  • number (Integer, String) —

    pull request number

Returns:

Raises:

  • (NotImplementedError)


55
56
57
# File 'lib/ace/git/providers/base.rb', line 55

def pull_request(number:)
  raise NotImplementedError, "Providers must implement #{self.class}#pull_request"
end

#pull_request_diff(number:) ⇒ String

Fetch the full diff of one pull request.

Parameters:

  • number (Integer, String) —

    pull request number

Returns:

  • (String) —

    unified diff text

Raises:

  • (NotImplementedError)


72
73
74
# File 'lib/ace/git/providers/base.rb', line 72

def pull_request_diff(number:)
  raise NotImplementedError, "Providers must implement #{self.class}#pull_request_diff"
end

#pull_request_for_branch(branch:) ⇒ ProviderPullRequest?

Find the pull request associated with a branch.

Parameters:

  • branch (String) —

    branch name

Returns:

  • (ProviderPullRequest, nil) —

    evidence, or nil when no pull request is associated with the branch

Raises:

  • (NotImplementedError)


64
65
66
# File 'lib/ace/git/providers/base.rb', line 64

def pull_request_for_branch(branch:)
  raise NotImplementedError, "Providers must implement #{self.class}#pull_request_for_branch"
end

#recent_pull_requests(limit:) ⇒ Array<ProviderPullRequest>

List recent pull requests across states (newest first).

Parameters:

  • limit (Integer) —

    maximum number of pull requests

Returns:

Raises:

  • (NotImplementedError)


80
81
82
# File 'lib/ace/git/providers/base.rb', line 80

def recent_pull_requests(limit:)
  raise NotImplementedError, "Providers must implement #{self.class}#recent_pull_requests"
end

#repository ⇒ ProviderRepository

Fetch repository metadata for the resolved server.

Returns:

Raises:

  • (NotImplementedError)


103
104
105
# File 'lib/ace/git/providers/base.rb', line 103

def repository
  raise NotImplementedError, "Providers must implement #{self.class}#repository"
end