elasticsearch-ruby 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm ruby-1.9.3@elasticsearch-ruby
@@ -21,7 +21,6 @@ Gem::Specification.new do |s|
21
21
  # = Library dependencies
22
22
  #
23
23
  s.add_dependency 'thrift'
24
- s.add_dependency 'faraday'
25
24
  s.add_dependency 'activesupport', ">= 3.0.0"
26
25
  s.add_development_dependency "rake"
27
26
  s.add_development_dependency "minitest"
@@ -4,7 +4,7 @@ module ElasticSearch
4
4
 
5
5
  def initialize(options)
6
6
  @body = options[:body].eql?("") ? "{}" : options[:body]
7
- @status = options[:status]
7
+ @status = options[:status].to_i
8
8
 
9
9
  case @status
10
10
  when 200..206
@@ -1,18 +1,30 @@
1
- require 'faraday'
1
+ require "net/http"
2
+ require "uri"
2
3
 
3
4
  module ElasticSearch
4
5
  class HTTPTransport < TransportBase
5
6
  def execute(request)
6
- response = current_connection.send(request.method, request.path) do |req|
7
- req.body = request.body unless request.method.eql?(:delete)
8
- req.params = request.parameters if request.parameters
9
- end
10
- ElasticSearch::Response.new(body: response.body, status: response.status)
7
+ query_string = "?#{request.parameters.to_query}" if request.parameters.is_a?(Hash)
8
+ http_request = get_class(request.method).new("#{request.path}#{query_string}")
9
+ http_request.body = request.body
10
+ response = current_connection.request(http_request)
11
+ ElasticSearch::Response.new(body: response.body, status: response.code)
11
12
  end
12
13
 
13
14
  private
14
15
  def get_connection(host)
15
- Faraday.new(:url => host)
16
+ uri = URI.parse(host)
17
+ Net::HTTP.new(uri.host, uri.port)
18
+ end
19
+
20
+ def get_class(method)
21
+ case method
22
+ when :get then Net::HTTP::Get
23
+ when :post then Net::HTTP::Post
24
+ when :put then Net::HTTP::Put
25
+ when :delete then Net::HTTP::Delete
26
+ when :head then Net::HTTP::Head
27
+ end
16
28
  end
17
29
  end
18
30
  end
@@ -1,3 +1,3 @@
1
1
  module ElasticSearch
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-16 00:00:00.000000000 Z
12
+ date: 2012-04-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thrift
16
- requirement: &70333353079280 !ruby/object:Gem::Requirement
16
+ requirement: &70256836637740 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,21 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70333353079280
25
- - !ruby/object:Gem::Dependency
26
- name: faraday
27
- requirement: &70333353078860 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: '0'
33
- type: :runtime
34
- prerelease: false
35
- version_requirements: *70333353078860
24
+ version_requirements: *70256836637740
36
25
  - !ruby/object:Gem::Dependency
37
26
  name: activesupport
38
- requirement: &70333353078200 !ruby/object:Gem::Requirement
27
+ requirement: &70256836637220 !ruby/object:Gem::Requirement
39
28
  none: false
40
29
  requirements:
41
30
  - - ! '>='
@@ -43,10 +32,10 @@ dependencies:
43
32
  version: 3.0.0
44
33
  type: :runtime
45
34
  prerelease: false
46
- version_requirements: *70333353078200
35
+ version_requirements: *70256836637220
47
36
  - !ruby/object:Gem::Dependency
48
37
  name: rake
49
- requirement: &70333353077540 !ruby/object:Gem::Requirement
38
+ requirement: &70256836636740 !ruby/object:Gem::Requirement
50
39
  none: false
51
40
  requirements:
52
41
  - - ! '>='
@@ -54,10 +43,10 @@ dependencies:
54
43
  version: '0'
55
44
  type: :development
56
45
  prerelease: false
57
- version_requirements: *70333353077540
46
+ version_requirements: *70256836636740
58
47
  - !ruby/object:Gem::Dependency
59
48
  name: minitest
60
- requirement: &70333353077040 !ruby/object:Gem::Requirement
49
+ requirement: &70256836636060 !ruby/object:Gem::Requirement
61
50
  none: false
62
51
  requirements:
63
52
  - - ! '>='
@@ -65,10 +54,10 @@ dependencies:
65
54
  version: '0'
66
55
  type: :development
67
56
  prerelease: false
68
- version_requirements: *70333353077040
57
+ version_requirements: *70256836636060
69
58
  - !ruby/object:Gem::Dependency
70
59
  name: turn
71
- requirement: &70333353076580 !ruby/object:Gem::Requirement
60
+ requirement: &70256836635620 !ruby/object:Gem::Requirement
72
61
  none: false
73
62
  requirements:
74
63
  - - ! '>='
@@ -76,7 +65,7 @@ dependencies:
76
65
  version: '0'
77
66
  type: :development
78
67
  prerelease: false
79
- version_requirements: *70333353076580
68
+ version_requirements: *70256836635620
80
69
  description: Ruby Driver for Elastic Search
81
70
  email:
82
71
  - edmund@edmundatwork.com
@@ -85,6 +74,7 @@ extensions: []
85
74
  extra_rdoc_files: []
86
75
  files:
87
76
  - .gitignore
77
+ - .rvmrc
88
78
  - Gemfile
89
79
  - Rakefile
90
80
  - elastic_search.gemspec