uri_service 0.2.5 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cbe79b3bc5359b1f9bb6c0e48826c259d1011048
4
- data.tar.gz: 50033704d6b6201e0867f93341029aae63067063
3
+ metadata.gz: 845187ba683b261e1633154472f1d014ec54427f
4
+ data.tar.gz: 8796fb9f981396e0850b25f44b63807b74d58140
5
5
  SHA512:
6
- metadata.gz: 732b6341e5ff646b5b0939e20123b4570642ba9b5070154de094a37bc23a6869db673ff962e1887c2ee0f5aee18fe6d6d82aa5896ed35d0c803c489939c79aea
7
- data.tar.gz: b5009f28d5aa849085798c6c4a89f194cdc79ecffb7173bd04316c5143674acf3fb7d8f25ec4e05a1f68c51473dafcbfd97229ac6c606dc47408e9bf44a90b0c
6
+ metadata.gz: 373950826a7bd03c9ec44b0809d6ec777349da1271313fc9a87368381f9e5dae18bfb45240727b44eab24d1a5e87dbab82a2b090bdaf425e53c157a3a936da8a
7
+ data.tar.gz: 6a5ae8b0ca6a7515465ffefd41271a9235b8694d7c5153f9cc18b982f5fd76bef028908d421e6dca7190aeabb82983588246e8c716841cf89e1928c3e7ba5c0a
@@ -290,9 +290,20 @@ class UriService::Client
290
290
  end
291
291
  end
292
292
 
293
- def find_term_by_uri(uri)
293
+ # Finds the first term matching the specified conditions
294
+ def find_term_by(opts)
295
+ fqs = []
296
+
297
+ # Only search on allowed fields
298
+ unsupported_search_fields = opts.map{|key, val| key.to_s} - CORE_FIELD_NAMES
299
+ raise UriService::UnsupportedSearchFieldError, "Unsupported search fields: #{unsupported_search_fields.join(', ')}" if unsupported_search_fields.present?
300
+
301
+ opts.each do |field_name, val|
302
+ fqs << (field_name.to_s + ':"' + UriService.solr_escape(val.to_s) + '"')
303
+ end
304
+
294
305
  @rsolr_pool.with do |rsolr|
295
- response = rsolr.get('select', params: { :q => '*:*', :fq => 'uri:' + UriService.solr_escape(uri) })
306
+ response = rsolr.get('select', params: {:q => '*:*', :fq => fqs })
296
307
  if response['response']['numFound'] == 1
297
308
  return term_solr_doc_to_frozen_term_hash(response['response']['docs'].first)
298
309
  end
@@ -474,4 +485,5 @@ class UriService::ExistingUriError < StandardError;end
474
485
  class UriService::ExistingVocabularyStringKeyError < StandardError;end
475
486
  class UriService::NonExistentUriError < StandardError;end
476
487
  class UriService::NonExistentVocabularyError < StandardError;end
477
- class UriService::UnsupportedObjectTypeError < StandardError;end
488
+ class UriService::UnsupportedObjectTypeError < StandardError;end
489
+ class UriService::UnsupportedSearchFieldError < StandardError;end
@@ -1,6 +1,6 @@
1
1
  module UriService
2
2
 
3
- VERSION = '0.2.5'
3
+ VERSION = '0.2.6'
4
4
 
5
5
  def self.version
6
6
  VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uri_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric O'Hanlon
@@ -202,4 +202,3 @@ specification_version: 4
202
202
  summary: A service for registering local URIs and performing both local and remote
203
203
  URI lookups.
204
204
  test_files: []
205
- has_rdoc: