es 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -35,6 +35,12 @@ module ES
35
35
  @dumper.load(response)
36
36
  end
37
37
 
38
+ def update(path, data)
39
+ serialized = @dumper.dump(data)
40
+ response = @client.update(path, serialized)
41
+ @dumper.load(response)
42
+ end
43
+
38
44
  def create_index(path, data)
39
45
  serialized = @dumper.dump(data)
40
46
  response = @client.create_index(path, serialized)
@@ -3,7 +3,7 @@ module ES
3
3
  def initialize(opts = {})
4
4
  @connection = opts[:connection] || begin
5
5
  host = opts[:host] || 'http://localhost:9200'
6
- driver = opts[:driver] || Curl
6
+ driver = opts[:driver] || Curl::Easy
7
7
  Connection.new(host, driver)
8
8
  end
9
9
  end
@@ -28,6 +28,10 @@ module ES
28
28
  @connection.request(:post, action_path(path, :search), query)
29
29
  end
30
30
 
31
+ def update(path, data)
32
+ @connection.request(:post, action_path(path, :update), data)
33
+ end
34
+
31
35
  def bulk(path, requests)
32
36
  @connection.request(:post, action_path(path, :bulk), requests)
33
37
  end
@@ -1,3 +1,3 @@
1
1
  module ES
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -44,4 +44,10 @@ describe ES::Client do
44
44
 
45
45
  subject.search('index/1', [1,2,3]).should == response
46
46
  end
47
+
48
+ it 'serializes data for .update' do
49
+ client.should_receive(:update).with('index/1', '[1,2,3]').and_return(raw_response)
50
+
51
+ subject.update('index/1', [1,2,3]).should == response
52
+ end
47
53
  end
@@ -53,4 +53,12 @@ describe ES::RawClient do
53
53
  subject.bulk('index', data).should == response
54
54
  end
55
55
  end
56
+
57
+ context '.update' do
58
+ it 'sends POST to connection' do
59
+ connection.should_receive(:request).with(:post, 'index/1/_update', data).and_return(response)
60
+
61
+ subject.update('index/1', data).should == response
62
+ end
63
+ end
56
64
  end
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: es
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jan Suchal
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-11 00:00:00.000000000 Z
12
+ date: 2013-06-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oj