solrizer 3.2.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d77a71925151847cbb586039e03296e1b0aa2c9
4
- data.tar.gz: a2bbb1286b7b037dc5a83d81f84ec098edc60283
3
+ metadata.gz: fdbccd31fa681a9b641d09d28db5f2658cc19c4d
4
+ data.tar.gz: 8b3f8f8fd164e2d9720c5bbcad56b3948ef7ffad
5
5
  SHA512:
6
- metadata.gz: 76ad75ea81fb427b72a0b214637427f44ecd54d5e4b80cc43f49ae4c13598816d3756144b4b1081f7c357169595d97d7c8ce4e1137533e54e99807c619f9d9d6
7
- data.tar.gz: 9294cad6b4a5661321d4a0780652af3e31fbebfeabf6b3ebe5d62577d37aaf6cc685255edb50acc5fd8782f468bb05a0d8ba1e64bb40c346c6f10202e8103250
6
+ metadata.gz: c2e433d14eefcbdc9f5c04aefbfaaf3a533f7cb7a8dc896b2096e0c9e9d5dfa42b659af1f66d075c7801341db15adff967900c7c09bf381e1c927a826c4f1426
7
+ data.tar.gz: 26a18f117e4c1e75192b14c926d7485611c4c148a751488530c75a81d7e1ae2af16619a2337d5f55a0771cb91a83ccc02863cf86d7ec0b18acb5785597935d24
@@ -1,3 +1,9 @@
1
+ h2. 3.3.0
2
+ * 2014-07-17: Remove dependency on mediashelf-loggable [Justin Coyne]
3
+ * 2014-07-17: Fix rspec deprecations [Justin Coyne]
4
+ * 2014-06-04: Refactor format_node_value so we don't need to check responds_to? [Justin Coyne]
5
+
6
+ [Justin Coyne]
1
7
  h2. 3.2.0
2
8
  #25 Allow any field_value except nil to be inserted into a solr field
3
9
  #24 Remove dependency on solrizer-fedora, use AF to update index by pid
@@ -1,4 +1,6 @@
1
1
  require 'active_support'
2
+ require 'active_support/core_ext/module/attribute_accessors'
3
+
2
4
  module Solrizer
3
5
  extend ActiveSupport::Autoload
4
6
 
@@ -12,51 +14,55 @@ module Solrizer
12
14
  autoload :VERSION, 'solrizer/version'
13
15
  autoload :XML, 'solrizer/xml'
14
16
 
15
- def self.version
16
- Solrizer::VERSION
17
- end
17
+ mattr_accessor :logger, instance_writer: false
18
18
 
19
- def self.default_field_mapper
20
- @@default_field_mapper ||= Solrizer::FieldMapper.new
21
- end
19
+ class << self
20
+ def version
21
+ Solrizer::VERSION
22
+ end
22
23
 
23
- def self.default_field_mapper=(field_mapper)
24
- @@default_field_mapper = field_mapper
25
- end
24
+ def default_field_mapper
25
+ @@default_field_mapper ||= Solrizer::FieldMapper.new
26
+ end
26
27
 
28
+ def default_field_mapper=(field_mapper)
29
+ @@default_field_mapper = field_mapper
30
+ end
27
31
 
28
- def self.solr_name(*args)
29
- default_field_mapper.solr_name(*args)
30
- end
31
32
 
32
- # @params [Hash] doc the hash to insert the value into
33
- # @params [String] name the name of the field (without the suffix)
34
- # @params [String,Date,Array] value the value (or array of values) to be inserted
35
- # @params [Array,Hash] indexer_args the arguments that find the indexer
36
- # @returns [Hash] doc the document that was provided with the new field inserted
37
- def self.insert_field(doc, name, value, *indexer_args)
38
- # adding defaults indexer
39
- indexer_args = [:stored_searchable] if indexer_args.empty?
40
- default_field_mapper.solr_names_and_values(name, value, indexer_args).each do |k, v|
41
- doc[k] ||= []
42
- if v.is_a? Array
43
- doc[k] += v
44
- else
45
- doc[k] = v
33
+ def solr_name(*args)
34
+ default_field_mapper.solr_name(*args)
35
+ end
36
+
37
+ # @params [Hash] doc the hash to insert the value into
38
+ # @params [String] name the name of the field (without the suffix)
39
+ # @params [String,Date,Array] value the value (or array of values) to be inserted
40
+ # @params [Array,Hash] indexer_args the arguments that find the indexer
41
+ # @returns [Hash] doc the document that was provided with the new field inserted
42
+ def insert_field(doc, name, value, *indexer_args)
43
+ # adding defaults indexer
44
+ indexer_args = [:stored_searchable] if indexer_args.empty?
45
+ default_field_mapper.solr_names_and_values(name, value, indexer_args).each do |k, v|
46
+ doc[k] ||= []
47
+ if v.is_a? Array
48
+ doc[k] += v
49
+ else
50
+ doc[k] = v
51
+ end
46
52
  end
53
+ doc
47
54
  end
48
- doc
49
- end
50
55
 
51
- # @params [Hash] doc the hash to insert the value into
52
- # @params [String] name the name of the field (without the suffix)
53
- # @params [String,Date] value the value to be inserted
54
- # @params [Array,Hash] indexer_args the arguments that find the indexer
55
- # @returns [Hash] doc the document that was provided with the new field (replacing any field with the same name)
56
- def self.set_field(doc, name, value, *indexer_args)
57
- # adding defaults indexer
58
- indexer_args = [:stored_searchable] if indexer_args.empty?
59
- doc.merge! default_field_mapper.solr_names_and_values(name, value, indexer_args)
60
- doc
56
+ # @params [Hash] doc the hash to insert the value into
57
+ # @params [String] name the name of the field (without the suffix)
58
+ # @params [String,Date] value the value to be inserted
59
+ # @params [Array,Hash] indexer_args the arguments that find the indexer
60
+ # @returns [Hash] doc the document that was provided with the new field (replacing any field with the same name)
61
+ def set_field(doc, name, value, *indexer_args)
62
+ # adding defaults indexer
63
+ indexer_args = [:stored_searchable] if indexer_args.empty?
64
+ doc.merge! default_field_mapper.solr_names_and_values(name, value, indexer_args)
65
+ doc
66
+ end
61
67
  end
62
68
  end
@@ -9,34 +9,35 @@ module Solrizer
9
9
  #
10
10
  class Extractor
11
11
 
12
- # Insert +field_value+ for +field_name+ into +solr_doc+
13
- # Handles inserting new values into a Hash while ensuring that you don't destroy or overwrite any existing values in the hash.
14
- # Ensures that field values are always appended to arrays within the values hash.
15
- # Also ensures that values are run through format_node_value
16
- # @param [Hash] solr_doc
17
- # @param [String] field_name
18
- # @param [String] field_value
19
- def self.insert_solr_field_value(solr_doc, field_name, field_value)
20
- formatted_value = self.format_node_value(field_value)
21
- if solr_doc[field_name]
22
- solr_doc[field_name] = Array(solr_doc[field_name]) << formatted_value
23
- else
24
- solr_doc[field_name] = formatted_value
12
+ class << self
13
+ # Insert +field_value+ for +field_name+ into +solr_doc+
14
+ # Handles inserting new values into a Hash while ensuring that you don't destroy or overwrite any existing values in the hash.
15
+ # Ensures that field values are always appended to arrays within the values hash.
16
+ # Also ensures that values are run through format_node_value
17
+ # @param [Hash] solr_doc
18
+ # @param [String] field_name
19
+ # @param [String] field_value
20
+ def insert_solr_field_value(solr_doc, field_name, field_value)
21
+ formatted_value = format_node_value(field_value)
22
+ if solr_doc[field_name]
23
+ solr_doc[field_name] = Array(solr_doc[field_name]) << formatted_value
24
+ else
25
+ solr_doc[field_name] = formatted_value
26
+ end
27
+ return solr_doc
25
28
  end
26
- return solr_doc
27
- end
28
-
29
- # Strips the majority of whitespace from the values array and then joins them with a single blank delimitter
30
- # Returns an empty string if values argument is nil
31
- #
32
- # @param [Array] values Array of strings representing the values to be formatted
33
- # @return [String]
34
- def self.format_node_value values
35
- if values.nil?
36
- return ""
37
- else
38
- values = [values] unless values.respond_to? :map
39
- return values.map{|val| val.gsub(/\s+/,' ').strip}.join(" ")
29
+
30
+ # Strips the majority of whitespace from the values array and then joins them with a single blank delimitter
31
+ # Returns an empty string if values argument is nil
32
+ #
33
+ # @param [Array] values Array of strings representing the values to be formatted
34
+ # @return [String]
35
+ def format_node_value values
36
+ if values.nil?
37
+ ""
38
+ else
39
+ Array(values).map{|val| val.gsub(/\s+/,' ').strip}.join(" ")
40
+ end
40
41
  end
41
42
  end
42
43
 
@@ -1,4 +1,3 @@
1
- require "loggable"
2
1
  require 'active_support/core_ext/class/attribute'
3
2
  require 'active_support/core_ext/string/inflections'
4
3
  module Solrizer
@@ -100,8 +99,6 @@ module Solrizer
100
99
 
101
100
  class FieldMapper
102
101
 
103
- include Loggable
104
-
105
102
  # ------ Instance methods ------
106
103
 
107
104
  attr_reader :id_field, :default_index_types
@@ -228,7 +225,7 @@ module Solrizer
228
225
  values = (results[name] ||= [])
229
226
  values << value unless value.nil? || values.include?(value)
230
227
  else
231
- logger.warn "Setting #{name} to `#{value}', but it already had `#{results[name]}'" if results[name]
228
+ Solrizer.logger.warn "Setting #{name} to `#{value}', but it already had `#{results[name]}'" if results[name] && Solrizer.logger
232
229
  results[name] = value
233
230
  end
234
231
  end
@@ -1,3 +1,3 @@
1
1
  module Solrizer
2
- VERSION = "3.2.0"
2
+ VERSION = "3.3.0"
3
3
  end
@@ -14,7 +14,6 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.add_dependency "nokogiri"
16
16
  s.add_dependency "xml-simple"
17
- s.add_dependency "mediashelf-loggable", "~>0.4.7"
18
17
  s.add_dependency "stomp"
19
18
  s.add_dependency "daemons"
20
19
  s.add_dependency "activesupport"
@@ -10,33 +10,30 @@ describe Solrizer::Common do
10
10
  Object.send(:remove_const, :Foo)
11
11
  end
12
12
 
13
+ let(:solr_doc) { {} }
14
+
13
15
  it "should handle many field types" do
14
- solr_doc = {}
15
16
  Foo.create_and_insert_terms('my_name', 'value', [:displayable, :searchable, :sortable], solr_doc)
16
- solr_doc.should == {'my_name_ssm' => ['value'], 'my_name_si' => 'value', 'my_name_teim' => ['value']}
17
+ expect(solr_doc).to eq('my_name_ssm' => ['value'], 'my_name_si' => 'value', 'my_name_teim' => ['value'])
17
18
  end
18
19
 
19
20
  it "should handle dates that are searchable" do
20
- solr_doc = {}
21
21
  Foo.create_and_insert_terms('my_name', Date.parse('2013-01-10'), [:stored_searchable], solr_doc)
22
- solr_doc.should == {'my_name_dtsim' => ['2013-01-10T00:00:00Z']}
22
+ expect(solr_doc).to eq('my_name_dtsim' => ['2013-01-10T00:00:00Z'])
23
23
  end
24
24
 
25
25
  it "should handle dates that are stored_sortable" do
26
- solr_doc = {}
27
26
  Foo.create_and_insert_terms('my_name', Date.parse('2013-01-10'), [:stored_sortable], solr_doc)
28
- solr_doc.should == {'my_name_dtsi' => '2013-01-10T00:00:00Z'}
27
+ expect(solr_doc).to eq('my_name_dtsi' => '2013-01-10T00:00:00Z')
29
28
  end
30
29
 
31
30
  it "should handle dates that are displayable" do
32
- solr_doc = {}
33
31
  Foo.create_and_insert_terms('my_name', Date.parse('2013-01-10'), [:displayable], solr_doc)
34
- solr_doc.should == {'my_name_ssm' => ['2013-01-10']}
32
+ expect(solr_doc).to eq('my_name_ssm' => ['2013-01-10'])
35
33
  end
36
34
 
37
35
  it "should handle dates that are sortable" do
38
- solr_doc = {}
39
36
  Foo.create_and_insert_terms('my_name', Date.parse('2013-01-10'), [:sortable], solr_doc)
40
- solr_doc.should == {'my_name_dti' => '2013-01-10T00:00:00Z'}
37
+ expect(solr_doc).to eq('my_name_dti' => '2013-01-10T00:00:00Z')
41
38
  end
42
39
  end
@@ -8,15 +8,15 @@ describe Solrizer::Extractor do
8
8
 
9
9
  describe ".format_node_value" do
10
10
  it "should strip white space out of the array and join it with a single blank" do
11
- Solrizer::Extractor.format_node_value([" test \n node \t value \t"]).should == "test node value"
12
- Solrizer::Extractor.format_node_value([" test ", " \n node ", " \t value \t"]).should == "test node value"
11
+ expect(Solrizer::Extractor.format_node_value([" test \n node \t value \t"])).to eq "test node value"
12
+ expect(Solrizer::Extractor.format_node_value([" test ", " \n node ", " \t value \t"])).to eq "test node value"
13
13
  end
14
14
  it "should return an empty string if given an argument of nil" do
15
- Solrizer::Extractor.format_node_value(nil).should == ""
15
+ expect(Solrizer::Extractor.format_node_value(nil)).to eq ''
16
16
  end
17
17
 
18
18
  it "should strip white space out of a string" do
19
- Solrizer::Extractor.format_node_value("raw string\n with whitespace").should == "raw string with whitespace"
19
+ expect(Solrizer::Extractor.format_node_value("raw string\n with whitespace")).to eq "raw string with whitespace"
20
20
  end
21
21
  end
22
22
 
@@ -24,19 +24,19 @@ describe Solrizer::Extractor do
24
24
  it "should initialize a solr doc list if it is nil" do
25
25
  solr_doc = {'title_tesim' => nil }
26
26
  Solrizer::Extractor.insert_solr_field_value(solr_doc, 'title_tesim', 'Frank')
27
- solr_doc.should == {"title_tesim"=>"Frank"}
27
+ expect(solr_doc).to eq("title_tesim"=>"Frank")
28
28
  end
29
29
  it "should insert multiple" do
30
30
  solr_doc = {'title_tesim' => nil }
31
31
  Solrizer::Extractor.insert_solr_field_value(solr_doc, 'title_tesim', 'Frank')
32
32
  Solrizer::Extractor.insert_solr_field_value(solr_doc, 'title_tesim', 'Margret')
33
33
  Solrizer::Extractor.insert_solr_field_value(solr_doc, 'title_tesim', 'Joyce')
34
- solr_doc.should == {"title_tesim"=>["Frank", 'Margret', 'Joyce']}
34
+ expect(solr_doc).to eq("title_tesim"=>["Frank", 'Margret', 'Joyce'])
35
35
  end
36
36
  it "should not make a list if a single valued field is passed in" do
37
37
  solr_doc = {}
38
38
  Solrizer::Extractor.insert_solr_field_value(solr_doc, 'title_dtsi', '2013-03-22T12:33:00Z')
39
- solr_doc.should == {"title_dtsi"=>"2013-03-22T12:33:00Z"}
39
+ expect(solr_doc).to eq("title_dtsi"=>"2013-03-22T12:33:00Z")
40
40
  end
41
41
 
42
42
  end
@@ -148,100 +148,100 @@ describe Solrizer::FieldMapper do
148
148
  # --- Tests ----
149
149
 
150
150
  it "should handle the id field" do
151
- @mapper.id_field.should == 'ident'
151
+ expect(@mapper.id_field).to eq 'ident'
152
152
  end
153
153
 
154
154
 
155
155
  describe "extract_type" do
156
156
  it "should map objects to symbols" do
157
- @mapper.extract_type(7).should == :integer
158
- @mapper.extract_type(nil).should == nil
159
- @mapper.extract_type(Date.today).should == :date
160
- @mapper.extract_type(Time.now).should == :time
161
- @mapper.extract_type(DateTime.now).should == :time
162
- @mapper.extract_type("Hi").should == :string
157
+ expect(@mapper.extract_type(7)).to eq :integer
158
+ expect(@mapper.extract_type(nil)).to eq nil
159
+ expect(@mapper.extract_type(Date.today)).to eq :date
160
+ expect(@mapper.extract_type(Time.now)).to eq :time
161
+ expect(@mapper.extract_type(DateTime.now)).to eq :time
162
+ expect(@mapper.extract_type("Hi")).to eq :string
163
163
  end
164
164
  end
165
165
 
166
166
  describe '.solr_name' do
167
167
  it "should map based on passed descriptors" do
168
- @mapper.solr_name('bar', :edible).should == 'bar_food'
169
- @mapper.solr_name('bar', :laughable, type: :string).should == 'bar_haha'
168
+ expect(@mapper.solr_name('bar', :edible)).to eq 'bar_food'
169
+ expect(@mapper.solr_name('bar', :laughable, type: :string)).to eq 'bar_haha'
170
170
  end
171
171
 
172
172
  it "should default the index_type to :stored_searchable" do
173
- @mapper.solr_name('foo').should == 'foo_s'
173
+ expect(@mapper.solr_name('foo')).to eq 'foo_s'
174
174
  end
175
175
 
176
176
  it "should allow you to pass a string as the suffix" do
177
- @mapper.solr_name('bar', 'quack').should == 'bar_quack'
177
+ expect(@mapper.solr_name('bar', 'quack')).to eq 'bar_quack'
178
178
  end
179
179
 
180
180
  it "should map based on data type" do
181
- @mapper.solr_name('foo', :fungible, type: :integer).should == 'foo_f1'
182
- @mapper.solr_name('foo', :fungible, type: :garble).should == 'foo_f2' # based on type.default
183
- @mapper.solr_name('foo', :fungible, type: :date).should == 'foo_f0' # type.date falls through to container
181
+ expect(@mapper.solr_name('foo', :fungible, type: :integer)).to eq 'foo_f1'
182
+ expect(@mapper.solr_name('foo', :fungible, type: :garble)).to eq 'foo_f2' # based on type.default
183
+ expect(@mapper.solr_name('foo', :fungible, type: :date)).to eq 'foo_f0' # type.date falls through to container
184
184
  end
185
185
 
186
186
  it "should return nil for an unknown index types" do
187
- lambda {
187
+ expect {
188
188
  @mapper.solr_name('foo', :blargle)
189
- }.should raise_error(Solrizer::UnknownIndexMacro, "Unable to find `blargle' in [TestMapper0::Descriptors0, Solrizer::DefaultDescriptors]")
189
+ }.to raise_error(Solrizer::UnknownIndexMacro, "Unable to find `blargle' in [TestMapper0::Descriptors0, Solrizer::DefaultDescriptors]")
190
190
  end
191
191
 
192
192
  it "should allow subclasses to selectively override suffixes" do
193
193
  @mapper = TestMapper1.new
194
- @mapper.solr_name('foo', type: :date).should == 'foo_s'
195
- @mapper.solr_name('foo', type: :string).should == 'foo_s'
196
- @mapper.solr_name('foo', :fungible, type: :integer).should == 'foo_f5' # override on data type
197
- @mapper.solr_name('foo', :fungible, type: :garble).should == 'foo_f4' # override on data type
198
- @mapper.solr_name('foo', :fungible, type: :fratz).should == 'foo_f2' # from super
199
- @mapper.solr_name('foo', :fungible, type: :date).should == 'foo_f0' # super definition picks up override on index type
194
+ expect(@mapper.solr_name('foo', type: :date)).to eq 'foo_s'
195
+ expect(@mapper.solr_name('foo', type: :string)).to eq 'foo_s'
196
+ expect(@mapper.solr_name('foo', :fungible, type: :integer)).to eq 'foo_f5' # override on data type
197
+ expect(@mapper.solr_name('foo', :fungible, type: :garble)).to eq 'foo_f4' # override on data type
198
+ expect(@mapper.solr_name('foo', :fungible, type: :fratz)).to eq 'foo_f2' # from super
199
+ expect(@mapper.solr_name('foo', :fungible, type: :date)).to eq 'foo_f0' # super definition picks up override on index type
200
200
  end
201
201
 
202
202
 
203
203
  it "should raise an error when field_type is nil" do
204
204
  mapper = Solrizer::FieldMapper.new
205
- lambda { mapper.solr_name(:heifer, nil, :searchable)}.should raise_error Solrizer::InvalidIndexDescriptor
205
+ expect { mapper.solr_name(:heifer, nil, :searchable) }.to raise_error Solrizer::InvalidIndexDescriptor
206
206
  end
207
207
  end
208
208
 
209
209
  describe '.solr_names_and_values' do
210
210
  it "should map values based on passed descriptors" do
211
- @mapper.solr_names_and_values('foo', 'bar', [:stored_searchable, :laughable, :edible]).should == {
211
+ expect(@mapper.solr_names_and_values('foo', 'bar', [:stored_searchable, :laughable, :edible])).to eq(
212
212
  'foo_s' => ['bar'],
213
213
  'foo_food' => ['bar'],
214
214
  'foo_haha' => ["Knock knock. Who's there? Bar. Bar who?"]
215
- }
215
+ )
216
216
  end
217
217
 
218
218
  it "should apply mappings based on data type" do
219
- @mapper.solr_names_and_values('foo', 7, [:stored_searchable, :laughable]).should == {
219
+ expect(@mapper.solr_names_and_values('foo', 7, [:stored_searchable, :laughable])).to eq(
220
220
  'foo_s' => ['7'],
221
221
  'foo_ihaha' => ["How many foos does it take to screw in a light bulb? 7."]
222
- }
222
+ )
223
223
  end
224
224
 
225
225
  it "should raise error on unknown index types" do
226
- lambda {
226
+ expect {
227
227
  @mapper.solr_names_and_values('foo', 'bar', [:blargle])
228
- }.should raise_error(Solrizer::UnknownIndexMacro, "Unable to find `blargle' in [TestMapper0::Descriptors0, Solrizer::DefaultDescriptors]")
228
+ }.to raise_error(Solrizer::UnknownIndexMacro, "Unable to find `blargle' in [TestMapper0::Descriptors0, Solrizer::DefaultDescriptors]")
229
229
  end
230
230
 
231
231
  it "should generate multiple mappings when two return the _same_ solr name but _different_ values" do
232
- @mapper.solr_names_and_values('roll', 'rock', [:unstemmed_searchable, :stored_searchable]).should == {
232
+ expect(@mapper.solr_names_and_values('roll', 'rock', [:unstemmed_searchable, :stored_searchable])).to eq(
233
233
  'roll_s' => ["rock o'clock", 'rock']
234
- }
234
+ )
235
235
  end
236
236
 
237
237
  it "should not generate multiple mappings when two return the _same_ solr name and the _same_ value" do
238
- @mapper.solr_names_and_values('roll', 'rock', [:another_stored_searchable, :stored_searchable]).should == {
238
+ expect(@mapper.solr_names_and_values('roll', 'rock', [:another_stored_searchable, :stored_searchable])).to eq(
239
239
  'roll_s' => ['rock'],
240
- }
240
+ )
241
241
  end
242
242
 
243
243
  it "should return an empty hash when value is nil" do
244
- @mapper.solr_names_and_values('roll', nil, [:another_stored_searchable, :stored_searchable]).should == { }
244
+ expect(@mapper.solr_names_and_values('roll', nil, [:another_stored_searchable, :stored_searchable])).to eq({ })
245
245
  end
246
246
  end
247
247
 
@@ -251,33 +251,33 @@ describe Solrizer::FieldMapper do
251
251
  end
252
252
 
253
253
  it "should call the id field 'id'" do
254
- @mapper.id_field.should == 'id'
254
+ expect(@mapper.id_field).to eq 'id'
255
255
  end
256
256
 
257
257
  it "should default the index_type to :stored_searchable" do
258
- @mapper.solr_name('foo', :type=>:string).should == 'foo_tesim'
258
+ expect(@mapper.solr_name('foo', :type=>:string)).to eq 'foo_tesim'
259
259
  end
260
260
 
261
261
  it "should support field names as symbols" do
262
- @mapper.solr_name(:active_fedora_model, :symbol).should == "active_fedora_model_ssim"
262
+ expect(@mapper.solr_name(:active_fedora_model, :symbol)).to eq "active_fedora_model_ssim"
263
263
  end
264
264
 
265
265
  it "should not apply mappings for searchable by default" do
266
266
  # Just sanity check a couple; copy & pasting all data types is silly
267
- @mapper.solr_names_and_values('foo', 'bar', []).should == { }
268
- @mapper.solr_names_and_values('foo', "1",[]).should == { }
267
+ expect(@mapper.solr_names_and_values('foo', 'bar', [])).to eq({ })
268
+ expect(@mapper.solr_names_and_values('foo', "1",[])).to eq({ })
269
269
  end
270
270
 
271
271
  it "should support full ISO 8601 dates" do
272
- @mapper.solr_names_and_values('foo', "2012-11-06", [:dateable]).should == { 'foo_dtsim' =>["2012-11-06T00:00:00Z"] }
273
- @mapper.solr_names_and_values('foo', "November 6th, 2012", [:dateable]).should == { 'foo_dtsim' =>["2012-11-06T00:00:00Z"] }
274
- @mapper.solr_names_and_values('foo', "6 Nov. 2012", [:dateable]).should == { 'foo_dtsim' =>["2012-11-06T00:00:00Z"] }
275
- @mapper.solr_names_and_values('foo', '', [:dateable]).should == { 'foo_dtsim' => [] }
272
+ expect(@mapper.solr_names_and_values('foo', "2012-11-06", [:dateable])).to eq('foo_dtsim' =>["2012-11-06T00:00:00Z"])
273
+ expect(@mapper.solr_names_and_values('foo', "November 6th, 2012", [:dateable])).to eq('foo_dtsim' =>["2012-11-06T00:00:00Z"])
274
+ expect(@mapper.solr_names_and_values('foo', "6 Nov. 2012", [:dateable])).to eq('foo_dtsim' =>["2012-11-06T00:00:00Z"])
275
+ expect(@mapper.solr_names_and_values('foo', '', [:dateable])).to eq('foo_dtsim' => [])
276
276
  end
277
277
 
278
278
  it "should support searchable, stored_searchable, displayable, facetable, sortable, stored_sortable, unstemmed" do
279
279
  descriptors = [:searchable, :stored_searchable, :displayable, :facetable, :sortable, :stored_sortable, :unstemmed_searchable]
280
- @mapper.solr_names_and_values('foo', 'bar', descriptors).should == {
280
+ expect(@mapper.solr_names_and_values('foo', 'bar', descriptors)).to eq(
281
281
  "foo_teim" => ["bar"], #searchable
282
282
  "foo_tesim" => ["bar"], #stored_searchable
283
283
  "foo_ssm" => ["bar"], #displayable
@@ -285,13 +285,13 @@ describe Solrizer::FieldMapper do
285
285
  "foo_si" => "bar", #sortable
286
286
  "foo_ssi" => "bar", #stored_sortable
287
287
  "foo_tim" => ["bar"] #unstemmed_searchable
288
- }
288
+ )
289
289
  end
290
290
 
291
291
  it "should support stored_sortable" do
292
292
  time = Time.iso8601("2012-11-06T15:16:17Z")
293
- @mapper.solr_names_and_values('foo', time, :stored_sortable).should == {"foo_dtsi" => "2012-11-06T15:16:17Z"}
294
- @mapper.solr_names_and_values('foo', 'bar', :stored_sortable).should == {"foo_ssi" => "bar"}
293
+ expect(@mapper.solr_names_and_values('foo', time, :stored_sortable)).to eq("foo_dtsi" => "2012-11-06T15:16:17Z")
294
+ expect(@mapper.solr_names_and_values('foo', 'bar', :stored_sortable)).to eq("foo_ssi" => "bar")
295
295
  end
296
296
  end
297
297
  end
@@ -7,68 +7,68 @@ describe Solrizer do
7
7
  let(:doc) { Hash.new }
8
8
  it "should insert a field with the default (stored_searchable) indexer" do
9
9
  Solrizer.insert_field(doc, 'foo', 'A name')
10
- doc.should == {'foo_tesim' => ['A name']}
10
+ expect(doc).to eq('foo_tesim' => ['A name'])
11
11
  end
12
12
  it "should not create an array of fields that are not multivalued" do
13
13
  Solrizer.insert_field(doc, 'foo', 'A name', :sortable)
14
- doc.should == {'foo_si' => 'A name'}
14
+ expect(doc).to eq('foo_si' => 'A name')
15
15
  end
16
16
  it "should insert a field with multiple indexers" do
17
17
  Solrizer.insert_field(doc, 'foo', 'A name', :sortable, :facetable)
18
- doc.should == {'foo_si' => 'A name', 'foo_sim' => ['A name']}
18
+ expect(doc).to eq('foo_si' => 'A name', 'foo_sim' => ['A name'])
19
19
  end
20
20
  it "should insert Dates" do
21
21
  Solrizer.insert_field(doc, 'foo', Date.parse('2013-01-13'))
22
- doc.should == {'foo_dtsim' => ["2013-01-13T00:00:00Z"]}
22
+ expect(doc).to eq('foo_dtsim' => ["2013-01-13T00:00:00Z"])
23
23
  end
24
24
  it "should insert Times" do
25
25
  Solrizer.insert_field(doc, 'foo', Time.parse('2013-01-13T22:45:56+06:00'))
26
- doc.should == {'foo_dtsim' => ["2013-01-13T16:45:56Z"]}
26
+ expect(doc).to eq('foo_dtsim' => ["2013-01-13T16:45:56Z"])
27
27
  end
28
28
  it "should insert true Booleans" do
29
29
  Solrizer.insert_field(doc, 'foo', true)
30
- doc.should == {'foo_bsi' => true}
30
+ expect(doc).to eq('foo_bsi' => true)
31
31
  end
32
32
  it "should insert false Booleans" do
33
33
  Solrizer.insert_field(doc, 'foo', false)
34
- doc.should == {'foo_bsi' => false}
34
+ expect(doc).to eq('foo_bsi' => false)
35
35
  end
36
36
 
37
37
  it "should insert multiple values" do
38
38
  Solrizer.insert_field(doc, 'foo', ['A name', 'B name'], :sortable, :facetable)
39
- doc.should == {'foo_si' => 'B name', 'foo_sim' => ['A name', 'B name']}
39
+ expect(doc).to eq('foo_si' => 'B name', 'foo_sim' => ['A name', 'B name'])
40
40
  end
41
41
 
42
42
  it 'should insert nothing when passed a nil value' do
43
43
  Solrizer.insert_field(doc, 'foo', nil, :sortable, :facetable)
44
- doc.should == {}
44
+ expect(doc).to eq( { } )
45
45
  end
46
46
  end
47
47
 
48
48
  describe "on a document with values" do
49
- before{ @doc = {'foo_si' => 'A name', 'foo_sim' => ['A name']}}
49
+ let(:doc) { {'foo_si' => 'A name', 'foo_sim' => ['A name']} }
50
50
 
51
51
  it "should not overwrite muli-values that exist before" do
52
- Solrizer.insert_field(@doc, 'foo', 'B name', :sortable, :facetable)
53
- @doc.should == {'foo_si' => 'B name', 'foo_sim' => ['A name', 'B name']}
52
+ Solrizer.insert_field(doc, 'foo', 'B name', :sortable, :facetable)
53
+ expect(doc).to eq('foo_si' => 'B name', 'foo_sim' => ['A name', 'B name'])
54
54
  end
55
55
  end
56
56
  end
57
57
  describe ".set_field" do
58
58
  describe "on a document with values" do
59
- before{ @doc = {'foo_si' => ['A name'], 'foo_sim' => ['A name']}}
59
+ let(:doc) { {'foo_si' => ['A name'], 'foo_sim' => ['A name']} }
60
60
 
61
61
  it "should overwrite values that exist before" do
62
- Solrizer.set_field(@doc, 'foo', 'B name', :sortable, :facetable)
63
- @doc.should == {'foo_si' => 'B name', 'foo_sim' => ['B name']}
62
+ Solrizer.set_field(doc, 'foo', 'B name', :sortable, :facetable)
63
+ expect(doc).to eq('foo_si' => 'B name', 'foo_sim' => ['B name'])
64
64
  end
65
65
  end
66
66
  end
67
67
 
68
68
  describe ".solr_name" do
69
69
  it "should delegate to default_field_mapper" do
70
- Solrizer.solr_name('foo', type: :string).should == "foo_tesim"
71
- Solrizer.solr_name('foo', :sortable).should == "foo_si"
70
+ expect(Solrizer.solr_name('foo', type: :string)).to eq "foo_tesim"
71
+ expect(Solrizer.solr_name('foo', :sortable)).to eq "foo_si"
72
72
  end
73
73
  end
74
74
  end
@@ -10,16 +10,16 @@ describe Solrizer::XML::Extractor do
10
10
 
11
11
  describe ".xml_to_solr" do
12
12
  it "should turn simple xml into a solr document" do
13
- result[:type_tesim].should == "text"
14
- result[:medium_tesim].should == "Paper Document"
15
- result[:rights_tesim].should == "Presumed under copyright. Do not publish."
16
- result[:date_tesim].should == "1985-12-30"
17
- result[:format_tesim].should be_kind_of(Array)
18
- result[:format_tesim].should include("application/tiff")
19
- result[:format_tesim].should include("application/pdf")
20
- result[:format_tesim].should include("application/jp2000")
21
- result[:title_tesim].should == "This is a Sample Title"
22
- result[:publisher_tesim].should == "Sample Unversity"
13
+ expect(result[:type_tesim]).to eq "text"
14
+ expect(result[:medium_tesim]).to eq "Paper Document"
15
+ expect(result[:rights_tesim]).to eq "Presumed under copyright. Do not publish."
16
+ expect(result[:date_tesim]).to eq "1985-12-30"
17
+ expect(result[:format_tesim]).to be_kind_of(Array)
18
+ expect(result[:format_tesim]).to include("application/tiff")
19
+ expect(result[:format_tesim]).to include("application/pdf")
20
+ expect(result[:format_tesim]).to include("application/jp2000")
21
+ expect(result[:title_tesim]).to eq "This is a Sample Title"
22
+ expect(result[:publisher_tesim]).to eq "Sample Unversity"
23
23
  end
24
24
  end
25
25
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solrizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Zumwalt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-28 00:00:00.000000000 Z
11
+ date: 2014-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: mediashelf-loggable
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 0.4.7
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 0.4.7
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: stomp
57
43
  requirement: !ruby/object:Gem::Requirement