dnz-client 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
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[value.name] = value if value.valid?
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.values
55
+ @values
56
56
  end
57
57
 
58
58
  # Retrieve a FacetValue by name
59
59
  def [](index)
60
- @values[index]
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 {|key, value| yield value }
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
@@ -107,7 +107,6 @@ module DNZ
107
107
  # Parse the facets into an array of DNZ::FacetArray
108
108
  def parse_facets
109
109
  @facets = FacetArray.new
110
-
111
110
  doc.xpath('//facets/facet').each do |facet_xml|
112
111
  @facets << DNZ::Facet.new(@client, @search, facet_xml)
113
112
  end
data/lib/dnz.rb CHANGED
@@ -4,5 +4,5 @@ $:.unshift(File.dirname(__FILE__)) unless
4
4
  require 'dnz/client'
5
5
 
6
6
  module Dnz
7
- VERSION = '0.1.1'
7
+ VERSION = '0.1.2'
8
8
  end
@@ -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
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jeremy Wells