@@ -5,18 +5,13 @@ class Client::Gists < API
55
66 require_all 'github_api/client/gists' , 'comments'
77
8- REQUIRED_GIST_INPUTS = %w[
9- description
10- public
11- files
12- content
13- ] . freeze
14-
158 # Access to Gists::Comments API
169 namespace :comments
1710
1811 # List a user's gists
1912 #
13+ # @see https://developer.github.com/v3/gists/#list-a-users-gists
14+ #
2015 # @example
2116 # github = Github.new
2217 # github.gists.list user: 'user-name'
@@ -30,6 +25,8 @@ class Client::Gists < API
3025 #
3126 # List all public gists
3227 #
28+ # @see https://developer.github.com/v3/gists/#list-all-public-gists
29+ #
3330 # github = Github.new
3431 # github.gists.list :public
3532 #
@@ -49,13 +46,15 @@ def list(*args)
4946 return response unless block_given?
5047 response . each { |el | yield el }
5148 end
52- alias :all :list
49+ alias_method :all , :list
5350
5451 # List the authenticated user's starred gists
5552 #
53+ # @see https://developer.github.com/v3/gists/#list-starred-gists
54+ #
5655 # @example
57- # github = Github.new oauth_token: '...'
58- # github.gists.starred
56+ # github = Github.new oauth_token: '...'
57+ # github.gists.starred
5958 #
6059 # @return [Hash]
6160 #
@@ -69,22 +68,38 @@ def starred(*args)
6968
7069 # Get a single gist
7170 #
71+ # @see https://developer.github.com/v3/gists/#get-a-single-gist
72+ #
7273 # @example
73- # github = Github.new
74- # github.gists.get 'gist-id'
74+ # github = Github.new
75+ # github.gists.get 'gist-id'
76+ #
77+ # Get a specific revision of gist
78+ #
79+ # @see https://developer.github.com/v3/gists/#get-a-specific-revision-of-a-gist
80+ #
81+ # @example
82+ # github = Github.new
83+ # github.gists.get 'gist-id', sha: '
7584 #
7685 # @return [Hash]
7786 #
7887 # @api public
7988 def get ( *args )
8089 arguments ( args , required : [ :id ] )
8190
82- get_request ( "/gists/#{ arguments . id } " , arguments . params )
91+ if ( sha = arguments . params . delete ( 'sha' ) )
92+ get_request ( "/gists/#{ arguments . id } /#{ sha } " )
93+ else
94+ get_request ( "/gists/#{ arguments . id } " , arguments . params )
95+ end
8396 end
84- alias :find :get
97+ alias_method :find , :get
8598
8699 # Create a gist
87100 #
101+ # @see https://developer.github.com/v3/gists/#create-a-gist
102+ #
88103 # @param [Hash] params
89104 # @option params [String] :description
90105 # Optional string
@@ -112,15 +127,15 @@ def get(*args)
112127 #
113128 # @api public
114129 def create ( *args )
115- arguments ( args ) do
116- assert_required REQUIRED_GIST_INPUTS
117- end
130+ arguments ( args )
118131
119132 post_request ( "/gists" , arguments . params )
120133 end
121134
122135 # Edit a gist
123136 #
137+ # @see https://developer.github.com/v3/gists/#edit-a-gist
138+ #
124139 # @param [Hash] params
125140 # @option [String] :description
126141 # Optional string
@@ -162,6 +177,8 @@ def edit(*args)
162177
163178 # List gist commits
164179 #
180+ # @see https://developer.github.com/v3/gists/#list-gist-commits
181+ #
165182 # @example
166183 # github = Github.new
167184 # github.gists.commits 'gist-id'
@@ -177,6 +194,8 @@ def commits(*args)
177194
178195 # Star a gist
179196 #
197+ # @see https://developer.github.com/v3/gists/#star-a-gist
198+ #
180199 # @example
181200 # github = Github.new
182201 # github.gists.star 'gist-id'
@@ -190,6 +209,8 @@ def star(*args)
190209
191210 # Unstar a gist
192211 #
212+ # @see https://developer.github.com/v3/gists/#unstar-a-gist
213+ #
193214 # @xample
194215 # github = Github.new
195216 # github.gists.unstar 'gist-id'
@@ -203,10 +224,13 @@ def unstar(*args)
203224
204225 # Check if a gist is starred
205226 #
206- # = Examples
207- # github = Github.new
208- # github.gists.starred? 'gist-id'
227+ # @see https://developer.github.com/v3/gists/#check-if-a-gist-is-starred
209228 #
229+ # @example
230+ # github = Github.new
231+ # github.gists.starred? 'gist-id'
232+ #
233+ # @api public
210234 def starred? ( *args )
211235 arguments ( args , required : [ :id ] )
212236 get_request ( "/gists/#{ arguments . id } /star" , arguments . params )
@@ -225,14 +249,16 @@ def starred?(*args)
225249 def fork ( *args )
226250 arguments ( args , required : [ :id ] )
227251
228- post_request ( "/gists/#{ arguments . id } /fork " , arguments . params )
252+ post_request ( "/gists/#{ arguments . id } /forks " , arguments . params )
229253 end
230254
231255 # List gist forks
232256 #
257+ # @see https://developer.github.com/v3/gists/#list-gist-forks
258+ #
233259 # @example
234- # github = Github.new
235- # github.gists.forks 'gist-id'
260+ # github = Github.new
261+ # github.gists.forks 'gist-id'
236262 #
237263 # @api public
238264 def forks ( *args )
@@ -245,6 +271,8 @@ def forks(*args)
245271
246272 # Delete a gist
247273 #
274+ # @see https://developer.github.com/v3/gists/#delete-a-gist
275+ #
248276 # @example
249277 # github = Github.new
250278 # github.gists.delete 'gist-id'
0 commit comments