esnek 0.1.0 → 0.1.1
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.
- data/README.rdoc +2 -2
- data/lib/esnek/base.rb +4 -4
- data/lib/esnek/version.rb +1 -1
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -13,8 +13,8 @@ For the installation of elasticsearch please follow the guides at http://www.ela
|
|
13
13
|
== Usage:
|
14
14
|
|
15
15
|
require 'esnek'
|
16
|
-
es =
|
17
|
-
es._cluster.state
|
16
|
+
es = Esnek.new('http://localhost:9200')
|
17
|
+
es._cluster.state.get
|
18
18
|
|
19
19
|
== Notes
|
20
20
|
|
data/lib/esnek/base.rb
CHANGED
@@ -11,12 +11,12 @@ class Esnek
|
|
11
11
|
|
12
12
|
def method_missing(method_sym, *args, &block)
|
13
13
|
if [:get, :put, :post, :delete].include?(method_sym)
|
14
|
-
url = @url_root + @chain.map{|e| e[:
|
15
|
-
params = @chain.inject({}){|s,e| s.merge!(e[:params]) if e[:
|
14
|
+
url = @url_root.gsub(/\/$/,'') + '/' + @chain.map{|e| e[:method]}.join('/')
|
15
|
+
params = @chain.inject({}){|s,e| s.merge!(e[:arg][:params] || {}) if e[:arg].is_a?(Hash)}
|
16
16
|
@chain = []
|
17
|
-
OpenStruct.new JSON.parse RestClient.send(method_sym, url, {:params =>
|
17
|
+
OpenStruct.new JSON.parse RestClient.send(method_sym, url, {:params => params})
|
18
18
|
else
|
19
|
-
@chain << {:
|
19
|
+
@chain << {:method => method_sym, :arg => args[0] || {} }
|
20
20
|
self
|
21
21
|
end
|
22
22
|
end
|
data/lib/esnek/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ESNEK_VERSION='0.1.
|
1
|
+
ESNEK_VERSION='0.1.1'
|
metadata
CHANGED