esnek 0.0.1 → 0.1.0
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 -1
- data/lib/esnek/base.rb +30 -0
- data/lib/esnek/version.rb +1 -1
- data/lib/esnek.rb +0 -3
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
= Esnek
|
2
|
+
_UNDER HEAVY DEVELOPMENT IN APRIL 2011_
|
2
3
|
|
3
4
|
_Esnek_ provides a quick Ruby interface for JSON APIs, such as _ElasticSearch_ (http://www.elasticsearch.org); a scalable, fast, distributed,
|
4
5
|
highly-available, real time search RESTful search engine communicating by JSON over HTTP, based on _Lucene_ (http://lucene.apache.org).
|
@@ -12,7 +13,7 @@ For the installation of elasticsearch please follow the guides at http://www.ela
|
|
12
13
|
== Usage:
|
13
14
|
|
14
15
|
require 'esnek'
|
15
|
-
es = ElasticSearch.new('
|
16
|
+
es = ElasticSearch.new('http://localhost:9200')
|
16
17
|
es._cluster.state
|
17
18
|
|
18
19
|
== Notes
|
data/lib/esnek/base.rb
CHANGED
@@ -1,2 +1,32 @@
|
|
1
|
+
require 'rest_client'
|
2
|
+
require 'json'
|
3
|
+
require 'ostruct'
|
4
|
+
|
1
5
|
class Esnek
|
6
|
+
attr_accessor :chain, :url_root
|
7
|
+
def initialize(url_root)
|
8
|
+
@url_root = url_root
|
9
|
+
@chain = []
|
10
|
+
end
|
11
|
+
|
12
|
+
def method_missing(method_sym, *args, &block)
|
13
|
+
if [:get, :put, :post, :delete].include?(method_sym)
|
14
|
+
url = @url_root + @chain.map{|e| e[:met]}.join('/')
|
15
|
+
params = @chain.inject({}){|s,e| s.merge!(e[:params]) if e[:params].is_a?(Hash)}
|
16
|
+
@chain = []
|
17
|
+
OpenStruct.new JSON.parse RestClient.send(method_sym, url, {:params => {:q => 'search'}})
|
18
|
+
else
|
19
|
+
@chain << {:met => method_sym, :params => args}
|
20
|
+
self
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def respond_to?(method_sym)
|
25
|
+
if [:get, :put, :post, :delete].include?(method_sym)
|
26
|
+
true
|
27
|
+
else
|
28
|
+
super
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
2
32
|
end
|
data/lib/esnek/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ESNEK_VERSION='0.0
|
1
|
+
ESNEK_VERSION='0.1.0'
|
data/lib/esnek.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: esnek
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 0
|
9
8
|
- 1
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alper Akgun
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-18 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: json
|