Class: Kennel::GithubReporter
- Inherits:
-
Object
- Object
- Kennel::GithubReporter
- Defined in:
- lib/kennel/github_reporter.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(token) ⇒ GithubReporter
constructor
A new instance of GithubReporter.
- #report(&block) ⇒ Object
Constructor Details
#initialize(token) ⇒ GithubReporter
Returns a new instance of GithubReporter.
11 12 13 14 15 16 |
# File 'lib/kennel/github_reporter.rb', line 11 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 |
Class Method Details
.report(token, &block) ⇒ Object
5 6 7 8 |
# File 'lib/kennel/github_reporter.rb', line 5 def report(token, &block) return yield unless token new(token).report(&block) end |
Instance Method Details
#report(&block) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/kennel/github_reporter.rb', line 18 def report(&block) output = Utils.strip_shell_control(Utils.tee_output(&block).strip) rescue StandardError output = "Error:\n#{$ERROR_INFO.}" raise ensure comment "```\n#{output || "Error"}\n```" end |