class Policial::Commit

Public: A Commit in a GitHub repo.

Attributes

repo[R]
sha[R]

Public Class Methods

new(repo, sha, github_client) click to toggle source
# File lib/policial/commit.rb, line 8
def initialize(repo, sha, github_client)
  @repo = repo
  @sha  = sha
  @github_client = github_client
end

Public Instance Methods

file_content(filename) click to toggle source
# File lib/policial/commit.rb, line 14
def file_content(filename)
  contents = @github_client.contents(@repo, path: filename, ref: @sha)

  if contents && contents.content
    Base64.decode64(contents.content).force_encoding('UTF-8')
  else
    ''
  end
rescue Octokit::NotFound
  ''
end