esapiserver 0.0.5 → 0.0.6
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.
- checksums.yaml +4 -4
- data/lib/esapiserver.rb +11 -5
- data/lib/esapiserver/version.rb +1 -1
- data/spec/esapiserver_spec.rb +5 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10db36d732326c30b1ea10d9a4508ae74d69cbed
|
4
|
+
data.tar.gz: 20b8649043caa2e7be49d4ac46d8096a5a898a2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 262b1ee728134ed4e3e2295b85c32e4a8a91473b5538395f60f58e082900cf53a298e43f1afffde663eeb871ce52994bce7410d5ee53357576c3b4123e165128
|
7
|
+
data.tar.gz: 8612b62082502e511729ea1c0ad2ae963041ab0e11de12344a55eb7eb2963f4084d0b68cadb1bf6dea3575c79e5bba7181ef6077adb6f0e2633732e57c631e86
|
data/lib/esapiserver.rb
CHANGED
@@ -79,15 +79,14 @@ module Esapiserver
|
|
79
79
|
if request.query_string.empty?
|
80
80
|
result = collection.find.to_a.map{|t| fromBsonId(t, params[:model])}.to_json
|
81
81
|
else
|
82
|
-
if request.query_string.include? 'ids[]' or request.query_string.include? 'ids%5B%5D'
|
82
|
+
if request.query_string.include? 'ids[]' or request.query_string.include? 'ids%5B%5D'
|
83
83
|
ids = []
|
84
|
-
|
85
84
|
if request.query_string.include? '&'
|
86
85
|
queries = request.query_string.split('&')
|
87
86
|
queries.each do |q|
|
88
87
|
key, value = q.split('=')
|
89
|
-
if key != 'ids[]' and key != 'ids%5B%5D'
|
90
|
-
throw 'multiple query parameters
|
88
|
+
if key != 'ids[]' and key != 'ids%5B%5D'
|
89
|
+
throw 'multiple query parameters that also have _ids[]= parameters not supported yet'
|
91
90
|
end
|
92
91
|
ids << toBsonId(value)
|
93
92
|
end
|
@@ -97,7 +96,14 @@ module Esapiserver
|
|
97
96
|
end
|
98
97
|
query = {"_id" => { "$in" => ids }}
|
99
98
|
elsif request.query_string.include? '&'
|
100
|
-
|
99
|
+
conditions = []
|
100
|
+
queries = request.query_string.split('&')
|
101
|
+
queries.each do |q|
|
102
|
+
key, value = q.split('=')
|
103
|
+
conditions << {modelName(params[:model]) + "." + key => value}
|
104
|
+
end
|
105
|
+
query = {"$and" => conditions }
|
106
|
+
puts query
|
101
107
|
else
|
102
108
|
key, value = request.query_string.split('=')
|
103
109
|
query = {modelName(params[:model]) + "." + key => value}
|
data/lib/esapiserver/version.rb
CHANGED
data/spec/esapiserver_spec.rb
CHANGED
@@ -41,7 +41,7 @@ describe 'esapiserver that' do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
#http://127.0.0.1:4567/api/focusareas?ids%5B%5D=53d7781819cfd232f4000085&ids%5B%5D=53d778e319cfd232f4000087
|
44
|
-
it 'returns a list of models that matches a
|
44
|
+
it 'returns a list of models that matches a list of ids' do
|
45
45
|
#create another post
|
46
46
|
payload = '{"post": {"name": "test1"}}'
|
47
47
|
post '/api/posts', payload, "CONTENT_TYPE" => "application/json"
|
@@ -61,6 +61,10 @@ describe 'esapiserver that' do
|
|
61
61
|
#TODO should check to see if it is parsable by json
|
62
62
|
end
|
63
63
|
|
64
|
+
it 'returns a list of models that matches a specific query' do
|
65
|
+
pending
|
66
|
+
end
|
67
|
+
|
64
68
|
#http://localhost:4567/api/posts?name=test1
|
65
69
|
it 'returns a model with a specific key/value' do
|
66
70
|
get '/api/posts?name=test1'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: esapiserver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Miles
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|