Skip to content

Instantly share code, notes, and snippets.

@SabretWoW
Created December 11, 2013 23:20
Show Gist options
  • Save SabretWoW/7920355 to your computer and use it in GitHub Desktop.
Save SabretWoW/7920355 to your computer and use it in GitHub Desktop.
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