jsl-myzofeedtosis 0.0.2.1 → 0.0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,19 +9,26 @@ module Myzofeedtosis
9
9
  class Client
10
10
  attr_reader :options, :url
11
11
 
12
+ @@backends = {} unless defined?(@@backends)
13
+
12
14
  DEFAULTS = {
13
15
  :backend => {
14
16
  :moneta_klass => 'Moneta::Memory'
15
17
  }
16
18
  } unless defined?(DEFAULTS)
17
19
 
20
+ # Initializes a new myzofeedtosis library. The backend can be a hash of options, in
21
+ # which case we initialize a new HashBack::Backend. Or, it may be a pre-initialized
22
+ # backend, in which case we set the backend to the given HashBack::Backend object.
18
23
  def initialize(url, options = { })
19
24
  @url = url
20
- @options = DEFAULTS.merge(options)
21
25
 
22
- @backend = HashBack::Backend.new( 'Myzofeedtosis',
23
- @options[:backend][:moneta_klass],
24
- @options[:backend].except(:moneta_klass) )
26
+ if options[:backend].is_a?(HashBack::Backend)
27
+ @backend = options[:backend]
28
+ else
29
+ @options = DEFAULTS.merge(options.dup)
30
+ @backend = HashBack::Backend.new( 'Myzofeedtosis', @options[:backend][:moneta_klass], @options[:backend].except(:moneta_klass) )
31
+ end
25
32
  end
26
33
 
27
34
  # Retrieves the latest entries from this feed. Returns a Myzofeedtosis::Result
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{myzofeedtosis}
3
- s.version = "0.0.2.1"
3
+ s.version = "0.0.2.2"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Justin Leitgeb"]
@@ -35,6 +35,14 @@ describe Myzofeedtosis::Client do
35
35
  @fr.expects(:new_curl_easy).returns(curl_easy)
36
36
  @fr.fetch
37
37
  end
38
+
39
+ describe "when given a pre-initialized backend" do
40
+ it "should set the @backend to the pre-initialized structure" do
41
+ h = HashBack::Backend.new('Foo', 'Moneta::Memory')
42
+ fc = Myzofeedtosis::Client.new(@url, :backend => h)
43
+ fc.__send__(:instance_variable_get, :@backend).should == h
44
+ end
45
+ end
38
46
  end
39
47
 
40
48
  describe "#fetch" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsl-myzofeedtosis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2.1
4
+ version: 0.0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Leitgeb