class Github::Gists
def create_gist(params={})
}
}
'content' => 'String file contents'
'file1.txt' => {
'files' => {
'public' => true,
'description' => 'the description for this gist',
@github.gists.create_gist
@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_gist(params={}) _normalize_params_keys(params) unless _validate_inputs(REQUIRED_GIST_INPUTS, params) raise ArgumentError, "Required parameters are: #{REQUIRED_GIST_INPUTS.join(', ')}" end post("/gists", params) end
def delete_gist(gist_id, params={})
@github.gists.delete_gist 'gist-id'
@github = Github.new
= Examples
Delete a gist
def delete_gist(gist_id, params={}) _validate_presence_of(gist_id) _normalize_params_keys(params) delete("/gists/#{gist_id}", params) end
def edit_gist(gist_id, params={})
}
'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 '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_gist(gist_id, params={}) _validate_presence_of(gist_id) _normalize_params_keys(params) patch("/gists/#{gist_id}", params) end
def fork(gist_id, params={})
@github.gists.fork 'gist-id'
@github = Github.new
= Examples
Fork a gist
def fork(gist_id, params={}) _validate_presence_of(gist_id) _normalize_params_keys(params) post("/gists/#{gist_id}/fork", params) end
def gist(gist_id, params={})
@github.gists.get_gist 'gist-id'
@github = Github.new
= Examples
Get a single gist
def gist(gist_id, params={}) _normalize_params_keys(params) _validate_presence_of(gist_id) get("/gists/#{gist_id}", params) end
def gists(user_name=nil, params={})
@github.gists.gists
@github = Github.new :oauth_token => '...'
= Examples
this will returns all public gists
List the authenticated user’s gists or if called anonymously,
@github.gists.gists
@github = Github.new :user => 'user-name'
= Examples
List a user's gists.
def gists(user_name=nil, params={}) _update_user_repo_params(user_name) _normalize_params_keys(params) response = if user get("/users/#{user}/gists", params) elsif oauth_token get("/gists", params) else get("/gists/public", params) end return response unless block_given? response.each { |el| yield el } end
def initialize(options = {})
def initialize(options = {}) super(options) end
def star(gist_id, params={})
@github.gists.star 'gist-id'
@github = Github.new
= Examples
Star a gist
def star(gist_id, params={}) _validate_presence_of(gist_id) _normalize_params_keys(params) put("/gists/#{gist_id}/star", params) end
def starred(params={})
@github.gists.starred
@github = Github.new :oauth_token => '...'
= Examples
List the authenticated user's starred gists
def starred(params={}) _normalize_params_keys(params) response = get("/gists/starred", params) return response unless block_given? response.each { |el| yield el } end
def starred?(gist_id, params={})
@github.gists.unstar 'gist-id'
@github = Github.new
= Examples
Check if a gist is starred
def starred?(gist_id, params={}) _validate_presence_of(gist_id) _normalize_params_keys(params) get("/gists/#{gist_id}/star", params) true rescue Github::ResourceNotFound false end
def unstar(gist_id, params={})
@github.gists.unstar 'gist-id'
@github = Github.new
= Examples
Unstar a gist
def unstar(gist_id, params={}) _validate_presence_of(gist_id) _normalize_params_keys(params) delete("/gists/#{gist_id}/star", params) end