Sha256: f783264f92b5b18a3dce74711b545d6a3a918ea9f91a5b6af561755e0849e1e0
Contents?: true
Size: 831 Bytes
Versions: 2
Compression:
Stored size: 831 Bytes
Contents
require 'md5' require 'uri' module Feedzirra module Backend class Filesystem DEFAULTS = { :path => File.expand_path(File.join(%w[ ~ / .feedzirra ])) } def initialize(options = { }) @options = DEFAULTS.merge(options) initialize_store end def get(url) f = filename_for(url) Marshal.load(File.read(f)) if File.exist?(f) end def set(url, result) File.open(filename_for(url), 'w') {|f| f.write(Marshal.dump(result)) } end private def initialize_store FileUtils.mkdir(@options[:path]) unless File.exist?(@options[:path]) end def filename_for(url) File.join(@options[:path], MD5.hexdigest(URI.parse(url).normalize.to_s)) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jsl-feedzirra-0.0.12.6 | lib/feedzirra/backend/filesystem.rb |
jsl-feedzirra-0.0.12.7 | lib/feedzirra/backend/filesystem.rb |