tiny-queries 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tiny-queries.rb +10 -11
- 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: ab4b379b5bd230b6ac819f4e35690cef6ae2c82a
|
4
|
+
data.tar.gz: ca56e073226d9ced0034a886079ed20649875aba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0881c89366dc600f0527d10e0e635d48b2b4a0b7144d94109d5d3fdaee7b6e78b17bfb4c36e43bdf15627440ce4ef2eaa8d0af5cd92574a5699da0ad5b8690e6
|
7
|
+
data.tar.gz: 368fc65223d404071dfc4109e52aad32267ea005c16d46b94a909414ccafaf2922cb7e6426f740d6e974f5c3f1746d36afbcf90749aee12b71b35095678192a2
|
data/lib/tiny-queries.rb
CHANGED
@@ -13,7 +13,7 @@ class TinyQueries
|
|
13
13
|
attr_accessor :connector
|
14
14
|
|
15
15
|
# :globals is a hash to be used for global query parameters
|
16
|
-
# Global query parameters are
|
16
|
+
# Global query parameters are sent to each query call along with the regular query parameters
|
17
17
|
attr_accessor :globals
|
18
18
|
|
19
19
|
# Constructor
|
@@ -26,24 +26,23 @@ class TinyQueries
|
|
26
26
|
# Params:
|
27
27
|
# +term+:: query term, like "a" or "a(b)" or "a:b"
|
28
28
|
# +params+:: a hash for the query parameters
|
29
|
-
def run(term, params=
|
29
|
+
def run(term, params={})
|
30
30
|
|
31
31
|
# Check if connector is set
|
32
32
|
if @connector.nil?
|
33
33
|
raise "You need to set connector first - calling queries without connector is not supported yet"
|
34
34
|
end
|
35
|
-
|
36
|
-
command = @connector + " \"" + term + "\""
|
37
35
|
|
38
|
-
|
39
|
-
|
40
|
-
if params.class != Hash
|
41
|
-
raise "Parameters should be passed as a Hash"
|
42
|
-
end
|
43
|
-
|
44
|
-
command += " \"" + JSON.generate( params.merge( @globals ) ).gsub(/\"/,"\\\"") + "\"";
|
36
|
+
if params.class != Hash
|
37
|
+
raise "Parameters should be passed as a Hash"
|
45
38
|
end
|
46
39
|
|
40
|
+
# Create command
|
41
|
+
command =
|
42
|
+
@connector +
|
43
|
+
" \"" + term + "\"" +
|
44
|
+
" \"" + JSON.generate( params.merge( @globals ) ).gsub(/\"/,"\\\"") + "\"";
|
45
|
+
|
47
46
|
# Execute the command and capture the output
|
48
47
|
json = `#{command}`
|
49
48
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tiny-queries
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wouter Diesveld
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: ''
|
14
14
|
email: wouter@tinyqueries.com
|