rubberband 0.0.7 → 0.0.8

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.
@@ -0,0 +1,12 @@
1
+ require "test_notifier/runner/autotest"
2
+
3
+ Autotest.add_hook(:initialize) {|at|
4
+ at.add_exception %r{^\.git} # ignore Version Control System
5
+ at.add_exception %r{^./tmp} # ignore temp files, lest autotest will run again, and again...
6
+ # at.clear_mappings # take out the default (test/test*rb)
7
+ at.add_mapping(%r{^lib/.*\.rb$}) {|f, _|
8
+ Dir['spec/**/*.rb']
9
+ }
10
+ nil
11
+ }
12
+
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format nested
2
+ --color
@@ -2,6 +2,7 @@ Maintainer:
2
2
  Grant Rodgers <grantr at gmail dot com>
3
3
 
4
4
  Contributors:
5
+ Edmund Salvacion
5
6
  Ernie Makris
6
7
  jeroig
7
8
  mootpointer
data/Gemfile CHANGED
@@ -4,8 +4,10 @@ gem "patron"
4
4
  gem "yajl-ruby"
5
5
 
6
6
  group :development do
7
- gem "shoulda", ">= 0"
8
7
  gem "bundler", "~> 1.0.0"
9
- gem "jeweler", "~> 1.5.1"
10
- gem "rcov", ">= 0"
8
+ gem "jeweler", "~> 1.5.2"
9
+ gem "simplecov", ">= 0.3.8", :require => false
10
+ gem "rspec", "~> 2.4"
11
+ gem "yard", "~> 0.6"
12
+ gem "mocha", "~> 0.9.11"
11
13
  end
@@ -1,24 +1,39 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ diff-lcs (1.1.2)
4
5
  git (1.2.5)
5
- jeweler (1.5.1)
6
+ jeweler (1.5.2)
6
7
  bundler (~> 1.0.0)
7
8
  git (>= 1.2.5)
8
9
  rake
10
+ mocha (0.9.11)
11
+ rake
9
12
  patron (0.4.10)
10
13
  rake (0.8.7)
11
- rcov (0.9.9)
12
- shoulda (2.11.3)
14
+ rspec (2.5.0)
15
+ rspec-core (~> 2.5.0)
16
+ rspec-expectations (~> 2.5.0)
17
+ rspec-mocks (~> 2.5.0)
18
+ rspec-core (2.5.1)
19
+ rspec-expectations (2.5.0)
20
+ diff-lcs (~> 1.1.2)
21
+ rspec-mocks (2.5.0)
22
+ simplecov (0.3.9)
23
+ simplecov-html (>= 0.3.7)
24
+ simplecov-html (0.3.9)
13
25
  yajl-ruby (0.7.8)
26
+ yard (0.6.4)
14
27
 
15
28
  PLATFORMS
16
29
  ruby
17
30
 
18
31
  DEPENDENCIES
19
32
  bundler (~> 1.0.0)
20
- jeweler (~> 1.5.1)
33
+ jeweler (~> 1.5.2)
34
+ mocha (~> 0.9.11)
21
35
  patron
22
- rcov
23
- shoulda
36
+ rspec (~> 2.4)
37
+ simplecov (>= 0.3.8)
24
38
  yajl-ruby
39
+ yard (~> 0.6)
data/Rakefile CHANGED
@@ -21,30 +21,20 @@ Jeweler::Tasks.new do |gem|
21
21
  gem.description = %Q{An ElasticSearch client with ThriftClient-like failover handling.}
22
22
  gem.email = "grantr@gmail.com"
23
23
  gem.authors = ["grantr"]
24
- end
25
- Jeweler::RubygemsDotOrgTasks.new
26
24
 
27
- require 'rake/testtask'
28
- Rake::TestTask.new(:test) do |test|
29
- test.libs << 'lib' << 'test'
30
- test.pattern = 'test/**/*_test.rb'
31
- test.verbose = true
25
+ gem.add_runtime_dependency 'patron'
26
+ gem.add_runtime_dependency 'yajl-ruby'
27
+ gem.add_development_dependency 'rspec', '~> 2.4'
32
28
  end
29
+ Jeweler::RubygemsDotOrgTasks.new
33
30
 
34
- require 'rcov/rcovtask'
35
- Rcov::RcovTask.new do |test|
36
- test.libs << 'test'
37
- test.pattern = 'test/**/test_*.rb'
38
- test.verbose = true
31
+ require 'rspec/core'
32
+ require 'rspec/core/rake_task'
33
+ RSpec::Core::RakeTask.new(:spec) do |spec|
34
+ spec.pattern = FileList['spec/**/*_spec.rb']
39
35
  end
40
36
 
41
- task :default => :test
37
+ task :default => :spec
42
38
 
43
- require 'rake/rdoctask'
44
- Rake::RDocTask.new do |rdoc|
45
- version = ElasticSearch::Version::STRING
46
- rdoc.rdoc_dir = 'rdoc'
47
- rdoc.title = "rubberband #{version}"
48
- rdoc.rdoc_files.include('README*')
49
- rdoc.rdoc_files.include('lib/**/*.rb')
50
- end
39
+ require 'yard'
40
+ YARD::Rake::YardocTask.new
@@ -8,7 +8,7 @@ module ElasticSearch
8
8
  else
9
9
  response = request(:put, {:index => index, :type => type, :id => id}, options, body)
10
10
  end
11
- handle_error(response) unless response.status == 200
11
+ handle_error(response) unless (response.status == 200 or response.status == 201)
12
12
  encoder.decode(response.body)
13
13
  end
14
14
 
@@ -2,7 +2,7 @@ module ElasticSearch
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- PATCH = 7
5
+ PATCH = 8
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rubberband}
8
- s.version = "0.0.7"
8
+ s.version = "0.0.8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["grantr"]
12
- s.date = %q{2011-02-08}
12
+ s.date = %q{2011-02-22}
13
13
  s.description = %q{An ElasticSearch client with ThriftClient-like failover handling.}
14
14
  s.email = %q{grantr@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -18,6 +18,8 @@ Gem::Specification.new do |s|
18
18
  "TODO"
19
19
  ]
20
20
  s.files = [
21
+ ".autotest",
22
+ ".rspec",
21
23
  "CONTRIBUTORS",
22
24
  "Gemfile",
23
25
  "Gemfile.lock",
@@ -50,12 +52,12 @@ Gem::Specification.new do |s|
50
52
  "lib/elasticsearch/version.rb",
51
53
  "lib/rubberband.rb",
52
54
  "rubberband.gemspec",
53
- "test/admin_test.rb",
54
- "test/elasticsearch_test.rb",
55
- "test/hits_test.rb",
56
- "test/index_test.rb",
57
- "test/test_helper.rb",
58
- "test/type_test.rb",
55
+ "spec/admin_spec.rb",
56
+ "spec/bulk_spec.rb",
57
+ "spec/hits_spec.rb",
58
+ "spec/index_spec.rb",
59
+ "spec/spec_helper.rb",
60
+ "spec/type_spec.rb",
59
61
  "vendor/elasticsearch/elasticsearch.thrift"
60
62
  ]
61
63
  s.homepage = %q{http://github.com/grantr/rubberband}
@@ -64,12 +66,12 @@ Gem::Specification.new do |s|
64
66
  s.rubygems_version = %q{1.3.7}
65
67
  s.summary = %q{An ElasticSearch client.}
66
68
  s.test_files = [
67
- "test/admin_test.rb",
68
- "test/elasticsearch_test.rb",
69
- "test/hits_test.rb",
70
- "test/index_test.rb",
71
- "test/test_helper.rb",
72
- "test/type_test.rb"
69
+ "spec/admin_spec.rb",
70
+ "spec/bulk_spec.rb",
71
+ "spec/hits_spec.rb",
72
+ "spec/index_spec.rb",
73
+ "spec/spec_helper.rb",
74
+ "spec/type_spec.rb"
73
75
  ]
74
76
 
75
77
  if s.respond_to? :specification_version then
@@ -79,25 +81,40 @@ Gem::Specification.new do |s|
79
81
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
80
82
  s.add_runtime_dependency(%q<patron>, [">= 0"])
81
83
  s.add_runtime_dependency(%q<yajl-ruby>, [">= 0"])
82
- s.add_development_dependency(%q<shoulda>, [">= 0"])
83
84
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
84
- s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
85
- s.add_development_dependency(%q<rcov>, [">= 0"])
85
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
86
+ s.add_development_dependency(%q<simplecov>, [">= 0.3.8"])
87
+ s.add_development_dependency(%q<rspec>, ["~> 2.4"])
88
+ s.add_development_dependency(%q<yard>, ["~> 0.6"])
89
+ s.add_development_dependency(%q<mocha>, ["~> 0.9.11"])
90
+ s.add_runtime_dependency(%q<patron>, [">= 0"])
91
+ s.add_runtime_dependency(%q<yajl-ruby>, [">= 0"])
92
+ s.add_development_dependency(%q<rspec>, ["~> 2.4"])
86
93
  else
87
94
  s.add_dependency(%q<patron>, [">= 0"])
88
95
  s.add_dependency(%q<yajl-ruby>, [">= 0"])
89
- s.add_dependency(%q<shoulda>, [">= 0"])
90
96
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
91
- s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
92
- s.add_dependency(%q<rcov>, [">= 0"])
97
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
98
+ s.add_dependency(%q<simplecov>, [">= 0.3.8"])
99
+ s.add_dependency(%q<rspec>, ["~> 2.4"])
100
+ s.add_dependency(%q<yard>, ["~> 0.6"])
101
+ s.add_dependency(%q<mocha>, ["~> 0.9.11"])
102
+ s.add_dependency(%q<patron>, [">= 0"])
103
+ s.add_dependency(%q<yajl-ruby>, [">= 0"])
104
+ s.add_dependency(%q<rspec>, ["~> 2.4"])
93
105
  end
94
106
  else
95
107
  s.add_dependency(%q<patron>, [">= 0"])
96
108
  s.add_dependency(%q<yajl-ruby>, [">= 0"])
97
- s.add_dependency(%q<shoulda>, [">= 0"])
98
109
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
99
- s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
100
- s.add_dependency(%q<rcov>, [">= 0"])
110
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
111
+ s.add_dependency(%q<simplecov>, [">= 0.3.8"])
112
+ s.add_dependency(%q<rspec>, ["~> 2.4"])
113
+ s.add_dependency(%q<yard>, ["~> 0.6"])
114
+ s.add_dependency(%q<mocha>, ["~> 0.9.11"])
115
+ s.add_dependency(%q<patron>, [">= 0"])
116
+ s.add_dependency(%q<yajl-ruby>, [">= 0"])
117
+ s.add_dependency(%q<rspec>, ["~> 2.4"])
101
118
  end
102
119
  end
103
120
 
@@ -0,0 +1,21 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "basic ops" do
4
+ before(:all) do
5
+ @first_index = 'first-' + Time.now.to_i.to_s
6
+ @client = ElasticSearch.new('127.0.0.1:9200', :index => @first_index, :type => "tweet")
7
+ end
8
+
9
+ after(:all) do
10
+ @client.delete_index(@first_index)
11
+ sleep(1)
12
+ end
13
+
14
+ it "should get and update mappings" do
15
+ @client.index({:foo => "bar"}, :id => "1", :refresh => true)
16
+
17
+ @client.index_mapping(@first_index).should == {@first_index => {"tweet" => { "properties" => { "foo" => {"type" => "string" }}}}}
18
+ @client.update_mapping({"tweet" => {:properties => {:bar => {:type => "string"}}}})
19
+ @client.index_mapping(@first_index).should == {@first_index => {"tweet" => { "properties" => { "foo" => {"type" => "string" }, "bar" => { "type" => "string"}}}}}
20
+ end
21
+ end
@@ -0,0 +1,30 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "bulk ops" do
4
+ before(:all) do
5
+ @index = 'first-' + Time.now.to_i.to_s
6
+ @client = ElasticSearch.new('127.0.0.1:9200', :index => @index, :type => "tweet")
7
+ end
8
+
9
+ after(:all) do
10
+ @client.delete_index(@index)
11
+ sleep(1)
12
+ end
13
+
14
+ it "should index documents in bulk" do
15
+ @client.bulk do |c|
16
+ c.index({:foo => 'bar'}, :id => '1')
17
+ c.index({:foo => 'baz'}, :id => '2')
18
+ end
19
+ @client.bulk do
20
+ @client.index({:socks => 'stripey'}, :id => '3')
21
+ @client.index({:socks => 'argyle'}, :id => '4')
22
+ end
23
+ @client.refresh
24
+
25
+ @client.get("1").foo.should == "bar"
26
+ @client.get("2").foo.should == "baz"
27
+ @client.get("3").socks.should == "stripey"
28
+ @client.get("4").socks.should == "argyle"
29
+ end
30
+ end
@@ -0,0 +1,79 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe ElasticSearch::Api::Hit do
4
+ let(:response) { {"_source" => {"foo" => "bar"}, "_id" => "1"} }
5
+
6
+ subject { described_class.new(response) }
7
+
8
+ its(:id) { should == response["_id"] }
9
+
10
+ its(:attributes) { should be_frozen }
11
+
12
+ it "should set hit attributes" do
13
+ subject.foo.should == response["_source"]["foo"]
14
+ end
15
+ end
16
+
17
+ describe ElasticSearch::Api::Hits do
18
+ context "unpaginated" do
19
+ let(:response) do
20
+ {
21
+ "_shards"=>{"total"=>30, "successful"=>30, "failed"=>0},
22
+ "hits"=>{"total"=>2, "max_score"=>1.0, "hits"=>[
23
+ {"_index"=>"test_index", "_type"=>"test_type", "_id"=>"1", "_score"=>1.0, "_source"=>{"foo" => "bar"}},
24
+ {"_index"=>"test_index", "_type"=>"test_type", "_id"=>"2", "_score"=>1.0, "_source"=>{"foo" => "baz"}}
25
+ ]}}
26
+ end
27
+
28
+ subject { described_class.new(response) }
29
+
30
+ it { should respond_to(:response) }
31
+
32
+ its(:total_entries) { should == response["hits"]["hits"].size }
33
+
34
+ it "should instantiate hits in order" do
35
+ response["hits"]["hits"].each_with_index do |hit, i|
36
+ subject.hits[i].should == ElasticSearch::Api::Hit.new(hit)
37
+ end
38
+ end
39
+
40
+
41
+ it "should freeze all hits" do
42
+ subject.hits.all? { |h| h.frozen? }.should be_true
43
+ end
44
+
45
+ it "should freeze hits array when frozen" do
46
+ subject.freeze
47
+ subject.hits.should be_frozen
48
+ end
49
+
50
+ it { should respond_to(:to_a) }
51
+
52
+ it "should delegate array methods" do
53
+ subject.collect { |h| h.id }.should == response["hits"]["hits"].collect { |h| h["_id"] }
54
+ end
55
+
56
+ end
57
+
58
+ context "paginated" do
59
+ let(:response) do
60
+ {
61
+ "_shards"=>{"total"=>30, "successful"=>30, "failed"=>0},
62
+ "hits"=>{"total"=>6, "max_score"=>1.0, "hits"=>[
63
+ {"_index"=>"test_index", "_type"=>"test_type", "_id"=>"3", "_score"=>1.0, "_source"=>{"foo" => "bar"}},
64
+ {"_index"=>"test_index", "_type"=>"test_type", "_id"=>"4", "_score"=>1.0, "_source"=>{"foo" => "baz"}}
65
+ ]}}
66
+ end
67
+
68
+ let(:per_page) { 2 }
69
+ let(:page) { 2 }
70
+
71
+ subject { described_class.new(response, {:page => page, :per_page => per_page}) }
72
+
73
+ its(:total_pages) { should == (response["hits"]["total"] / per_page.to_f).ceil }
74
+ its(:next_page) { should == (page + 1) }
75
+ its(:previous_page) { should == (page - 1) }
76
+ its(:current_page) { should == page }
77
+ its(:per_page) { should == per_page }
78
+ end
79
+ end
@@ -0,0 +1,34 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "index ops" do
4
+ before(:all) do
5
+ @first_index = 'first-' + Time.now.to_i.to_s
6
+ @client = ElasticSearch.new('127.0.0.1:9200', :index => @first_index, :type => "tweet")
7
+ end
8
+
9
+ after(:all) do
10
+ @client.delete_index(@first_index)
11
+ sleep(1)
12
+ end
13
+
14
+ it "should get and delete a document" do
15
+ @client.index({:foo => "bar"}, :id => "1", :refresh => true)
16
+
17
+ @client.get("1").foo.should == "bar"
18
+ @client.delete("1", :refresh => true).should be_true
19
+ @client.get("1").should be_nil
20
+ end
21
+
22
+ it 'should search and count documents' do
23
+ @client.index({:foo => "bar"}, :id => "1")
24
+ @client.index({:foo => "baz"}, :id => "2")
25
+ @client.index({:foo => "baz also"}, :id => "3")
26
+ @client.refresh(@first_index)
27
+
28
+ @client.search("bar").should have(1).items
29
+ @client.count("bar").should == 1
30
+
31
+ @client.search(:query => { :term => { :foo => 'baz' }}).should have(2).items
32
+ @client.count(:term => { :foo => 'baz' }).should == 2
33
+ end
34
+ end
@@ -0,0 +1,20 @@
1
+ if RUBY_VERSION =~ /^1\.9/
2
+ require 'simplecov'
3
+ SimpleCov.start do
4
+ add_filter '/spec/'
5
+ add_filter '/features/'
6
+ end
7
+ end
8
+
9
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
10
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
11
+ require 'rspec'
12
+ require 'rubberband'
13
+
14
+ # Requires supporting files with custom matchers and macros, etc,
15
+ # in ./support/ and its subdirectories.
16
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
17
+
18
+ RSpec.configure do |config|
19
+ config.mock_with :mocha
20
+ end
@@ -0,0 +1,46 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "type and index parameters" do
4
+ before(:all) do
5
+ @first_index = 'first-' + Time.now.to_i.to_s
6
+ @second_index = 'second-' + Time.now.to_i.to_s
7
+ @third_index = 'third-' + Time.now.to_i.to_s
8
+ @username = 'kimchy' + Time.now.to_i.to_s
9
+ @client = ElasticSearch.new('127.0.0.1:9200', :index => @first_index, :type => "tweet")
10
+ @client.index({:user => @username}, :id => 1)
11
+ @client.index({:user => @username}, :id => 2, :type => "grillo")
12
+ @client.index({:user => @username}, :id => 3, :type => "cote")
13
+ @client.index({:user => @username}, :id => 4, :index => @second_index, :type => "cote")
14
+ @client.index({:user => @username}, :id => 5, :index => @third_index, :type => "mencho")
15
+ @client.index({:user => @username}, :id => 6, :index => @third_index, :type => "cote")
16
+ @client.refresh(@first_index, @second_index, @third_index)
17
+ end
18
+
19
+ after(:all) do
20
+ @client.delete_index(@first_index)
21
+ @client.delete_index(@second_index)
22
+ @client.delete_index(@third_index)
23
+ sleep(1)
24
+ end
25
+
26
+ it "should search in all indexes" do
27
+ @client.count(@username,{:index => "", :type => ""}).should == 6
28
+ end
29
+
30
+ it "should search in all types with index first" do
31
+ @client.count(@username,{:index => @first_index, :type => ""}).should == 3
32
+ end
33
+
34
+ it "should search in first index with types tweet,cote" do
35
+ @client.count(@username,{:index => @first_index, :type => "tweet,cote"}).should == 2
36
+ end
37
+
38
+ it "should search in index first and second" do
39
+ @first_and_second = @first_index + ',' + @second_index
40
+ @client.count(@username,{:index => @first_and_second, :type => ""}).should == 4
41
+ end
42
+
43
+ it "should search in types grillo,cote of all indexes" do
44
+ @client.count(@username,{:index => "", :type => "grillo,cote"}).should == 4
45
+ end
46
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 7
9
- version: 0.0.7
8
+ - 8
9
+ version: 0.0.8
10
10
  platform: ruby
11
11
  authors:
12
12
  - grantr
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-02-08 00:00:00 -08:00
17
+ date: 2011-02-22 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -44,20 +44,22 @@ dependencies:
44
44
  prerelease: false
45
45
  version_requirements: *id002
46
46
  - !ruby/object:Gem::Dependency
47
- name: shoulda
47
+ name: bundler
48
48
  requirement: &id003 !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
- - - ">="
51
+ - - ~>
52
52
  - !ruby/object:Gem::Version
53
53
  segments:
54
+ - 1
54
55
  - 0
55
- version: "0"
56
+ - 0
57
+ version: 1.0.0
56
58
  type: :development
57
59
  prerelease: false
58
60
  version_requirements: *id003
59
61
  - !ruby/object:Gem::Dependency
60
- name: bundler
62
+ name: jeweler
61
63
  requirement: &id004 !ruby/object:Gem::Requirement
62
64
  none: false
63
65
  requirements:
@@ -65,30 +67,86 @@ dependencies:
65
67
  - !ruby/object:Gem::Version
66
68
  segments:
67
69
  - 1
68
- - 0
69
- - 0
70
- version: 1.0.0
70
+ - 5
71
+ - 2
72
+ version: 1.5.2
71
73
  type: :development
72
74
  prerelease: false
73
75
  version_requirements: *id004
74
76
  - !ruby/object:Gem::Dependency
75
- name: jeweler
77
+ name: simplecov
76
78
  requirement: &id005 !ruby/object:Gem::Requirement
77
79
  none: false
78
80
  requirements:
79
- - - ~>
81
+ - - ">="
80
82
  - !ruby/object:Gem::Version
81
83
  segments:
82
- - 1
83
- - 5
84
- - 1
85
- version: 1.5.1
84
+ - 0
85
+ - 3
86
+ - 8
87
+ version: 0.3.8
86
88
  type: :development
87
89
  prerelease: false
88
90
  version_requirements: *id005
89
91
  - !ruby/object:Gem::Dependency
90
- name: rcov
92
+ name: rspec
91
93
  requirement: &id006 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ segments:
99
+ - 2
100
+ - 4
101
+ version: "2.4"
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: *id006
105
+ - !ruby/object:Gem::Dependency
106
+ name: yard
107
+ requirement: &id007 !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ~>
111
+ - !ruby/object:Gem::Version
112
+ segments:
113
+ - 0
114
+ - 6
115
+ version: "0.6"
116
+ type: :development
117
+ prerelease: false
118
+ version_requirements: *id007
119
+ - !ruby/object:Gem::Dependency
120
+ name: mocha
121
+ requirement: &id008 !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ~>
125
+ - !ruby/object:Gem::Version
126
+ segments:
127
+ - 0
128
+ - 9
129
+ - 11
130
+ version: 0.9.11
131
+ type: :development
132
+ prerelease: false
133
+ version_requirements: *id008
134
+ - !ruby/object:Gem::Dependency
135
+ name: patron
136
+ requirement: &id009 !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ segments:
142
+ - 0
143
+ version: "0"
144
+ type: :runtime
145
+ prerelease: false
146
+ version_requirements: *id009
147
+ - !ruby/object:Gem::Dependency
148
+ name: yajl-ruby
149
+ requirement: &id010 !ruby/object:Gem::Requirement
92
150
  none: false
93
151
  requirements:
94
152
  - - ">="
@@ -96,9 +154,23 @@ dependencies:
96
154
  segments:
97
155
  - 0
98
156
  version: "0"
157
+ type: :runtime
158
+ prerelease: false
159
+ version_requirements: *id010
160
+ - !ruby/object:Gem::Dependency
161
+ name: rspec
162
+ requirement: &id011 !ruby/object:Gem::Requirement
163
+ none: false
164
+ requirements:
165
+ - - ~>
166
+ - !ruby/object:Gem::Version
167
+ segments:
168
+ - 2
169
+ - 4
170
+ version: "2.4"
99
171
  type: :development
100
172
  prerelease: false
101
- version_requirements: *id006
173
+ version_requirements: *id011
102
174
  description: An ElasticSearch client with ThriftClient-like failover handling.
103
175
  email: grantr@gmail.com
104
176
  executables: []
@@ -110,6 +182,8 @@ extra_rdoc_files:
110
182
  - README.rdoc
111
183
  - TODO
112
184
  files:
185
+ - .autotest
186
+ - .rspec
113
187
  - CONTRIBUTORS
114
188
  - Gemfile
115
189
  - Gemfile.lock
@@ -142,12 +216,12 @@ files:
142
216
  - lib/elasticsearch/version.rb
143
217
  - lib/rubberband.rb
144
218
  - rubberband.gemspec
145
- - test/admin_test.rb
146
- - test/elasticsearch_test.rb
147
- - test/hits_test.rb
148
- - test/index_test.rb
149
- - test/test_helper.rb
150
- - test/type_test.rb
219
+ - spec/admin_spec.rb
220
+ - spec/bulk_spec.rb
221
+ - spec/hits_spec.rb
222
+ - spec/index_spec.rb
223
+ - spec/spec_helper.rb
224
+ - spec/type_spec.rb
151
225
  - vendor/elasticsearch/elasticsearch.thrift
152
226
  has_rdoc: true
153
227
  homepage: http://github.com/grantr/rubberband
@@ -163,7 +237,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
163
237
  requirements:
164
238
  - - ">="
165
239
  - !ruby/object:Gem::Version
166
- hash: -4380067439050607353
240
+ hash: 2137179161715678959
167
241
  segments:
168
242
  - 0
169
243
  version: "0"
@@ -183,9 +257,9 @@ signing_key:
183
257
  specification_version: 3
184
258
  summary: An ElasticSearch client.
185
259
  test_files:
186
- - test/admin_test.rb
187
- - test/elasticsearch_test.rb
188
- - test/hits_test.rb
189
- - test/index_test.rb
190
- - test/test_helper.rb
191
- - test/type_test.rb
260
+ - spec/admin_spec.rb
261
+ - spec/bulk_spec.rb
262
+ - spec/hits_spec.rb
263
+ - spec/index_spec.rb
264
+ - spec/spec_helper.rb
265
+ - spec/type_spec.rb
@@ -1,25 +0,0 @@
1
- require 'test_helper'
2
-
3
- class BasicTest < Test::Unit::TestCase
4
- context "basic ops" do
5
-
6
- setup do
7
- @first_index = 'first-' + Time.now.to_i.to_s
8
- @client = ElasticSearch.new('127.0.0.1:9200', :index => @first_index, :type => "tweet")
9
- end
10
-
11
- teardown do
12
- @client.delete_index(@first_index)
13
- sleep(1)
14
- end
15
-
16
- #TODO this test fails randomly, there's some kind of timing issue here
17
- should "get and update mappings" do
18
- @client.index({:foo => "bar"}, :id => "1", :refresh => true)
19
-
20
- assert_equal({@first_index => {"tweet" => { "properties" => { "foo" => {"type" => "string" }}}}}, @client.index_mapping(@first_index))
21
- @client.update_mapping({"tweet" => {:properties => {:bar => {:type => "string"}}}})
22
- assert_equal({@first_index => {"tweet" => { "properties" => { "foo" => {"type" => "string" }, "bar" => { "type" => "string"}}}}}, @client.index_mapping(@first_index))
23
- end
24
- end
25
- end
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ElasticSearchTest < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- #flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end
@@ -1,101 +0,0 @@
1
- require 'test_helper'
2
-
3
- class HitsTest < Test::Unit::TestCase
4
- context "A Hit instance" do
5
- setup do
6
- @response = {"_source" => {"foo" => "bar"}, "_id" => "1"}
7
- @hit = ElasticSearch::Api::Hit.new(@response)
8
- end
9
-
10
- should "set id" do
11
- assert_equal @response["_id"], @hit.id
12
- end
13
-
14
- should "set hit attributes" do
15
- assert_equal @response["_source"]["foo"], @hit.foo
16
- end
17
-
18
- should "be frozen" do
19
- assert @hit.attributes.frozen?
20
- end
21
-
22
- end
23
-
24
- context "A Hits instance" do
25
- setup do
26
- @response = {
27
- "_shards"=>{"total"=>30, "successful"=>30, "failed"=>0},
28
- "hits"=>{"total"=>2, "max_score"=>1.0, "hits"=>[
29
- {"_index"=>"test_index", "_type"=>"test_type", "_id"=>"1", "_score"=>1.0, "_source"=>{"foo" => "bar"}},
30
- {"_index"=>"test_index", "_type"=>"test_type", "_id"=>"2", "_score"=>1.0, "_source"=>{"foo" => "baz"}}
31
- ]}}
32
- @hits = ElasticSearch::Api::Hits.new(@response)
33
- end
34
-
35
- should "set response" do
36
- assert_equal @response, @hits.response
37
- end
38
-
39
- should "set total_entries" do
40
- assert_equal @response["hits"]["hits"].size, @hits.total_entries
41
- end
42
-
43
- should "instantiate hits in order" do
44
- @response["hits"]["hits"].each_with_index do |hit, i|
45
- assert_equal ElasticSearch::Api::Hit.new(hit), @hits.hits[i]
46
- end
47
- end
48
-
49
- should "freeze hits" do
50
- assert @hits.hits.all? { |h| h.frozen? }
51
- end
52
-
53
- should "freeze hits array when frozen" do
54
- @hits.freeze
55
- assert @hits.hits.frozen?
56
- end
57
-
58
- should "respond to to_a" do
59
- assert_equal @hits.hits, @hits.to_a
60
- end
61
-
62
- should "respond to array methods" do
63
- assert @hits.respond_to?(:collect)
64
- assert_equal @response["hits"]["hits"].collect { |h| h["_id"] }, @hits.collect { |h| h.id }
65
- end
66
- end
67
-
68
- context "a paginated hits instance" do
69
- setup do
70
- @response = {
71
- "_shards"=>{"total"=>30, "successful"=>30, "failed"=>0},
72
- "hits"=>{"total"=>6, "max_score"=>1.0, "hits"=>[
73
- {"_index"=>"test_index", "_type"=>"test_type", "_id"=>"3", "_score"=>1.0, "_source"=>{"foo" => "bar"}},
74
- {"_index"=>"test_index", "_type"=>"test_type", "_id"=>"4", "_score"=>1.0, "_source"=>{"foo" => "baz"}}
75
- ]}}
76
- @per_page = 2
77
- @page = 2
78
- @hits = ElasticSearch::Api::Hits.new(@response, {:page => @page, :per_page => @per_page})
79
- end
80
-
81
- should "respond to total_pages" do
82
- assert_equal (@response["hits"]["total"] / @per_page.to_f).ceil, @hits.total_pages
83
- end
84
-
85
- should "respond to next_page" do
86
- assert_equal @page + 1, @hits.next_page
87
- end
88
-
89
- should "respond to previous_page" do
90
- assert_equal @page - 1, @hits.previous_page
91
- end
92
-
93
- should "respond to current_page" do
94
- assert_equal @page, @hits.current_page
95
- end
96
-
97
- should "respond to per page" do
98
- assert_equal @per_page, @hits.per_page
99
- end
100
- end
101
- end
@@ -1,35 +0,0 @@
1
- require 'test_helper'
2
-
3
- class IndexTest < Test::Unit::TestCase
4
- context "index ops" do
5
-
6
- setup do
7
- @first_index = 'first-' + Time.now.to_i.to_s
8
- @client = ElasticSearch.new('127.0.0.1:9200', :index => @first_index, :type => "tweet")
9
- end
10
-
11
- teardown do
12
- @client.delete_index(@first_index)
13
- sleep(1)
14
- end
15
-
16
- should "do basic ops on a document" do
17
- @client.index({:foo => "bar"}, :id => "1", :refresh => true)
18
-
19
- assert_equal "bar", @client.get("1").foo
20
- assert_equal true, @client.delete("1", :refresh => true)
21
- assert_equal nil, @client.get("1")
22
-
23
- @client.index({:foo => "bar"}, :id => "1")
24
- @client.index({:foo => "baz"}, :id => "2")
25
- @client.index({:foo => "baz also"}, :id => "3")
26
- @client.refresh(@first_index)
27
-
28
- assert_equal 1, @client.search("bar").size
29
- assert_equal 1, @client.count("bar")
30
-
31
- assert_equal 2, @client.search(:query => { :term => { :foo => 'baz' }}).size
32
- assert_equal 2, @client.count(:term => { :foo => 'baz' })
33
- end
34
- end
35
- end
@@ -1,10 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
-
5
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
- $LOAD_PATH.unshift(File.dirname(__FILE__))
7
- require 'elasticsearch'
8
-
9
- class Test::Unit::TestCase
10
- end
@@ -1,47 +0,0 @@
1
- require 'test_helper'
2
-
3
- class TypeTest < Test::Unit::TestCase
4
- context "Test with differents Types" do
5
-
6
- setup do
7
- @first_index = 'first-' + Time.now.to_i.to_s
8
- @second_index = 'second-' + Time.now.to_i.to_s
9
- @third_index = 'third-' + Time.now.to_i.to_s
10
- @username = 'kimchy' + Time.now.to_i.to_s
11
- @client = ElasticSearch.new('127.0.0.1:9200', :index => @first_index, :type => "tweet")
12
- @client.index({:user => @username}, :id => 1)
13
- @client.index({:user => @username}, :id => 2, :type => "grillo")
14
- @client.index({:user => @username}, :id => 3, :type => "cote")
15
- @client.index({:user => @username}, :id => 4, :index => @second_index, :type => "cote")
16
- @client.index({:user => @username}, :id => 5, :index => @third_index, :type => "mencho")
17
- @client.index({:user => @username}, :id => 6, :index => @third_index, :type => "cote")
18
- @client.refresh(@first_index, @second_index, @third_index)
19
- end
20
-
21
- teardown do
22
- @client.delete_index(@first_index)
23
- @client.delete_index(@second_index)
24
- @client.delete_index(@third_index)
25
- sleep(1)
26
- end
27
-
28
- should "Test different stages using indexes and types" do
29
- # Search in all indexes
30
- assert_equal @client.count(@username,{:index => "", :type => ""}), 6
31
-
32
- # Search in all types with index first
33
- assert_equal @client.count(@username,{:index => @first_index, :type => ""}), 3
34
-
35
- # Search in first index with types tweet,cote
36
- assert_equal @client.count(@username,{:index => @first_index, :type => "tweet,cote"}), 2
37
-
38
- # Search in index first and second
39
- @first_and_second = @first_index + ',' + @second_index
40
- assert_equal @client.count(@username,{:index => @first_and_second, :type => ""}), 4
41
-
42
- # Search in types grillo,cote of all indexes" do
43
- assert_equal @client.count(@username,{:index => "", :type => "grillo,cote"}), 4
44
- end
45
-
46
- end
47
- end