dnz-client 0.1.1 → 0.1.2
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.
- data/History.txt +7 -3
- data/lib/dnz/client.rb +1 -1
- data/lib/dnz/facet.rb +7 -5
- data/lib/dnz/record.rb +4 -7
- data/lib/dnz/results.rb +0 -1
- data/lib/dnz.rb +1 -1
- data/spec/dnz/client_spec.rb +2 -2
- metadata +2 -2
data/History.txt
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
=== 0.1.2 2010-05-24
|
|
2
|
+
|
|
3
|
+
* Fix for bug where facet values would not be returned in order.
|
|
4
|
+
|
|
1
5
|
=== 0.1.1 2010-05-24
|
|
2
6
|
|
|
3
|
-
* Add support for fetching individual record metadata.
|
|
7
|
+
* Add support for fetching individual record metadata. [ paulflewelling ]
|
|
4
8
|
|
|
5
9
|
=== 0.1.0 2010-05-13
|
|
6
10
|
|
|
@@ -9,7 +13,7 @@
|
|
|
9
13
|
|
|
10
14
|
=== 0.0.9 2010-04-23
|
|
11
15
|
|
|
12
|
-
* Support for previewing custom searches
|
|
16
|
+
* Support for previewing custom searches.
|
|
13
17
|
|
|
14
18
|
=== 0.0.8 2009-11-19
|
|
15
19
|
|
|
@@ -17,7 +21,7 @@
|
|
|
17
21
|
|
|
18
22
|
=== 0.0.7 2009-11-16
|
|
19
23
|
|
|
20
|
-
* Support for multiple values in a filter
|
|
24
|
+
* Support for multiple values in a filter.
|
|
21
25
|
|
|
22
26
|
=== 0.0.5 2009-09-15
|
|
23
27
|
|
data/lib/dnz/client.rb
CHANGED
|
@@ -133,7 +133,7 @@ module DNZ
|
|
|
133
133
|
# puts category.name
|
|
134
134
|
# end
|
|
135
135
|
def categories(options = {})
|
|
136
|
-
options = options.merge(:facets => 'category', :facet_num_results => 100)
|
|
136
|
+
options = options.merge(:facets => 'category', :facet_num_results => 100, :num_results => 0)
|
|
137
137
|
search('*:*', options).facets['category'].values
|
|
138
138
|
end
|
|
139
139
|
|
data/lib/dnz/facet.rb
CHANGED
|
@@ -41,28 +41,30 @@ module DNZ
|
|
|
41
41
|
|
|
42
42
|
def initialize(client, search, doc)
|
|
43
43
|
@name = doc.xpath('facet-field').text
|
|
44
|
-
@values =
|
|
44
|
+
@values = []
|
|
45
45
|
@search = search
|
|
46
46
|
|
|
47
47
|
doc.xpath('values').first.children.each do |value_doc|
|
|
48
48
|
value = DNZ::FacetValue.new(client, self, value_doc)
|
|
49
|
-
@values
|
|
49
|
+
@values << value if value.valid?
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
# An array of FacetValue objects
|
|
54
54
|
def values
|
|
55
|
-
@values
|
|
55
|
+
@values
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
# Retrieve a FacetValue by name
|
|
59
59
|
def [](index)
|
|
60
|
-
@values
|
|
60
|
+
@values.detect{|value| value.name == index }
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
# Enumerate the FacetValue objects
|
|
64
64
|
def each
|
|
65
|
-
@values.each
|
|
65
|
+
@values.each do |value|
|
|
66
|
+
yield value
|
|
67
|
+
end
|
|
66
68
|
end
|
|
67
69
|
|
|
68
70
|
def to_s
|
data/lib/dnz/record.rb
CHANGED
|
@@ -3,12 +3,12 @@ require 'dnz/memoizable'
|
|
|
3
3
|
require 'dnz/namespace_array'
|
|
4
4
|
|
|
5
5
|
module DNZ
|
|
6
|
+
# This class is for fetching record metadata from DigitalNZ.
|
|
6
7
|
class Record
|
|
7
8
|
def self.find(id)
|
|
8
9
|
self.new(Client.connection, id)
|
|
9
10
|
end
|
|
10
11
|
|
|
11
|
-
|
|
12
12
|
def initialize(client, id)
|
|
13
13
|
@client = client
|
|
14
14
|
options = {:id => id}
|
|
@@ -17,24 +17,21 @@ module DNZ
|
|
|
17
17
|
parse_record
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
def method_missing(method, *args, &block)
|
|
20
|
+
def method_missing(method, * args, & block)
|
|
22
21
|
if attribute = document.root.attributes[method.to_s.upcase]
|
|
23
22
|
attribute.to_s
|
|
24
23
|
else
|
|
25
|
-
@data.send(method, *args, &block)
|
|
24
|
+
@data.send(method, * args, & block)
|
|
26
25
|
end
|
|
27
26
|
end
|
|
28
27
|
|
|
28
|
+
private
|
|
29
29
|
|
|
30
|
-
private
|
|
31
30
|
# Return a Nokogiri document for the XML
|
|
32
31
|
def document
|
|
33
32
|
@doc ||= Nokogiri::XML(@xml)
|
|
34
33
|
end
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
|
|
38
35
|
# Parse the result into an array of DNZ::Result
|
|
39
36
|
def parse_record
|
|
40
37
|
@data = NamespaceArray.new
|
data/lib/dnz/results.rb
CHANGED
data/lib/dnz.rb
CHANGED
data/spec/dnz/client_spec.rb
CHANGED
|
@@ -193,12 +193,12 @@ describe Client do
|
|
|
193
193
|
end
|
|
194
194
|
|
|
195
195
|
it 'should run a search for categories facet' do
|
|
196
|
-
@client.should_receive(:search).with('*:*', :facets => 'category', :facet_num_results => 100).and_return(@search)
|
|
196
|
+
@client.should_receive(:search).with('*:*', :facets => 'category', :facet_num_results => 100, :num_results => 0).and_return(@search)
|
|
197
197
|
@client.categories
|
|
198
198
|
end
|
|
199
199
|
|
|
200
200
|
it 'should run a search with custom_search' do
|
|
201
|
-
@client.should_receive(:search).with('*:*', :facets => 'category', :facet_num_results => 100, :custom_search => 'test').and_return(@search)
|
|
201
|
+
@client.should_receive(:search).with('*:*', :facets => 'category', :facet_num_results => 100, :num_results => 0, :custom_search => 'test').and_return(@search)
|
|
202
202
|
@client.categories(:custom_search => 'test')
|
|
203
203
|
end
|
|
204
204
|
|