Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A Ruby script demonstrating how to pull Gists from the GitHub Gist API.
# Gem that wraps around the Gist API
# https://github.com/sinisterchipmunk/active-gist
require 'activegist'
# GitHub Gist API documentation:
# - http://developer.github.com/v3/gists/
# Set up credentials.
ActiveGist::API.username = "Your GitHub username"
ActiveGist::API.password = "Your GitHub password"
gist_id = 6234923
gist = ActiveGist.find(gist_id)
puts "The dump of gist ##{gist.id}\n\n"
puts gist.inspect
puts "\nAnd some of the pieces in the response:\n\n"
puts "ID: #{gist.id}"
puts "User: #{gist.user}"
puts "Gist description: #{gist.description}"
puts "User's URL: #{gist.user['html_url']}"
puts "Site admin? #{gist.user['site_admin']}"
puts "\nGist ##{gist.id} pulled successfully!\n\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.