Class: FlakyTestTracker::Source::GitHubSource

Inherits:
Object
  • Object
show all
Defined in:
lib/flaky_test_tracker/source/github_source.rb

Overview

GitHub source.

Constant Summary collapse

DEFAULT_HOST =
"github.com"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository:, commit:, branch:, host:) ⇒ GitHubSource

Returns a new instance of GitHubSource.



27
28
29
30
31
32
# File 'lib/flaky_test_tracker/source/github_source.rb', line 27

def initialize(repository:, commit:, branch:, host:)
  @host = host
  @repository = repository
  @commit = commit
  @branch = branch
end

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



25
26
27
# File 'lib/flaky_test_tracker/source/github_source.rb', line 25

def branch
  @branch
end

#commitObject (readonly)

Returns the value of attribute commit.



25
26
27
# File 'lib/flaky_test_tracker/source/github_source.rb', line 25

def commit
  @commit
end

#hostObject (readonly)

Returns the value of attribute host.



25
26
27
# File 'lib/flaky_test_tracker/source/github_source.rb', line 25

def host
  @host
end

#repositoryObject (readonly)

Returns the value of attribute repository.



25
26
27
# File 'lib/flaky_test_tracker/source/github_source.rb', line 25

def repository
  @repository
end

Class Method Details

.build(repository:, commit:, branch:, host: DEFAULT_HOST) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/flaky_test_tracker/source/github_source.rb', line 11

def self.build(
  repository:,
  commit:,
  branch:,
  host: DEFAULT_HOST
)
  new(
    host: host,
    repository: repository,
    commit: commit,
    branch: branch
  )
end

Instance Method Details

#file_source_location_uri(file_path:, line_number:) ⇒ URI

Returns URI for a file on the source.

Returns:

  • (URI)

    URI for a file on the source.



35
36
37
38
39
# File 'lib/flaky_test_tracker/source/github_source.rb', line 35

def file_source_location_uri(file_path:, line_number:)
  uri = URI("https://#{host}/#{repository}/blob/#{commit}/#{file_path}")
  uri.fragment = "L#{line_number}"
  uri
end

#source_uriURI

Returns on the source.

Returns:

  • (URI)

    on the source.



42
43
44
# File 'lib/flaky_test_tracker/source/github_source.rb', line 42

def source_uri
  URI("https://#{host}/#{repository}/tree/#{commit}")
end