Module: Octokit::Client::Gists

Included in:
Octokit::Client
Defined in:
lib/octokit/client/gists.rb

Instance Method Summary collapse

Instance Method Details

#create_gist(options = {}) ⇒ Object



5
6
7
# File 'lib/octokit/client/gists.rb', line 5

def create_gist(options={})
  post '/gists', options, 3
end

#delete_gist(gist, options = {}) ⇒ Object



9
10
11
12
# File 'lib/octokit/client/gists.rb', line 9

def delete_gist(gist, options={})
  response = delete("/gists/#{Gist.new gist}", options, 3, true, true)
  response.status == 204
end

#edit_gist(gist, options = {}) ⇒ Object



14
15
16
# File 'lib/octokit/client/gists.rb', line 14

def edit_gist(gist, options={})
  patch "/gists/#{Gist.new gist}", options, 3
end

#fork_gist(gist, options = {}) ⇒ Object



40
41
42
# File 'lib/octokit/client/gists.rb', line 40

def fork_gist(gist, options={})
  post "/gists/#{Gist.new gist}/fork", options, 3
end

#gist(gist, options = {}) ⇒ Object



18
19
20
# File 'lib/octokit/client/gists.rb', line 18

def gist(gist, options={})
  get "/gists/#{Gist.new gist}", options, 3
end

#gist_starred?(gist, options = {}) ⇒ Boolean

Returns true if gist is starred, false otherwise.

Returns:

  • (Boolean)


31
32
33
34
35
36
37
38
# File 'lib/octokit/client/gists.rb', line 31

def gist_starred?(gist, options={})
  begin
    get("/gists/#{Gist.new gist}/star", options, 3, true, true)
    return true
  rescue Octokit::NotFound
    return false
  end
end

#gists(username = nil, options = {}) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/octokit/client/gists.rb', line 22

def gists(username=nil, options={})
  if username.nil?
    get '/gists', options, 3
  else
    get "/users/#{username}/gists", options, 3
  end
end

#public_gists(options = {}) ⇒ Object



44
45
46
# File 'lib/octokit/client/gists.rb', line 44

def public_gists(options={})
  get '/gists', options, 3
end

#star_gist(gist, options = {}) ⇒ Object

Returns true or false based on success.



53
54
55
56
# File 'lib/octokit/client/gists.rb', line 53

def star_gist(gist, options={})
  response = put("/gists/#{Gist.new gist}/star", options, 3, true, true)
  response.status == 204
end

#starred_gists(options = {}) ⇒ Object



48
49
50
# File 'lib/octokit/client/gists.rb', line 48

def starred_gists(options={})
  get '/gists/starred', options, 3
end

#unstar_gist(gist, options = {}) ⇒ Object

Returns true or false based on success.



59
60
61
62
# File 'lib/octokit/client/gists.rb', line 59

def unstar_gist(gist, options={})
  response = delete("/gists/#{Gist.new gist}/star", options, 3, true, true)
  response.status == 204
end