这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on Aug 23, 2024. It is now read-only.

Fix Gist::delete #185

Merged
merged 3 commits into from
Jul 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 44 additions & 32 deletions lib/octonode/gist.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

114 changes: 66 additions & 48 deletions lib/octonode/me.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 11 additions & 8 deletions lib/octonode/repo.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 17 additions & 13 deletions src/octonode/gist.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ class Gist

# Delete a gist
# '/gists/37' DELETE
delete: (id) ->
@client.del "/gists/#{id}", {}, (err, s, b, h) =>
@delete(id) if err? or s isnt 204
delete: (id, cb) ->
@client.del "/gists/#{id}", {}, (err, s, b, h) ->
return cb(err) if err
if s isnt 204 then cb(new Error("Gist delete error")) else cb null

# Fork a gist
# '/gists/37/forks' POST
Expand All @@ -83,19 +84,21 @@ class Gist

# Star a gist
# '/gists/37/star' PUT
star: (id) ->
@client.put "/gists/#{id}/star", {}, (err, s, b, h) =>
@star(id) if err? or s isnt 204
star: (id, cb) ->
@client.put "/gists/#{id}/star", {}, (err, s, b, h) ->
return cb(err) if err
if s isnt 204 then cb(new Error("Gist star error")) else cb null

# Unstar a gist
# '/gists/37/unstar' DELETE
unstar: (id) ->
@client.del "/gists/#{id}/unstar", {}, (err, s, b, h) =>
@unstar(id) if err? or s isnt 204
unstar: (id, cb) ->
@client.del "/gists/#{id}/unstar", {}, (err, s, b, h) ->
return cb(err) if err
if s isnt 204 then cb(new Error("Gist unstar error")) else cb null

# Check if a gist is starred
# '/gists/37/star' GET
check: (id) ->
check: (id, cb) ->
@client.get "/gists/#{id}/star", (err, s, b, h) ->
return cb(err) if err
cb null, s is 204, h
Expand Down Expand Up @@ -130,9 +133,10 @@ class Gist

# Delete a comment
# '/gists/comments/1' DELETE
deleteComment: (id) ->
@client.del "/gists/comments/#{id}", {}, (err, s, b, h) =>
@deleteComment(id) if err? or s isnt 204
deleteComment: (id, cb) ->
@client.del "/gists/comments/#{id}", {}, (err, s, b, h) ->
return cb(err) if err
if s isnt 204 then cb(new Error("Gist deleteComment error")) else cb null

comments: (id, cbOrCmnt, cb) ->
if !cb? and typeof cbOrCmnt is 'function'
Expand Down
Loading