Module: Octokit::Client::Gists
- Included in:
- Octokit::Client
- Defined in:
- lib/octokit/client/gists.rb
Overview
Methods for the Gists API
Instance Method Summary collapse
-
#create_gist(options = {}) ⇒ Sawyer::Resource
Create a gist.
-
#create_gist_comment(gist_id, comment, options = {}) ⇒ Sawyer::Resource
Create gist comment.
-
#delete_gist(gist, options = {}) ⇒ Boolean
Delete a gist.
-
#delete_gist_comment(gist_id, gist_comment_id, options = {}) ⇒ Boolean
Delete gist comment.
-
#edit_gist(gist, options = {}) ⇒ Object
Edit a gist.
-
#fork_gist(gist, options = {}) ⇒ Sawyer::Resource
Fork a gist.
-
#gist(gist, options = {}) ⇒ Sawyer::Resource
Get a single gist.
-
#gist_comment(gist_id, gist_comment_id, options = {}) ⇒ Sawyer::Resource
Get gist comment.
-
#gist_comments(gist_id, options = {}) ⇒ Array<Sawyer::Resource>
List gist comments.
-
#gist_commits(gist, options = {}) ⇒ Array
List gist commits.
-
#gist_forks(gist, options = {}) ⇒ Array
List gist forks.
-
#gist_starred?(gist, options = {}) ⇒ Boolean
Check if a gist is starred.
-
#gists(user = nil, options = {}) ⇒ Array<Sawyer::Resource>
(also: #list_gists)
List gists for a user or all public gists.
-
#public_gists(options = {}) ⇒ Array<Sawyer::Resource>
List public gists.
-
#star_gist(gist, options = {}) ⇒ Boolean
Star a gist.
-
#starred_gists(options = {}) ⇒ Array<Sawyer::Resource>
List the authenticated user’s starred gists.
-
#unstar_gist(gist, options = {}) ⇒ Boolean
Unstar a gist.
-
#update_gist_comment(gist_id, gist_comment_id, comment, options = {}) ⇒ Sawyer::Resource
Update gist comment.
Instance Method Details
#create_gist(options = {}) ⇒ Sawyer::Resource
Create a gist
71 72 73 |
# File 'lib/octokit/client/gists.rb', line 71 def create_gist( = {}) post 'gists', end |
#create_gist_comment(gist_id, comment, options = {}) ⇒ Sawyer::Resource
Create gist comment
Requires authenticated client.
198 199 200 201 |
# File 'lib/octokit/client/gists.rb', line 198 def create_gist_comment(gist_id, comment, = {}) = .merge({:body => comment}) post "gists/#{gist_id}/comments", end |
#delete_gist(gist, options = {}) ⇒ Boolean
Delete a gist
161 162 163 |
# File 'lib/octokit/client/gists.rb', line 161 def delete_gist(gist, = {}) boolean_from_response :delete, "gists/#{Gist.new(gist)}", end |
#delete_gist_comment(gist_id, gist_comment_id, options = {}) ⇒ Boolean
Delete gist comment
Requires authenticated client.
229 230 231 |
# File 'lib/octokit/client/gists.rb', line 229 def delete_gist_comment(gist_id, gist_comment_id, = {}) boolean_from_response(:delete, "gists/#{gist_id}/comments/#{gist_comment_id}", ) end |
#edit_gist(gist, options = {}) ⇒ Object
Edit a gist
93 94 95 |
# File 'lib/octokit/client/gists.rb', line 93 def edit_gist(gist, = {}) patch "gists/#{Gist.new(gist)}", end |
#fork_gist(gist, options = {}) ⇒ Sawyer::Resource
Fork a gist
141 142 143 |
# File 'lib/octokit/client/gists.rb', line 141 def fork_gist(gist, = {}) post "gists/#{Gist.new(gist)}/forks", end |
#gist(gist, options = {}) ⇒ Sawyer::Resource
Get a single gist
52 53 54 55 56 57 58 59 |
# File 'lib/octokit/client/gists.rb', line 52 def gist(gist, = {}) = .dup if sha = .delete(:sha) get "gists/#{Gist.new(gist)}/#{sha}", else get "gists/#{Gist.new(gist)}", end end |
#gist_comment(gist_id, gist_comment_id, options = {}) ⇒ Sawyer::Resource
Get gist comment
184 185 186 |
# File 'lib/octokit/client/gists.rb', line 184 def gist_comment(gist_id, gist_comment_id, = {}) get "gists/#{gist_id}/comments/#{gist_comment_id}", end |
#gist_comments(gist_id, options = {}) ⇒ Array<Sawyer::Resource>
List gist comments
172 173 174 |
# File 'lib/octokit/client/gists.rb', line 172 def gist_comments(gist_id, = {}) paginate "gists/#{gist_id}/comments", end |
#gist_commits(gist, options = {}) ⇒ Array
List gist commits
104 105 106 |
# File 'lib/octokit/client/gists.rb', line 104 def gist_commits(gist, = {}) paginate "gists/#{Gist.new(gist)}/commits", end |
#gist_forks(gist, options = {}) ⇒ Array
List gist forks
152 153 154 |
# File 'lib/octokit/client/gists.rb', line 152 def gist_forks(gist, = {}) paginate "gists/#{Gist.new(gist)}/forks", end |
#gist_starred?(gist, options = {}) ⇒ Boolean
Check if a gist is starred
132 133 134 |
# File 'lib/octokit/client/gists.rb', line 132 def gist_starred?(gist, = {}) boolean_from_response :get, "gists/#{Gist.new(gist)}/star", end |
#gists(user = nil, options = {}) ⇒ Array<Sawyer::Resource> Also known as: list_gists
List gists for a user or all public gists
18 19 20 21 22 23 24 |
# File 'lib/octokit/client/gists.rb', line 18 def gists(user=nil, = {}) if user.nil? paginate 'gists', else paginate "#{User.path user}/gists", end end |
#public_gists(options = {}) ⇒ Array<Sawyer::Resource>
List public gists
33 34 35 |
# File 'lib/octokit/client/gists.rb', line 33 def public_gists( = {}) paginate 'gists/public', end |
#star_gist(gist, options = {}) ⇒ Boolean
Star a gist
114 115 116 |
# File 'lib/octokit/client/gists.rb', line 114 def star_gist(gist, = {}) boolean_from_response :put, "gists/#{Gist.new(gist)}/star", end |
#starred_gists(options = {}) ⇒ Array<Sawyer::Resource>
List the authenticated user’s starred gists
41 42 43 |
# File 'lib/octokit/client/gists.rb', line 41 def starred_gists( = {}) paginate 'gists/starred', end |
#unstar_gist(gist, options = {}) ⇒ Boolean
Unstar a gist
123 124 125 |
# File 'lib/octokit/client/gists.rb', line 123 def unstar_gist(gist, = {}) boolean_from_response :delete, "gists/#{Gist.new(gist)}/star", end |
#update_gist_comment(gist_id, gist_comment_id, comment, options = {}) ⇒ Sawyer::Resource
Update gist comment
Requires authenticated client
214 215 216 217 |
# File 'lib/octokit/client/gists.rb', line 214 def update_gist_comment(gist_id, gist_comment_id, comment, = {}) = .merge({:body => comment}) patch "gists/#{gist_id}/comments/#{gist_comment_id}", end |