dnz-client 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.0.8 2009-11-19
2
+
3
+ * Support for custom_search API with categories call.
4
+
1
5
  === 0.0.7 2009-11-16
2
6
 
3
7
  * Support for multiple values in a filter
data/Rakefile CHANGED
@@ -5,8 +5,6 @@ require 'fileutils'
5
5
  require './lib/dnz'
6
6
 
7
7
  Hoe.plugin :newgem
8
- # Hoe.plugin :website
9
- # Hoe.plugin :cucumberfeatures
10
8
 
11
9
  # Generate all the Rake tasks
12
10
  # Run 'rake -T' to see list of generated tasks (from gem root directory)
data/lib/dnz/client.rb CHANGED
@@ -100,13 +100,18 @@ module DNZ
100
100
 
101
101
  # Get a list of all categories using the 'category' facet.
102
102
  #
103
+ # ==== Options
104
+ #
105
+ # * <tt>:custom_search</tt> - The name of a custom search created at http://digitalnz.org
106
+ #
103
107
  # ==== Example
104
108
  # categories = client.categories
105
109
  # categories.each do |category|
106
110
  # puts category.name
107
111
  # end
108
- def categories
109
- search('*:*', :facets => 'category', :facet_num_results => 100).facets['category'].values
112
+ def categories(options = {})
113
+ options = options.merge(:facets => 'category', :facet_num_results => 100)
114
+ search('*:*', options).facets['category'].values
110
115
  end
111
116
 
112
117
  # Run a search using the digitalnz.org API.
data/lib/dnz/search.rb CHANGED
@@ -75,7 +75,7 @@ module DNZ
75
75
 
76
76
  # The number of pages available for the current search.
77
77
  def pages
78
- num_results_requested < result_count ? (result_count.to_f / num_results_requested).ceil : 0
78
+ num_results_requested < result_count ? (result_count.to_f / num_results_requested).ceil : 1
79
79
  end
80
80
 
81
81
  # The number of results requested via the :num_results option (see <tt>Client.search</tt>).
@@ -83,12 +83,17 @@ module DNZ
83
83
  @num_results_requested || 20
84
84
  end
85
85
 
86
+ def inspect
87
+ self.to_s
88
+ end
89
+
86
90
  def to_s
87
91
  {
88
- :results => self.results.length,
92
+ :results => self.result_count,
89
93
  :facets => self.facets.length,
90
94
  :page => self.page,
91
- :pages => self.pages
95
+ :pages => self.pages,
96
+ :per_page => self.num_results_requested
92
97
  }.inspect
93
98
  end
94
99
 
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.0.7'
7
+ VERSION = '0.0.8'
8
8
  end
@@ -141,6 +141,11 @@ describe Client do
141
141
  @client.should_receive(:search).with('*:*', :facets => 'category', :facet_num_results => 100).and_return(@search)
142
142
  @client.categories
143
143
  end
144
+
145
+ it 'should run a search with custom_search' do
146
+ @client.should_receive(:search).with('*:*', :facets => 'category', :facet_num_results => 100, :custom_search => 'test').and_return(@search)
147
+ @client.categories(:custom_search => 'test')
148
+ end
144
149
 
145
150
  it 'should return the categories facet' do
146
151
  @client.categories.should == @categories
data/tasks/rspec.rake CHANGED
@@ -1,18 +1,6 @@
1
- begin
2
- require 'spec'
3
- rescue LoadError
4
- require 'rubygems'
5
- require 'spec'
6
- end
7
- begin
8
- require 'spec/rake/spectask'
9
- rescue LoadError
10
- puts <<-EOS
11
- To use rspec for testing you must install rspec gem:
12
- gem install rspec
13
- EOS
14
- exit(0)
15
- end
1
+ require 'spec'
2
+ require 'spec/rake/spectask'
3
+
16
4
 
17
5
  desc "Run the specs under spec"
18
6
  Spec::Rake::SpecTask.new do |t|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dnz-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Wells
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-16 00:00:00 +13:00
12
+ date: 2009-11-19 00:00:00 +13:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency