tripod 0.10.9 → 0.10.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 40ee076fa76f2dd85f1f03f328f38e4e2813612b
4
- data.tar.gz: af419e68c83352681b72f40c7d009929f6878ddf
3
+ metadata.gz: 17e09d56a300cfbce5e1e35feb3be1821a129eee
4
+ data.tar.gz: 8b149e9c78c869ec7f307e84d2e609840b0271fe
5
5
  SHA512:
6
- metadata.gz: 7c99e9887bf0e13489e3bcc33aa4d29a83780d82a78b8c1767b308129dba8df70da0e5f3ff966492ac30d962e80fb91d91628481258ae2607814fc826ea6180b
7
- data.tar.gz: 65136c91f3e23f23f7061c1b113620176e555eff080f12a104a531edfe24a30022ad6ea64d5c4e4cccda22a320dea8d98db027acc248a13269c9acae7f376d21
6
+ metadata.gz: 8c32107cb6bb6d0065f5584e08be54f54ac08222a63ebf8a9e4dbf88ccbcc01425bfb9e61d0c4f4aa938d76cf9439b22f44ee6387f80cb03f537f44b4f8e549e
7
+ data.tar.gz: 42054adedd9b7975e3ddef60678b7118f596e75982ff6d7cfd731c9ed745767bb382cc9f9326e552cdf98935efc7ab8afc1236ec8bc4aee9b2a492244b71ea13
data/lib/tripod.rb CHANGED
@@ -49,6 +49,9 @@ module Tripod
49
49
  mattr_accessor :data_endpoint
50
50
  @@data_endpoint = 'http://127.0.0.1:3030/tripod/data'
51
51
 
52
+ mattr_accessor :extra_endpoint_params
53
+ @@extra_endpoint_params = {}
54
+
52
55
  mattr_accessor :timeout_seconds
53
56
  @@timeout_seconds = 30
54
57
 
@@ -16,7 +16,9 @@ module Tripod::SparqlClient
16
16
  # @return [ RestClient::Response ]
17
17
  def self.query(sparql, accept_header, extra_params={}, response_limit_bytes = :default)
18
18
 
19
- params = {:query => sparql}.merge(extra_params).to_query
19
+ non_sparql_params = (Tripod.extra_endpoint_params).merge(extra_params)
20
+ params_hash = {:query => sparql}.merge(non_sparql_params)
21
+ params = self.to_query(params_hash)
20
22
  request_url = Tripod.query_endpoint
21
23
  streaming_opts = {:accept => accept_header, :timeout_seconds => Tripod.timeout_seconds}
22
24
  streaming_opts.merge!(_response_limit_options(response_limit_bytes)) if Tripod.response_limit_bytes
@@ -25,8 +27,8 @@ module Tripod::SparqlClient
25
27
  stream_data = -> {
26
28
  Tripod.logger.debug "TRIPOD: About to run query: #{sparql}"
27
29
  Tripod.logger.debug "TRIPOD: Streaming from url: #{request_url}"
30
+ Tripod.logger.debug "TRIPOD: non sparql params #{non_sparql_params.to_s}"
28
31
  Tripod.logger.debug "TRIPOD: Streaming opts: #{streaming_opts.inspect}"
29
-
30
32
  Tripod::Streaming.get_data(request_url, params, streaming_opts)
31
33
  }
32
34
 
@@ -43,6 +45,20 @@ module Tripod::SparqlClient
43
45
 
44
46
  end
45
47
 
48
+ # Tripod helper to turn a hash to a query string, allowing multiple params in arrays
49
+ # e.g. :query=>'foo', :graph=>['bar', 'baz']
50
+ # -> query=foo&graph=bar&graph=baz
51
+ # based on the ActiveSupport implementation, but with different behaviour for arrays
52
+ def self.to_query hash
53
+ hash.collect_concat do |key, value|
54
+ if value.class == Array
55
+ value.collect { |v| v.to_query( key ) }
56
+ else
57
+ value.to_query(key)
58
+ end
59
+ end.sort * '&'
60
+ end
61
+
46
62
  # Runs a SELECT +query+ against the endpoint. Returns a Hash of the results.
47
63
  #
48
64
  # @param [ String ] query The query to run
@@ -49,8 +49,13 @@ module Tripod
49
49
  total_request_time = Time.now - request_start_time
50
50
  end
51
51
 
52
- Tripod.logger.debug "TRIPOD: #{total_bytes} bytes streamed in: #{stream_duration} secs"
53
- Tripod.logger.debug "TRIPOD: total request time: #{total_request_time} secs"
52
+ if Tripod.logger.debug?
53
+ Tripod.logger.debug "TRIPOD: #{total_bytes} bytes streamed in: #{stream_duration} secs"
54
+ time_str = "TRIPOD: total request time: #{total_request_time} secs"
55
+ time_str += "!!! SLOW !!! " if total_request_time >= 1.0
56
+ Tripod.logger.debug time_str
57
+ end
58
+
54
59
  end
55
60
  rescue Timeout::Error => timeout
56
61
  raise Tripod::Errors::Timeout.new
@@ -1,3 +1,3 @@
1
1
  module Tripod
2
- VERSION = "0.10.9"
2
+ VERSION = "0.10.10"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tripod
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.9
4
+ version: 0.10.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ric Roberts
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-01-30 00:00:00.000000000 Z
13
+ date: 2015-02-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client