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

Version Path
kindai-2.8.0 spec/spec_helper.rb
kindai-2.7.0 spec/spec_helper.rb
kindai-2.6.0 spec/spec_helper.rb
kindai-2.5.1 spec/spec_helper.rb
kindai-2.4.3 spec/spec_helper.rb
kindai-2.4.2 spec/spec_helper.rb
kindai-2.4.1 spec/spec_helper.rb
kindai-2.4.0 spec/spec_helper.rb
kindai-2.3.0 spec/spec_helper.rb
kindai-2.2.1 spec/spec_helper.rb
kindai-2.2.0 spec/spec_helper.rb
kindai-2.1.2 spec/spec_helper.rb
kindai-2.1.1 spec/spec_helper.rb
kindai-2.1.0 spec/spec_helper.rb
kindai-2.0.0 spec/spec_helper.rb
kindai-1.9.0 spec/spec_helper.rb
kindai-1.8.0 spec/spec_helper.rb
kindai-1.7.4 spec/spec_helper.rb
kindai-1.7.2 spec/spec_helper.rb
kindai-1.7.1 spec/spec_helper.rb