jsl-feedzirra 0.0.12.5 → 0.0.12.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@ module Feedzirra
7
7
  # a page hasn't changed, and which feed entries have been updated.
8
8
  class DevNull
9
9
 
10
- def initialize(options = { })
10
+ def initialize(options = { })
11
11
  end
12
12
 
13
13
  def get(url)
@@ -11,6 +11,7 @@ module Feedzirra
11
11
 
12
12
  def initialize(options = { })
13
13
  @options = DEFAULTS.merge(options)
14
+ initialize_store
14
15
  end
15
16
 
16
17
  def get(url)
@@ -24,6 +25,10 @@ module Feedzirra
24
25
 
25
26
  private
26
27
 
28
+ def initialize_store
29
+ FileUtils.mkdir(@options[:path]) unless File.exist?(@options[:path])
30
+ end
31
+
27
32
  def filename_for(url)
28
33
  File.join(@options[:path], MD5.hexdigest(URI.parse(url).normalize.to_s))
29
34
  end
@@ -6,7 +6,8 @@ module Feedzirra
6
6
  class Memory
7
7
 
8
8
  def initialize(options = { })
9
- @store = { }
9
+ @store = { }
10
+ @options = options
10
11
  end
11
12
 
12
13
  def get(url)
@@ -17,7 +17,7 @@ module Feedzirra
17
17
  @retrievables = args.flatten
18
18
  @multi = Curl::Multi.new
19
19
  @responses = { }
20
- @backend = @options[:backend][:class].new
20
+ @backend = @options[:backend][:class].new(@options[:backend].except(:class))
21
21
  end
22
22
 
23
23
  # Prepares the curl object and calls #perform
data/lib/feedzirra.rb CHANGED
@@ -14,6 +14,7 @@ require 'active_support/core_ext/time'
14
14
  require 'core_ext/date'
15
15
  require 'core_ext/string'
16
16
  require 'core_ext/array'
17
+ require 'core_ext/hash'
17
18
 
18
19
  require 'feedzirra/backend/dev_null'
19
20
  require 'feedzirra/backend/filesystem'
@@ -20,4 +20,12 @@ describe Feedzirra::Backend::Filesystem do
20
20
  Feedzirra::Backend::Filesystem.new({:path => '/tmp'}).__send__(:filename_for, 'hey').should == '/tmp/bah'
21
21
  end
22
22
  end
23
+
24
+ describe "#initialize_store" do
25
+ it "should call File.mkdir if the directory does not exist" do
26
+ File.expects(:exist?).with('/tmp').returns(false)
27
+ FileUtils.expects(:mkdir).with('/tmp')
28
+ @backend.__send__(:initialize_store)
29
+ end
30
+ end
23
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsl-feedzirra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12.5
4
+ version: 0.0.12.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Dix