elasticsearch-transport 0.4.7 → 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/README.md +1 -1
- data/elasticsearch-transport.gemspec +3 -2
- data/lib/elasticsearch/transport/transport/base.rb +1 -1
- data/lib/elasticsearch/transport/transport/http/curb.rb +1 -1
- data/lib/elasticsearch/transport/transport/http/faraday.rb +1 -1
- data/lib/elasticsearch/transport/version.rb +1 -1
- data/test/integration/transport_test.rb +9 -1
- data/test/test_helper.rb +16 -5
- data/test/unit/transport_base_test.rb +2 -2
- data/test/unit/transport_curb_test.rb +7 -2
- metadata +18 -2
data/Gemfile
CHANGED
@@ -2,3 +2,7 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in elasticsearch-transport.gemspec
|
4
4
|
gemspec
|
5
|
+
|
6
|
+
if File.exists? File.expand_path("../../elasticsearch-extensions", __FILE__)
|
7
|
+
gem 'elasticsearch-extensions', :path => File.expand_path("../../elasticsearch-extensions", __FILE__), :require => true
|
8
|
+
end
|
data/README.md
CHANGED
@@ -16,7 +16,7 @@ data serialization and transport.
|
|
16
16
|
It does not handle calling the Elasticsearch API;
|
17
17
|
see the [`elasticsearch-api`](https://github.com/elasticsearch/elasticsearch-ruby/tree/master/elasticsearch-api) library.
|
18
18
|
|
19
|
-
The library is compatible with Ruby 1.8.7 or higher.
|
19
|
+
The library is compatible with Ruby 1.8.7 or higher and with Elasticsearch 0.90 and 1.0.
|
20
20
|
|
21
21
|
Features overview:
|
22
22
|
|
@@ -43,7 +43,7 @@ Gem::Specification.new do |s|
|
|
43
43
|
s.add_development_dependency "ci_reporter"
|
44
44
|
|
45
45
|
# Gems for testing integrations
|
46
|
-
s.add_development_dependency "curb"
|
46
|
+
s.add_development_dependency "curb" unless defined? JRUBY_VERSION
|
47
47
|
s.add_development_dependency "typhoeus", '~> 0.6'
|
48
48
|
|
49
49
|
# Prevent unit test failures on Ruby 1.8
|
@@ -53,8 +53,9 @@ Gem::Specification.new do |s|
|
|
53
53
|
end
|
54
54
|
|
55
55
|
if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
|
56
|
-
s.add_development_dependency "ruby-prof"
|
56
|
+
s.add_development_dependency "ruby-prof" unless defined? JRUBY_VERSION
|
57
57
|
s.add_development_dependency "simplecov"
|
58
|
+
s.add_development_dependency "simplecov-rcov"
|
58
59
|
s.add_development_dependency "cane"
|
59
60
|
s.add_development_dependency "require-prof"
|
60
61
|
s.add_development_dependency "coveralls"
|
@@ -209,7 +209,7 @@ module Elasticsearch
|
|
209
209
|
raise e
|
210
210
|
end
|
211
211
|
|
212
|
-
json = serializer.load(response.body) if response.
|
212
|
+
json = serializer.load(response.body) if response.headers && response.headers["content-type"] =~ /json/
|
213
213
|
took = (json['took'] ? sprintf('%.3fs', json['took']/1000.0) : 'n/a') rescue 'n/a' if logger || tracer
|
214
214
|
duration = Time.now-start if logger || tracer
|
215
215
|
|
@@ -44,7 +44,7 @@ module Elasticsearch
|
|
44
44
|
|
45
45
|
client = ::Curl::Easy.new
|
46
46
|
client.resolve_mode = :ipv4
|
47
|
-
client.headers = {'User-Agent' => "Curb #{Curl::CURB_VERSION}"
|
47
|
+
client.headers = {'User-Agent' => "Curb #{Curl::CURB_VERSION}"}
|
48
48
|
client.url = __full_url(host)
|
49
49
|
|
50
50
|
if host[:user]
|
@@ -14,6 +14,14 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
|
|
14
14
|
require 'typhoeus'
|
15
15
|
require 'typhoeus/adapters/faraday'
|
16
16
|
|
17
|
+
# Fix for unreleased Typhoeus version (https://github.com/typhoeus/typhoeus/commit/00da90f)
|
18
|
+
#
|
19
|
+
class ::Faraday::Adapter::Typhoeus
|
20
|
+
def configure_ssl(req, env)
|
21
|
+
# noop
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
17
25
|
transport = Elasticsearch::Transport::Transport::HTTP::Faraday.new \
|
18
26
|
:hosts => [ { :host => 'localhost', :port => @port } ] do |f|
|
19
27
|
f.response :logger
|
@@ -35,7 +43,7 @@ class Elasticsearch::Transport::ClientIntegrationTest < Elasticsearch::Test::Int
|
|
35
43
|
|
36
44
|
client = Elasticsearch::Transport::Client.new transport: transport
|
37
45
|
client.perform_request 'GET', ''
|
38
|
-
end
|
46
|
+
end unless JRUBY
|
39
47
|
end
|
40
48
|
|
41
49
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
RUBY_1_8 = defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
|
2
|
+
JRUBY = defined?(JRUBY_VERSION)
|
2
3
|
|
3
4
|
if RUBY_1_8 and not ENV['BUNDLE_GEMFILE']
|
4
5
|
require 'rubygems'
|
@@ -7,7 +8,17 @@ end
|
|
7
8
|
|
8
9
|
require 'rubygems' if RUBY_1_8
|
9
10
|
|
10
|
-
|
11
|
+
if ENV['COVERAGE'] && ENV['CI'].nil? && !RUBY_1_8
|
12
|
+
require 'simplecov'
|
13
|
+
SimpleCov.start { add_filter "/test|test_/" }
|
14
|
+
end
|
15
|
+
|
16
|
+
if ENV['CI'] && !RUBY_1_8
|
17
|
+
require 'simplecov'
|
18
|
+
require 'simplecov-rcov'
|
19
|
+
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
|
20
|
+
SimpleCov.start { add_filter "/test|test_" }
|
21
|
+
end
|
11
22
|
|
12
23
|
# Register `at_exit` handler for integration tests shutdown.
|
13
24
|
# MUST be called before requiring `test/unit`.
|
@@ -30,7 +41,7 @@ RequireProf.print_timing_infos if ENV["REQUIRE_PROF"]
|
|
30
41
|
if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
|
31
42
|
require 'elasticsearch/extensions/test/cluster'
|
32
43
|
require 'elasticsearch/extensions/test/startup_shutdown'
|
33
|
-
require 'elasticsearch/extensions/test/profiling'
|
44
|
+
require 'elasticsearch/extensions/test/profiling' unless JRUBY
|
34
45
|
end
|
35
46
|
|
36
47
|
class Test::Unit::TestCase
|
@@ -46,7 +57,7 @@ module Elasticsearch
|
|
46
57
|
class IntegrationTestCase < ::Test::Unit::TestCase
|
47
58
|
extend Elasticsearch::Extensions::Test::StartupShutdown
|
48
59
|
|
49
|
-
shutdown { Elasticsearch::Extensions::Test::Cluster.stop if ENV['SERVER'] && started? }
|
60
|
+
shutdown { Elasticsearch::Extensions::Test::Cluster.stop if ENV['SERVER'] && started? && Elasticsearch::Extensions::Test::Cluster.running? }
|
50
61
|
context "IntegrationTest" do; should "noop on Ruby 1.8" do; end; end if RUBY_1_8
|
51
62
|
end if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
|
52
63
|
end
|
@@ -56,8 +67,8 @@ module Elasticsearch
|
|
56
67
|
extend Elasticsearch::Extensions::Test::StartupShutdown
|
57
68
|
extend Elasticsearch::Extensions::Test::Profiling
|
58
69
|
|
59
|
-
shutdown { Elasticsearch::Extensions::Test::Cluster.stop if ENV['SERVER'] && started? }
|
70
|
+
shutdown { Elasticsearch::Extensions::Test::Cluster.stop if ENV['SERVER'] && started? && Elasticsearch::Extensions::Test::Cluster.running? }
|
60
71
|
context "IntegrationTest" do; should "noop on Ruby 1.8" do; end; end if RUBY_1_8
|
61
|
-
end
|
72
|
+
end unless RUBY_1_8 || JRUBY
|
62
73
|
end
|
63
74
|
end
|
@@ -142,7 +142,7 @@ class Elasticsearch::Transport::Transport::BaseTest < Test::Unit::TestCase
|
|
142
142
|
@transport.serializer.expects(:load).returns({'foo' => 'bar'})
|
143
143
|
|
144
144
|
response = @transport.perform_request 'GET', '/' do
|
145
|
-
Elasticsearch::Transport::Transport::Response.new 200, '{"foo":"bar"}'
|
145
|
+
Elasticsearch::Transport::Transport::Response.new 200, '{"foo":"bar"}', {"content-type" => 'application/json'}
|
146
146
|
end
|
147
147
|
|
148
148
|
assert_instance_of Elasticsearch::Transport::Transport::Response, response
|
@@ -153,7 +153,7 @@ class Elasticsearch::Transport::Transport::BaseTest < Test::Unit::TestCase
|
|
153
153
|
@transport.expects(:get_connection).returns(stub_everything :failures => 1)
|
154
154
|
@transport.serializer.expects(:load).never
|
155
155
|
response = @transport.perform_request 'GET', '/' do
|
156
|
-
Elasticsearch::Transport::Transport::Response.new 200, 'FOOBAR'
|
156
|
+
Elasticsearch::Transport::Transport::Response.new 200, 'FOOBAR', {"content-type" => 'text/plain'}
|
157
157
|
end
|
158
158
|
|
159
159
|
assert_instance_of Elasticsearch::Transport::Transport::Response, response
|
@@ -1,3 +1,9 @@
|
|
1
|
+
if JRUBY
|
2
|
+
puts "'#{File.basename(__FILE__)}' not supported on JRuby #{RUBY_VERSION}"
|
3
|
+
exit(0)
|
4
|
+
end
|
5
|
+
|
6
|
+
|
1
7
|
require 'test_helper'
|
2
8
|
require 'elasticsearch/transport/transport/http/curb'
|
3
9
|
require 'curb'
|
@@ -64,8 +70,7 @@ class Elasticsearch::Transport::Transport::HTTP::FaradayTest < Test::Unit::TestC
|
|
64
70
|
curl.headers["User-Agent"] = "myapp-0.0"
|
65
71
|
end
|
66
72
|
|
67
|
-
assert_equal
|
68
|
-
transport.connections.first.connection.headers )
|
73
|
+
assert_equal "myapp-0.0", transport.connections.first.connection.headers["User-Agent"]
|
69
74
|
end
|
70
75
|
|
71
76
|
should "set the credentials if passed" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticsearch-transport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-02-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
@@ -267,6 +267,22 @@ dependencies:
|
|
267
267
|
- - ! '>='
|
268
268
|
- !ruby/object:Gem::Version
|
269
269
|
version: '0'
|
270
|
+
- !ruby/object:Gem::Dependency
|
271
|
+
name: simplecov-rcov
|
272
|
+
requirement: !ruby/object:Gem::Requirement
|
273
|
+
none: false
|
274
|
+
requirements:
|
275
|
+
- - ! '>='
|
276
|
+
- !ruby/object:Gem::Version
|
277
|
+
version: '0'
|
278
|
+
type: :development
|
279
|
+
prerelease: false
|
280
|
+
version_requirements: !ruby/object:Gem::Requirement
|
281
|
+
none: false
|
282
|
+
requirements:
|
283
|
+
- - ! '>='
|
284
|
+
- !ruby/object:Gem::Version
|
285
|
+
version: '0'
|
270
286
|
- !ruby/object:Gem::Dependency
|
271
287
|
name: cane
|
272
288
|
requirement: !ruby/object:Gem::Requirement
|