solrizer 3.0.0.pre8 → 3.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -85,6 +85,18 @@ module Solrizer
85
85
  #
86
86
  # self.descriptors = [MyCustomIndexDescriptors, DefaultDescriptors]
87
87
  # end
88
+
89
+ class StringDescriptor < Solrizer::Descriptor
90
+
91
+ def initialize(suffix)
92
+ @suffix = suffix
93
+ end
94
+
95
+ def suffix(field_type)
96
+ '_'+@suffix
97
+ end
98
+
99
+ end
88
100
 
89
101
  class FieldMapper
90
102
 
@@ -104,7 +116,7 @@ module Solrizer
104
116
  self.id_field = self.class.id_field
105
117
  end
106
118
 
107
- # Given a field name, inndex_type, etc., returns the corresponding Solr name.
119
+ # Given a field name, index_type, etc., returns the corresponding Solr name.
108
120
  # TODO field type is the input format, maybe we could just detect that?
109
121
  # @param [String] field_name the ruby (term) name which will get a suffix appended to become a Solr field name
110
122
  # @param opts - index_type is only needed if the FieldDescriptor requires it (e.g. :searcahble)
@@ -132,19 +144,22 @@ module Solrizer
132
144
  end
133
145
  end
134
146
 
135
- # @param index_type is a FieldDescriptor or a symbol that points to a method that returns a field descriptor
147
+ # @param [Symbol, String, Descriptor] index_type is a Descriptor, a symbol that references a method that returns a Descriptor, or a string which will be used as the suffix.
148
+ # @return [Descriptor]
136
149
  def indexer(index_type)
137
150
  index_type = case index_type
138
151
  when Symbol
139
152
  index_type_macro(index_type)
140
- when Array
141
- raise "It's not yet supposed to be an array"
142
- #IndexDescriptors::Descriptor.new(*index_type)
143
- else
153
+ when String
154
+ StringDescriptor.new(index_type)
155
+ when Descriptor
144
156
  index_type
157
+ else
158
+ raise Solrizer::InvalidIndexDescriptor, "#{index_type.class} is not a valid indexer_type. Use a String, Symbol or Descriptor."
159
+ #IndexDescriptors::Descriptor.new(*index_type)
145
160
  end
146
161
 
147
- raise InvalidIndexDescriptor, "index type should be an IndexDescriptor, you passed: #{index_type}" unless index_type.kind_of? Descriptor
162
+ raise InvalidIndexDescriptor, "index type should be an Descriptor, you passed: #{index_type.class}" unless index_type.kind_of? Descriptor
148
163
  index_type
149
164
  end
150
165
 
@@ -1,3 +1,3 @@
1
1
  module Solrizer
2
- VERSION = "3.0.0.pre8"
2
+ VERSION = "3.0.0.rc1"
3
3
  end
@@ -160,6 +160,10 @@ describe Solrizer::FieldMapper do
160
160
  @mapper.solr_name('foo').should == 'foo_s'
161
161
  end
162
162
 
163
+ it "should allow you to pass a string as the suffix" do
164
+ @mapper.solr_name('bar', 'quack').should == 'bar_quack'
165
+ end
166
+
163
167
  it "should map based on data type" do
164
168
  @mapper.solr_name('foo', :fungible, type: :integer).should == 'foo_f1'
165
169
  @mapper.solr_name('foo', :fungible, type: :garble).should == 'foo_f2' # based on type.default
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solrizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.pre8
4
+ version: 3.0.0.rc1
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-03 00:00:00.000000000 Z
12
+ date: 2013-02-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -226,7 +226,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
226
226
  version: '0'
227
227
  segments:
228
228
  - 0
229
- hash: 1646376342601153569
229
+ hash: 985635456296935043
230
230
  required_rubygems_version: !ruby/object:Gem::Requirement
231
231
  none: false
232
232
  requirements: