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_starred?(gist, options = {}) ⇒ Boolean
Check if a gist is starred.
-
#gists(username = 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
63 64 65 |
# File 'lib/octokit/client/gists.rb', line 63 def create_gist( = {}) post 'gists', end |
#create_gist_comment(gist_id, comment, options = {}) ⇒ Sawyer::Resource
Create gist comment
Requires authenticated client.
169 170 171 172 |
# File 'lib/octokit/client/gists.rb', line 169 def create_gist_comment(gist_id, comment, = {}) .merge!({:body => comment}) post "gists/#{gist_id}/comments", end |
#delete_gist(gist, options = {}) ⇒ Boolean
Delete a gist
132 133 134 |
# File 'lib/octokit/client/gists.rb', line 132 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.
200 201 202 |
# File 'lib/octokit/client/gists.rb', line 200 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
86 87 88 |
# File 'lib/octokit/client/gists.rb', line 86 def edit_gist(gist, = {}) patch "gists/#{Gist.new gist}", end |
#fork_gist(gist, options = {}) ⇒ Sawyer::Resource
Fork a gist
123 124 125 |
# File 'lib/octokit/client/gists.rb', line 123 def fork_gist(gist, = {}) post "gists/#{Gist.new gist}/forks", end |
#gist(gist, options = {}) ⇒ Sawyer::Resource
Get a single gist
49 50 51 |
# File 'lib/octokit/client/gists.rb', line 49 def gist(gist, = {}) get "gists/#{Gist.new gist}", end |
#gist_comment(gist_id, gist_comment_id, options = {}) ⇒ Sawyer::Resource
Get gist comment
155 156 157 |
# File 'lib/octokit/client/gists.rb', line 155 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
143 144 145 |
# File 'lib/octokit/client/gists.rb', line 143 def gist_comments(gist_id, = {}) paginate "gists/#{gist_id}/comments", end |
#gist_starred?(gist, options = {}) ⇒ Boolean
Check if a gist is starred
114 115 116 |
# File 'lib/octokit/client/gists.rb', line 114 def gist_starred?(gist, = {}) boolean_from_response :get, "gists/#{Gist.new gist}/star", end |
#gists(username = 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(username=nil, = {}) if username.nil? paginate 'gists', else paginate "users/#{username}/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
96 97 98 |
# File 'lib/octokit/client/gists.rb', line 96 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
40 41 42 |
# File 'lib/octokit/client/gists.rb', line 40 def starred_gists( = {}) paginate 'gists/starred', end |
#unstar_gist(gist, options = {}) ⇒ Boolean
Unstar a gist
105 106 107 |
# File 'lib/octokit/client/gists.rb', line 105 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
185 186 187 188 |
# File 'lib/octokit/client/gists.rb', line 185 def update_gist_comment(gist_id, gist_comment_id, comment, = {}) .merge!({:body => comment}) patch "gists/#{gist_id}/comments/#{gist_comment_id}", end |