Class: Kennel::GithubReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/kennel/github_reporter.rb

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ GithubReporter

Returns a new instance of GithubReporter.



4
5
6
7
8
9
# File 'lib/kennel/github_reporter.rb', line 4

def initialize(token)
  @token = token
  @git_sha = Utils.capture_sh("git rev-parse HEAD").strip
  origin = ENV["PROJECT_REPOSITORY"] || Utils.capture_sh("git remote -v").split("\n").first
  @repo_part = origin[%r{github\.com[:/](.+?)(\.git|$)}, 1] || raise("no origin found")
end

Instance Method Details

#reportObject



11
12
13
14
15
# File 'lib/kennel/github_reporter.rb', line 11

def report
  output = Utils.strip_shell_control(Utils.capture_stdout { yield }.strip)
ensure
  comment "```\n#{output || "Error"}\n```"
end