primedia-endeca 0.9.14 → 0.9.15

Sign up to get free protection for your applications and to get access to all the features.
data/endeca.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{endeca}
5
- s.version = "0.9.14"
5
+ s.version = "0.9.15"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Rein Henrichs", "Andy Stone"]
9
- s.date = %q{2009-02-03}
9
+ s.date = %q{2009-02-04}
10
10
  s.description = %q{An Endeca client library for Ruby.}
11
11
  s.email = %q{}
12
12
  s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.rdoc"]
@@ -88,8 +88,15 @@ module Endeca
88
88
 
89
89
  # Returns the first Document matching the query options.
90
90
  def self.first(query_options={})
91
- records = request(query_options)['Records']
92
- records && new(records.first)
91
+ response = request(query_options)
92
+ if response['AggrRecords']
93
+ record = response['AggrRecords'].first['Records'].first
94
+ else
95
+ record = response['Records'].first
96
+ end
97
+ record && new(record)
98
+ rescue Exception
99
+ nil
93
100
  end
94
101
 
95
102
  # Returns all Documents matching the query options.
@@ -116,5 +123,6 @@ module Endeca
116
123
  URI.unescape(query_options)
117
124
  end
118
125
  end
126
+
119
127
  end
120
128
  end
data/lib/endeca.rb CHANGED
@@ -20,7 +20,7 @@ require 'endeca/document'
20
20
  module Endeca
21
21
 
22
22
  # :stopdoc:
23
- VERSION = '0.9.14'
23
+ VERSION = '0.9.15'
24
24
  # :startdoc:
25
25
 
26
26
  # Returns the version string for the library.
@@ -165,6 +165,15 @@ describe Endeca::Document do
165
165
  Endeca::Document.first(:id => '1234')
166
166
  end
167
167
 
168
+ it "should instantiate a new Endeca::Document from the first record in the response hash with aggregate results" do
169
+ hash = {'AggrRecords' => [{'Records' => [:document]}]}
170
+ Endeca::Request.stub!(:perform).and_return(hash)
171
+ Endeca::Document.
172
+ should_receive(:new).
173
+ with(:document)
174
+ Endeca::Document.first(:id => '1234')
175
+ end
176
+
168
177
  describe "when no matching record is returned" do
169
178
  it "should be nil" do
170
179
  Endeca::Request.stub!(:perform).and_return({'Records' => nil})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: primedia-endeca
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.14
4
+ version: 0.9.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rein Henrichs
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-02-03 00:00:00 -08:00
13
+ date: 2009-02-04 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency