primedia-endeca 0.9.9 → 0.9.10

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.9"
5
+ s.version = "0.9.10"
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-02}
9
+ s.date = %q{2009-02-03}
10
10
  s.description = %q{An Endeca client library for Ruby.}
11
11
  s.email = %q{}
12
12
  s.extra_rdoc_files = ["History.txt", "README.rdoc"]
data/example/listing.rb CHANGED
@@ -30,7 +30,4 @@ class Listing < Endeca::Document
30
30
 
31
31
  def coordinates; [latitude, longitude] end
32
32
  def image_url; (graphic_urls || thumbnails).first rescue nil end
33
-
34
- dim_reader :zip, :bathrooms, :bedrooms
35
-
36
33
  end
@@ -59,7 +59,17 @@ module Endeca
59
59
 
60
60
  # The internal collection of Document objects. Array methods are delegated here.
61
61
  def documents
62
- @documents ||= (@raw['Records'] || []).map(&@document_klass)
62
+ if @raw['Records']
63
+ @documents ||= @raw['Records'].map(&@document_klass)
64
+ elsif @raw['AggrRecords']
65
+ @documents ||= @raw['AggrRecords']['Records'].map(&@document_klass)
66
+ else
67
+ []
68
+ end
69
+ end
70
+
71
+ def aggregate?
72
+ @raw['AggrRecords'] ? true : false
63
73
  end
64
74
 
65
75
  # The collection of Refinement objects for the collection.
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.9'
23
+ VERSION = '0.9.10'
24
24
  # :startdoc:
25
25
 
26
26
  # Returns the version string for the library.
@@ -19,6 +19,11 @@ describe Endeca::DocumentCollection do
19
19
  'Refinements' => [@refinement],
20
20
  'Breadcrumbs' => [@breadcrumb]
21
21
  }
22
+
23
+ @aggregate_raw = {
24
+ 'AggrRecords' => {'Records' => [@document]}
25
+ }
26
+
22
27
  @document_collection = Endeca::DocumentCollection.new(@raw)
23
28
  end
24
29
 
@@ -35,29 +40,53 @@ describe Endeca::DocumentCollection do
35
40
  end
36
41
 
37
42
  describe '#documents' do
38
- it "should return a collection of documents" do
39
- @document_collection.documents.size.should == 1
40
- @document_collection.documents.first.should == Endeca::Document.new(@document)
41
- end
42
-
43
43
  it "should return the correct document class for subclassees" do
44
44
  class ConcreteDocument < Endeca::Document; end
45
45
  collection = Endeca::DocumentCollection.new(@raw, ConcreteDocument)
46
46
  collection.documents.first.class.should == ConcreteDocument
47
47
  end
48
- end
49
48
 
50
- describe "#previous_page" do
51
- describe "when on the first page" do
49
+ describe "with a normal record set" do
50
+ it "should return a collection of documents" do
51
+ @document_collection.documents.should == [Endeca::Document.new(@document)]
52
+ end
53
+ end
54
+
55
+ describe "with an aggregate record set" do
52
56
  before do
53
- @document_collection.stub!(:current_page).and_return(0)
57
+ @document_collection = Endeca::DocumentCollection.new(@aggregate_raw)
54
58
  end
55
59
 
56
- it "should be nil" do
57
- @document_collection.previous_page.should be_nil
60
+ it "should find the documents" do
61
+ @document_collection.documents.size.should == 1
62
+ @document_collection.documents.first.should == Endeca::Document.new(@document)
58
63
  end
59
64
  end
60
65
 
66
+ describe "with no record set" do
67
+ before { @document_collection = Endeca::DocumentCollection.new({}) }
68
+ it { @document_collection.documents.should be_empty }
69
+ end
70
+ end
71
+
72
+ describe "#aggregate?" do
73
+ describe "with a normal document collection" do
74
+ it { @document_collection.aggregate?.should be_false }
75
+ end
76
+
77
+ describe "with an aggregate document collection" do
78
+ before { @document_collection = Endeca::DocumentCollection.new(@aggregate_raw) }
79
+ it { @document_collection.aggregate?.should be_true }
80
+ end
81
+ end
82
+
83
+ describe "#previous_page" do
84
+ describe "when on the first page" do
85
+ before { @document_collection.stub!(:current_page).and_return(0) }
86
+
87
+ it { @document_collection.previous_page.should be_nil }
88
+ end
89
+
61
90
  describe "when on any other page" do
62
91
  before do
63
92
  @document_collection.stub!(:current_page).and_return(4)
@@ -75,19 +104,12 @@ describe Endeca::DocumentCollection do
75
104
  end
76
105
 
77
106
  describe "when on the last page" do
78
- before do
79
- @document_collection.stub!(:current_page).and_return(20)
80
- end
81
-
82
- it "should be nil" do
83
- @document_collection.next_page.should be_nil
84
- end
107
+ before { @document_collection.stub!(:current_page).and_return(20) }
108
+ it { @document_collection.next_page.should be_nil }
85
109
  end
86
110
 
87
111
  describe "when on any other page" do
88
- before do
89
- @document_collection.stub!(:current_page).and_return(4)
90
- end
112
+ before { @document_collection.stub!(:current_page).and_return(4) }
91
113
 
92
114
  it "should return the next page" do
93
115
  @document_collection.next_page.should == 5
@@ -121,16 +143,16 @@ describe Endeca::DocumentCollection do
121
143
  end
122
144
 
123
145
  describe "#is_a?" do
124
- it "should be true if the compared class is Array" do
125
- @document_collection.is_a?(Array).should be_true
146
+ describe "Array" do
147
+ it { @document_collection.is_a?(Array).should be_true }
126
148
  end
127
149
 
128
- it "should be true if the compared class is Endeca::DocumentCollection" do
129
- @document_collection.is_a?(Endeca::DocumentCollection).should be_true
150
+ describe "DocumentCollection" do
151
+ it { @document_collection.is_a?(Endeca::DocumentCollection).should be_true }
130
152
  end
131
153
 
132
- it "should be false if the compared class is String" do
133
- @document_collection.is_a?(String).should be_false
154
+ describe "String" do
155
+ it { @document_collection.is_a?(String).should be_false }
134
156
  end
135
157
  end
136
158
  end
data/spec/rcov.opts CHANGED
@@ -1,5 +1,5 @@
1
1
  --text-summary
2
2
  --exclude
3
- json,FakeWeb,rcov.rb,rspec,spec
3
+ json,FakeWeb,rcov.rb,rspec,spec,activesupport,builder,gem
4
4
  --sort
5
5
  coverage
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.9
4
+ version: 0.9.10
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-02 00:00:00 -08:00
13
+ date: 2009-02-03 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency