class Github::Gists
def comments(options={}, &block)
def comments(options={}, &block) @comments ||= ApiFactory.new('Gists::Comments', current_options.merge(options), &block) end
def create(*args)
}
}
'content' => 'String file contents'
'file1.txt' => {
'files' => {
'public' => true,
'description' => 'the description for this gist',
github.gists.create
github = Github.new
= Examples
:content - Required string - File contents.
the value another required hash with parameters:
The key of which should be a required string filename and
:files - Required hash - Files that make up this gist.
:public - Required boolean
:description - Optional string
= Inputs
Create a gist
def create(*args) arguments(args) do assert_required REQUIRED_GIST_INPUTS end post_request("/gists", arguments.params) end
def delete(*args)
github.gists.delete 'gist-id'
github = Github.new
= Examples
Delete a gist
def delete(*args) arguments(args, :required => [:gist_id]) delete_request("/gists/#{gist_id}", arguments.params) end
def edit(*args)
}
'delete_the_file.txt' => nil
},
'content' => 'a new file contents'
'new_file.txt' => {
},
'content' => 'modified contents'
'filename' => 'new_name.txt',
'old_name.txt' => {
},
'content' => 'Updated file contents'
'file1.txt' => {
'files' => {
'description' => 'the description for this gist',
github.gists.edit 'gist-id',
github = Github.new :oauth_token => '...'
= Examples
:filename - Optional string - New name for this file.
:content - Updated string - Update file contents.
the value another optional hash with parameters:
The key of which should be a optional string filename and
:files - Optional hash - Files that make up this gist.
:description - Optional string
= Inputs
Edit a gist
def edit(*args) arguments(args, :required => [:gist_id]) patch_request("/gists/#{gist_id}", arguments.params) end
def fork(*args)
github.gists.fork 'gist-id'
github = Github.new
= Examples
Fork a gist
def fork(*args) arguments(args, :required => [:gist_id]) post_request("/gists/#{gist_id}/fork", arguments.params) end
def get(*args)
github.gists.get 'gist-id'
github = Github.new
= Examples
Get a single gist
def get(*args) arguments(args, :required => [:gist_id]) get_request("/gists/#{gist_id}", arguments.params) end
def list(*args)
github.gists.list
github = Github.new :oauth_token => '...'
= Examples
this will returns all public gists
List the authenticated user’s gists or if called anonymously,
github.gists.list user: 'user-name'
github = Github.new
= Examples
List a user's gists.
def list(*args) params = arguments(args).params response = if (user = params.delete('user')) get_request("/users/#{user}/gists", params) elsif oauth_token get_request("/gists", params) else get_request("/gists/public", params) end return response unless block_given? response.each { |el| yield el } end
def star(*args)
github.gists.star 'gist-id'
github = Github.new
= Examples
Star a gist
def star(*args) arguments(args, :required => [:gist_id]) put_request("/gists/#{gist_id}/star", arguments.params) end
def starred(*args)
github.gists.starred
github = Github.new :oauth_token => '...'
= Examples
List the authenticated user's starred gists
def starred(*args) arguments(args) response = get_request("/gists/starred", arguments.params) return response unless block_given? response.each { |el| yield el } end
def starred?(*args)
github.gists.starred? 'gist-id'
github = Github.new
= Examples
Check if a gist is starred
def starred?(*args) arguments(args, :required => [:gist_id]) get_request("/gists/#{gist_id}/star", arguments.params) true rescue Github::Error::NotFound false end
def unstar(*args)
github.gists.unstar 'gist-id'
github = Github.new
= Examples
Unstar a gist
def unstar(*args) arguments(args, :required => [:gist_id]) delete_request("/gists/#{gist_id}/star", arguments.params) end