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
70 71 72 |
# File 'lib/octokit/client/gists.rb', line 70 def create_gist( = {}) post 'gists', end |
#create_gist_comment(gist_id, comment, options = {}) ⇒ Sawyer::Resource
Create gist comment
Requires authenticated client.
197 198 199 200 |
# File 'lib/octokit/client/gists.rb', line 197 def create_gist_comment(gist_id, comment, = {}) .merge!({:body => comment}) post "gists/#{gist_id}/comments", end |
#delete_gist(gist, options = {}) ⇒ Boolean
Delete a gist
160 161 162 |
# File 'lib/octokit/client/gists.rb', line 160 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.
228 229 230 |
# File 'lib/octokit/client/gists.rb', line 228 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
92 93 94 |
# File 'lib/octokit/client/gists.rb', line 92 def edit_gist(gist, = {}) patch "gists/#{Gist.new(gist)}", end |
#fork_gist(gist, options = {}) ⇒ Sawyer::Resource
Fork a gist
140 141 142 |
# File 'lib/octokit/client/gists.rb', line 140 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 |
# File 'lib/octokit/client/gists.rb', line 52 def gist(gist, = {}) 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
183 184 185 |
# File 'lib/octokit/client/gists.rb', line 183 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
171 172 173 |
# File 'lib/octokit/client/gists.rb', line 171 def gist_comments(gist_id, = {}) paginate "gists/#{gist_id}/comments", end |
#gist_commits(gist, options = {}) ⇒ Array
List gist commits
103 104 105 |
# File 'lib/octokit/client/gists.rb', line 103 def gist_commits(gist, = {}) paginate "gists/#{Gist.new(gist)}/commits", end |
#gist_forks(gist, options = {}) ⇒ Array
List gist forks
151 152 153 |
# File 'lib/octokit/client/gists.rb', line 151 def gist_forks(gist, = {}) paginate "gists/#{Gist.new(gist)}/forks", end |
#gist_starred?(gist, options = {}) ⇒ Boolean
Check if a gist is starred
131 132 133 |
# File 'lib/octokit/client/gists.rb', line 131 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
113 114 115 |
# File 'lib/octokit/client/gists.rb', line 113 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
122 123 124 |
# File 'lib/octokit/client/gists.rb', line 122 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
213 214 215 216 |
# File 'lib/octokit/client/gists.rb', line 213 def update_gist_comment(gist_id, gist_comment_id, comment, = {}) .merge!({:body => comment}) patch "gists/#{gist_id}/comments/#{gist_comment_id}", end |