Parent

Class/Module Index [+]

Quicksearch

Github::Client::Gists

Public Instance Methods

all(*args) click to toggle source
Alias for: list
commits(*args) click to toggle source

List gist commits

@example

github = Github.new
github.gists.commits 'gist-id'

@api public

# File lib/github_api/client/gists.rb, line 169
def commits(*args)
  arguments(args, required: [:id])

  response = get_request("/gists/#{arguments.id}/commits")
  return response unless block_given?
  response.each { |el| yield el }
end
create(*args) click to toggle source

Create a gist

@param [Hash] params @option params [String] :description

Optional string

@option params [Boolean] :public

Required boolean

@option params [Hash] :files

Required hash - Files that make up this gist.
The key of which should be a required string filename and
the value another required hash with parameters:
  @option files [String] :content
    Required string - File contents.

@example

github = Github.new
github.gists.create
  description: 'the description for this gist',
  public: true,
  files: {
    'file1.txt' => {
       content: 'String file contents'
     }
  }

@return [Hash]

@api public

# File lib/github_api/client/gists.rb, line 113
def create(*args)
  arguments(args) do
    assert_required REQUIRED_GIST_INPUTS
  end

  post_request("/gists", arguments.params)
end
delete(*args) click to toggle source

Delete a gist

@example

github = Github.new
github.gists.delete 'gist-id'

@api public

# File lib/github_api/client/gists.rb, line 252
def delete(*args)
  arguments(args, required: [:id])

  delete_request("/gists/#{arguments.id}", arguments.params)
end
edit(*args) click to toggle source

Edit a gist

@param [Hash] params @option [String] :description

Optional string

@option [Hash] :files

Optional hash - Files that make up this gist.
The key of which should be a optional string filename and 
the value another optional hash with parameters:
  @option [String] :content
    Updated string - Update file contents.
  @option [String] :filename
    Optional string - New name for this file.

@xample

github = Github.new oauth_token: '...'
github.gists.edit 'gist-id',
  description: 'the description for this gist',
  files: {
    'file1.txt' => {
       content: 'Updated file contents'
     },
    'old_name.txt' => {
       filename: 'new_name.txt',
       content: 'modified contents'
     },
    'new_file.txt' => {
       content: 'a new file contents'
     },
     'delete_the_file.txt' => nil
  }

@return [Hash]

@api public

# File lib/github_api/client/gists.rb, line 156
def edit(*args)
  arguments(args, required: [:id])

  patch_request("/gists/#{arguments.id}", arguments.params)
end
find(*args) click to toggle source
Alias for: get
fork(*args) click to toggle source

Fork a gist

@example

github = Github.new
github.gists.fork 'gist-id'

@api public

# File lib/github_api/client/gists.rb, line 224
def fork(*args)
  arguments(args, required: [:id])

  post_request("/gists/#{arguments.id}/fork", arguments.params)
end
forks(*args) click to toggle source

List gist forks

@example

github = Github.new
github.gists.forks 'gist-id'

@api public

# File lib/github_api/client/gists.rb, line 237
def forks(*args)
  arguments(args, required: [:id])

  response = get_request("/gists/#{arguments.id}/forks")
  return response unless block_given?
  response.each { |el| yield el }
end
get(*args) click to toggle source

Get a single gist

@example

github = Github.new
github.gists.get 'gist-id'

@return [Hash]

@api public

# File lib/github_api/client/gists.rb, line 78
def get(*args)
  arguments(args, required: [:id])

  get_request("/gists/#{arguments.id}", arguments.params)
end
Also aliased as: find
list(*args) click to toggle source

List a user’s gists

@example

github = Github.new
github.gists.list user: 'user-name'

List the authenticated user’s gists or if called anonymously, this will returns all public gists

@example

github = Github.new oauth_token: '...'
github.gists.list

List all public gists

github = Github.new
github.gists.list :public

@return [Hash]

@api public

# File lib/github_api/client/gists.rb, line 38
def list(*args)
  params = arguments(args).params

  response = if (user = params.delete('user'))
    get_request("/users/#{user}/gists", params)
  elsif args.map(&:to_s).include?('public')
    get_request("/gists/public", params)
  else
    get_request("/gists", params)
  end
  return response unless block_given?
  response.each { |el| yield el }
end
Also aliased as: all
star(*args) click to toggle source

Star a gist

@example

github = Github.new
github.gists.star 'gist-id'

@api public

# File lib/github_api/client/gists.rb, line 184
def star(*args)
  arguments(args, required: [:id])

  put_request("/gists/#{arguments.id}/star", arguments.params)
end
starred(*args) click to toggle source

List the authenticated user’s starred gists

@example

github = Github.new oauth_token: '...'
github.gists.starred

@return [Hash]

@api public

# File lib/github_api/client/gists.rb, line 62
def starred(*args)
  arguments(args)
  response = get_request("/gists/starred", arguments.params)
  return response unless block_given?
  response.each { |el| yield el }
end
starred?(*args) click to toggle source

Check if a gist is starred

Examples

github = Github.new
github.gists.starred? 'gist-id'
# File lib/github_api/client/gists.rb, line 209
def starred?(*args)
  arguments(args, required: [:id])
  get_request("/gists/#{arguments.id}/star", arguments.params)
  true
rescue Github::Error::NotFound
  false
end
unstar(*args) click to toggle source

Unstar a gist

@xample

github = Github.new
github.gists.unstar 'gist-id'

@api public

# File lib/github_api/client/gists.rb, line 197
def unstar(*args)
  arguments(args, required: [:id])

  delete_request("/gists/#{arguments.id}/star", arguments.params)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.