Skip to content

Instantly share code, notes, and snippets.

@jimjh
Created July 9, 2013 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimjh/5961836 to your computer and use it in GitHub Desktop.
Save jimjh/5961836 to your computer and use it in GitHub Desktop.
Caching with github_api gem using Faraday middleware.
#!/usr/bin/env ruby
require 'github_api'
require 'faraday-http-cache'
require 'logger'
@store = ActiveSupport::Cache::MemoryStore.new
@github = Github::Repos::Contents.new do |config|
config.stack.insert_before Github::Response::Jsonize, Faraday::HttpCache, @store
end
def fire
resp = @github.get user: 'jimjh', repo: 'floating-point-lesson', path: 'manifest.yml'
puts "x-ratelimit-remaining: #{resp.headers.ratelimit_remaining}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment