lib/dbla/repository.rb in dbla-0.0.2 vs lib/dbla/repository.rb in dbla-0.0.3

- old
+ new

@@ -10,17 +10,21 @@ def search params = {} data = nil #TODO Move this into a SearchBuilder, add a generator if params['q'] - q = "?api_key=#{api_key}&q=#{params['q']}" + q = "?api_key=#{api_key}&q=#{params['q']}&facets=sourceResource.format" if params.page - q << "&page=#{params.page}" + q << "&page=#{params.page}" end if params.rows - q << "&page_size=#{params.rows}" + q << "&page_size=#{params.rows}" end + params.facet_filters do |facet_field, value| + value = "\"#{value}\"" if value.index(' ') + q << "&#{facet_field}=#{CGI::escape(value)}" + end puts url + q data = get(url + q) end Response.new(data, params,{}) end @@ -32,14 +36,15 @@ response = http.request request return JSON.parse(response.body) end end def api_key - Dbla.config[:api_key] + Dbla.config.fetch(:api_key) end def url - @url ||= (Dbla.config[:url] + blacklight_config.document_model.name.downcase.pluralize).freeze + # REVIEW: What if the URL does not have a trailing /; Should it be `File.join?` + @url ||= (Dbla.config.fetch(:url) + blacklight_config.document_model.name.downcase.pluralize).freeze end end -end \ No newline at end of file +end