File tree 7 files changed +102
-2
lines changed
elasticsearch-persistence
7 files changed +102
-2
lines changed Original file line number Diff line number Diff line change @@ -21,9 +21,13 @@ Gem::Specification.new do |s|
21
21
s . extra_rdoc_files = [ "README.md" , "LICENSE.txt" ]
22
22
s . rdoc_options = [ "--charset=UTF-8" ]
23
23
24
+ s . add_dependency "elasticsearch" , '> 0.4'
25
+
24
26
s . add_development_dependency "bundler" , "~> 1.5"
25
27
s . add_development_dependency "rake"
26
28
29
+ s . add_development_dependency "elasticsearch-extensions"
30
+
27
31
s . add_development_dependency "shoulda-context"
28
32
s . add_development_dependency "mocha"
29
33
s . add_development_dependency "turn"
Original file line number Diff line number Diff line change 1
- require "elasticsearch/persistence/version"
1
+ require 'elasticsearch'
2
+
3
+ require 'elasticsearch/persistence/version'
4
+
5
+ require 'elasticsearch/persistence/client'
6
+ require 'elasticsearch/persistence/repository'
2
7
3
8
module Elasticsearch
4
9
module Persistence
5
- # Your code goes here...
10
+
11
+ # :nodoc:
12
+ module ClassMethods
13
+ def client
14
+ @client ||= Elasticsearch ::Client . new
15
+ end
16
+
17
+ def client = ( client )
18
+ @client = client
19
+ end
20
+ end
21
+
22
+ extend ClassMethods
6
23
end
7
24
end
Original file line number Diff line number Diff line change
1
+ module Elasticsearch
2
+ module Persistence
3
+
4
+ module Client
5
+ def client client = nil
6
+ @client ||= Elasticsearch ::Persistence . client
7
+ end
8
+
9
+ def client = ( client )
10
+ @client = client
11
+ end
12
+ end
13
+
14
+ end
15
+ end
Original file line number Diff line number Diff line change
1
+ module Elasticsearch
2
+ module Persistence
3
+
4
+ module Repository
5
+ include Elasticsearch ::Persistence ::Client
6
+ end
7
+ end
8
+ end
Original file line number Diff line number Diff line change
1
+ require 'test_helper'
2
+
3
+ class Elasticsearch ::Persistence ::ModuleTest < Test ::Unit ::TestCase
4
+ context "The Persistence module" do
5
+
6
+ context "client" do
7
+ should "have a default client" do
8
+ client = Elasticsearch ::Persistence . client
9
+ assert_not_nil client
10
+ assert_instance_of Elasticsearch ::Transport ::Client , client
11
+ end
12
+
13
+ should "allow to set a client" do
14
+ begin
15
+ Elasticsearch ::Persistence . client = "Foobar"
16
+ assert_equal "Foobar" , Elasticsearch ::Persistence . client
17
+ ensure
18
+ Elasticsearch ::Persistence . client = nil
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
Original file line number Diff line number Diff line change
1
+ require 'test_helper'
2
+
3
+ class Elasticsearch ::Persistence ::RepositoryClientTest < Test ::Unit ::TestCase
4
+ context "A repository client" do
5
+ class DummyReposistory
6
+ include Elasticsearch ::Persistence ::Repository
7
+ end
8
+
9
+ setup do
10
+ @shoulda_subject = DummyReposistory . new
11
+ end
12
+
13
+ should "have a default client" do
14
+ assert_not_nil subject . client
15
+ assert_instance_of Elasticsearch ::Transport ::Client , subject . client
16
+ end
17
+
18
+ should "allow to set a client" do
19
+ begin
20
+ subject . client = "Foobar"
21
+ assert_equal "Foobar" , subject . client
22
+ ensure
23
+ subject . client = nil
24
+ end
25
+ end
26
+ end
27
+ end
Original file line number Diff line number Diff line change
1
+ require 'test_helper'
2
+
3
+ class Elasticsearch ::Persistence ::RepositoryModuleTest < Test ::Unit ::TestCase
4
+ context "The repository module" do
5
+ end
6
+ end
You can’t perform that action at this time.
0 commit comments