Class: Policial::Commit
- Inherits:
-
Object
- Object
- Policial::Commit
- Defined in:
- lib/policial/commit.rb
Overview
Public: A Commit in a GitHub repo.
Instance Attribute Summary collapse
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
-
#sha ⇒ Object
readonly
Returns the value of attribute sha.
Instance Method Summary collapse
- #file_content(filename) ⇒ Object
-
#initialize(repo, sha) ⇒ Commit
constructor
A new instance of Commit.
Constructor Details
#initialize(repo, sha) ⇒ Commit
Returns a new instance of Commit.
6 7 8 9 |
# File 'lib/policial/commit.rb', line 6 def initialize(repo, sha) @repo = repo @sha = sha end |
Instance Attribute Details
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
4 5 6 |
# File 'lib/policial/commit.rb', line 4 def repo @repo end |
#sha ⇒ Object (readonly)
Returns the value of attribute sha.
4 5 6 |
# File 'lib/policial/commit.rb', line 4 def sha @sha end |
Instance Method Details
#file_content(filename) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/policial/commit.rb', line 11 def file_content(filename) contents = Policial.octokit.contents(@repo, path: filename, ref: @sha) if contents && contents.content Base64.decode64(contents.content).force_encoding('UTF-8') else '' end rescue Octokit::NotFound '' end |