juvet 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c2bcdf113709238fbc9a40cd143299aa1e831c53
4
- data.tar.gz: 1ee79a71687b9f3046fc23e48cd662c90ce47c27
3
+ metadata.gz: 5ac5e5b95d6312d763f506e3ba5e5d60ae2da66a
4
+ data.tar.gz: 728de00cdd354de2f413f893e4f5c78aae180f06
5
5
  SHA512:
6
- metadata.gz: 5de7d8d72d5d1d2e31e473b20389160ebbbe51bec69f3014e7233b5c01ac0933f8aba117efc67b51747496cc2e6271bf7cb04cf2366f7f8db904e6c591093e74
7
- data.tar.gz: 038dc3a218c1661107d8f456f945990d3e79c0ac3b5b23e056b8d2e11a48301d5d501eb36cdee34be3cde59a022cffa6cfaedccb319be921a50a6bea6058ee62
6
+ metadata.gz: e42c4c453fddc8fecfbfc6a7974fd8bd8d6b427ee601fd151393850eb65d4e05d1096227abd76780a20c2f306346d2ff5067dc469abe042529a368e8c42c2ef1
7
+ data.tar.gz: 3ec51c75ca8e74654b86c2a31da27a58ccd5a272c08c976b766bd7de8440e5da316c7e091223a6a6ef30dc4122260a6c46744ddd5fc102f8c19d6917f43065e6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- juvet (0.0.2)
4
+ juvet (0.0.3)
5
5
  redis
6
6
 
7
7
  GEM
@@ -6,7 +6,7 @@ module Juvet
6
6
  attr_reader :type
7
7
 
8
8
  def initialize(options={})
9
- opts = (options || {}).dup
9
+ opts = default_options.merge((options || {}))
10
10
 
11
11
  @type = opts.delete :type
12
12
  @options = opts
@@ -20,6 +20,10 @@ module Juvet
20
20
 
21
21
  private
22
22
 
23
+ def default_options
24
+ { type: :null }.freeze
25
+ end
26
+
23
27
  def load_adapter
24
28
  require "juvet/adapters/#{type}_adapter"
25
29
  rescue LoadError => e
@@ -3,9 +3,7 @@ require_relative "configuration/mapping"
3
3
 
4
4
  module Juvet
5
5
  class Configuration
6
- attr_reader :adapter
7
-
8
- def adapter=(options)
6
+ def adapter(options=nil)
9
7
  @adapter ||= Juvet::Configuration::Adapter.new(options)
10
8
  end
11
9
 
data/lib/juvet/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Juvet
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/juvet.rb CHANGED
@@ -12,8 +12,8 @@ module Juvet
12
12
  @configuration ||= Juvet::Configuration.new
13
13
  end
14
14
 
15
- def self.configure
16
- yield configuration if block_given?
15
+ def self.configure(&block)
16
+ configuration.instance_eval(&block) if block_given?
17
17
  configuration.load!
18
18
  end
19
19
  end
@@ -20,6 +20,13 @@ describe Juvet::Configuration::Adapter do
20
20
  end
21
21
  end
22
22
 
23
+ describe "default options" do
24
+ it "has a null adapter type" do
25
+ expect(described_class.new.type).to eq :null
26
+ expect(described_class.new.class_name).to eq "NullAdapter"
27
+ end
28
+ end
29
+
23
30
  describe "#build" do
24
31
  let(:mapper) { double(:mapper, collection_for_repository: nil) }
25
32
  subject { described_class.new type: :null }
@@ -2,7 +2,6 @@ describe Juvet::Configuration do
2
2
  subject { described_class.new }
3
3
 
4
4
  it "has a default repository adapter" do
5
- subject.adapter = nil
6
5
  expect(subject.adapter).to be_instance_of Juvet::Configuration::Adapter
7
6
  end
8
7
 
@@ -13,11 +12,6 @@ describe Juvet::Configuration do
13
12
  describe "#load!" do
14
13
  subject { described_class.new }
15
14
 
16
- before(:each) do
17
- subject.adapter = { type: :null }
18
- subject.mapping do; end
19
- end
20
-
21
15
  it "builds the mapping" do
22
16
  expect(subject.mapping).to receive(:build).and_call_original
23
17
  subject.load!
data/spec/juvet_spec.rb CHANGED
@@ -16,5 +16,23 @@ describe Juvet do
16
16
  expect(described_class.configuration).to receive(:load!)
17
17
  described_class.configure
18
18
  end
19
+
20
+ it "sets up the adapter" do
21
+ described_class.configure do
22
+ adapter type: :null, blah: "blah"
23
+ end
24
+ expect(described_class.configuration.adapter).to be_instance_of Juvet::Configuration::Adapter
25
+ expect(described_class.configuration.adapter.type).to eq :null
26
+ expect(described_class.configuration.adapter.options).to eq({ blah: "blah" })
27
+ expect(described_class.configuration.adapter.class_name).to eq "NullAdapter"
28
+ end
29
+
30
+ it "sets up the mapping" do
31
+ described_class.configure do
32
+ mapping do
33
+ end
34
+ end
35
+ expect(described_class.configuration.mapping).to be_instance_of Juvet::Configuration::Mapping
36
+ end
19
37
  end
20
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: juvet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Wright
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-12 00:00:00.000000000 Z
11
+ date: 2016-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis