mwmitchell-rsolr 0.6.5 → 0.6.6

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/CHANGES.txt CHANGED
@@ -1,3 +1,12 @@
1
+ 0.6.6 - January 26, 2009
2
+ Added #get method helper to RSolr::Response::Query::DocExt
3
+ # doc.get(key, opts)
4
+ # key is the name of the field
5
+ # opts is a hash with the following valid keys:
6
+ # - :sep - a string used for joining multivalued field values
7
+ # - :default - a value to return when the key doesn't exist
8
+ # if :sep is nil and the field is a multivalued field, the array is returned
9
+
1
10
  0.6.5 - January 26, 2009
2
11
  Removed to_mash everywhere, except for usage in RSolr::Response
3
12
  Added a #close method to the Direct adapter
data/lib/rsolr.rb CHANGED
@@ -7,7 +7,7 @@ proc {|base, files|
7
7
 
8
8
  module RSolr
9
9
 
10
- VERSION = '0.6.5'
10
+ VERSION = '0.6.6'
11
11
 
12
12
  autoload :Message, 'rsolr/message'
13
13
  autoload :Response, 'rsolr/response'
@@ -23,6 +23,21 @@ module RSolr::Response::Query
23
23
  end
24
24
  end
25
25
 
26
+ # helper
27
+ # key is the name of the field
28
+ # opts is a hash with the following valid keys:
29
+ # - :sep - a string used for joining multivalued field values
30
+ # - :default - a value to return when the key doesn't exist
31
+ # if :sep is nil and the field is a multivalued field, the array is returned
32
+ def get(key, opts={:sep=>', ', :default=>nil})
33
+ if self.key? key
34
+ val = self[key]
35
+ (val.is_a?(Array) and opts[:sep]) ? val.join(opts[:sep]) : val
36
+ else
37
+ opts[:default]
38
+ end
39
+ end
40
+
26
41
  end
27
42
 
28
43
  # from the delsolr project -> http://github.com/avvo/delsolr/tree/master/lib/delsolr/response.rb
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mwmitchell-rsolr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Mitchell