Sha256: c4244ac01397d5c2ca73f988b601ed503969bfdae414c2322fb9814c661c0b12
Contents?: true
Size: 837 Bytes
Versions: 30
Compression:
Stored size: 837 Bytes
Contents
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.dirname(__FILE__)) require 'rspec' require 'kindai' require 'tmpdir' module Kindai::Util def self.fetch_uri(uri, rich = false) logger.debug "fetch uri #{uri}" uri = URI.parse(uri) unless uri.kind_of? URI cache_directory = File.join(Dir.tmpdir, 'kindairb-cache') Dir.mkdir(cache_directory) unless File.directory?(cache_directory) cache_file = File.join(cache_directory, Digest::SHA1.hexdigest(uri.to_s)) unless File.exists? cache_file logger.debug "fetch cache #{uri}" open(cache_file, 'w') {|f| f.write Marshal.dump(uri.read) } end Marshal.load open(cache_file).read end # require 'logger' # require "stringio" # def self.logger # Logger.new(StringIO.new) # end end
Version data entries
30 entries across 30 versions & 1 rubygems