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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tiny-queries.rb +10 -11
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e464ce85a67154de3fe030ca4fedae1e2d3a0ca
4
- data.tar.gz: ccaa2a9141e1457f208a1933a1df8c916249d09e
3
+ metadata.gz: ab4b379b5bd230b6ac819f4e35690cef6ae2c82a
4
+ data.tar.gz: ca56e073226d9ced0034a886079ed20649875aba
5
5
  SHA512:
6
- metadata.gz: ae55ba89e79a9588da400005d2b503ee72a7f256c71c8756ddc49cdca42d9e50f7928749da92d659a2d2feb598280c75202bf7f2034c6bfb8b7c2b360ac692ac
7
- data.tar.gz: a79f0ab80a5bcd7c7928be7740e9317813af889f19da57391a60c04b5dd3b75d21362dd39c0f536e290278d1ce9464b492485bdeb48e2109f0f3bc8e716f5261
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 send to each query call along with the regular query parameters
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=nil)
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
- # Add parameters to query call if present
39
- if !params.nil?
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.1
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-20 00:00:00.000000000 Z
11
+ date: 2015-07-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ''
14
14
  email: wouter@tinyqueries.com