File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -173,7 +173,8 @@ begin
173
173
174
174
if options . key? :read
175
175
file_name = ARGV . first
176
- Gist . read_gist ( options [ :read ] , file_name )
176
+ output = Gist . read_gist ( options [ :read ] , file_name )
177
+ puts output if output
177
178
exit
178
179
end
179
180
Original file line number Diff line number Diff line change @@ -212,10 +212,13 @@ def list_all_gists(user = "")
212
212
get_gist_pages ( url , auth_token ( ) )
213
213
end
214
214
215
- def read_gist ( id , file_name = nil )
215
+ def read_gist ( id , file_name = nil , options = { } )
216
216
url = "#{ base_path } /gists/#{ id } "
217
217
218
- access_token = auth_token ( )
218
+ access_token = ( options [ :access_token ] || auth_token ( ) )
219
+ if access_token . to_s != ''
220
+ url << "?access_token=" << CGI . escape ( access_token )
221
+ end
219
222
220
223
request = Net ::HTTP ::Get . new ( url )
221
224
request [ 'Authorization' ] = "token #{ access_token } " if access_token . to_s != ''
@@ -232,7 +235,7 @@ def read_gist(id, file_name=nil)
232
235
file = files . values . first
233
236
end
234
237
235
- puts file [ "content" ]
238
+ file [ "content" ]
236
239
else
237
240
raise Error , "Gist with id of #{ id } does not exist."
238
241
end
You can’t perform that action at this time.
0 commit comments