Created
July 9, 2013 22:21
-
-
Save jimjh/5961836 to your computer and use it in GitHub Desktop.
Caching with github_api gem using Faraday middleware.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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