Class: Potatochop::GithubInterface
- Inherits:
-
Object
- Object
- Potatochop::GithubInterface
- Defined in:
- lib/potatochop/github_interface.rb
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #exists?(file_name) ⇒ Boolean
-
#initialize(repo, gh_options = {}) ⇒ GithubInterface
constructor
A new instance of GithubInterface.
- #read(file_name) ⇒ Object
Constructor Details
#initialize(repo, gh_options = {}) ⇒ GithubInterface
Returns a new instance of GithubInterface.
5 6 7 8 |
# File 'lib/potatochop/github_interface.rb', line 5 def initialize(repo, = {}) @source = repo @gh_client = Octokit::Client.new access_token: [:access_token] end |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
3 4 5 |
# File 'lib/potatochop/github_interface.rb', line 3 def source @source end |
Instance Method Details
#exists?(file_name) ⇒ Boolean
10 11 12 13 14 15 16 17 |
# File 'lib/potatochop/github_interface.rb', line 10 def exists?(file_name) begin @gh_client.contents(@source, path: file_name, accept: 'application/vnd.github.raw') true rescue Octokit::NotFound false end end |
#read(file_name) ⇒ Object
19 20 21 |
# File 'lib/potatochop/github_interface.rb', line 19 def read(file_name) @gh_client.contents(@source, path: file_name, accept: 'application/vnd.github.raw') end |