active-fedora 1.1.9 → 1.1.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ 1.1.11
2
+
3
+ * fix to update_index preventing double-metadata
4
+ * now nokogiri datastreams initialize with default template.
5
+
1
6
  1.1.8
2
7
 
3
8
  solrizer fix to ensure that Nokogiri Datastreams are included in Base.to_solr
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.9
1
+ 1.1.11
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{active-fedora}
8
- s.version = "1.1.9"
8
+ s.version = "1.1.11"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Zumwalt", "McClain Looney"]
@@ -86,10 +86,6 @@ module ActiveFedora
86
86
  end
87
87
  @new_object = false
88
88
  self.update_index if @metadata_is_dirty == true && ENABLE_SOLR_UPDATES
89
- if defined?( Solrizer::Solrizer )
90
- solrizer = Solrizer::Solrizer.new
91
- solrizer.solrize( self )
92
- end
93
89
  @metadata_is_dirty == false
94
90
  return result
95
91
  end
@@ -420,7 +416,12 @@ module ActiveFedora
420
416
 
421
417
  # Updates Solr index with self.
422
418
  def update_index
423
- SolrService.instance.conn.update(self.to_solr)
419
+ if defined?( Solrizer::Solrizer )
420
+ solrizer = Solrizer::Solrizer.new
421
+ solrizer.solrize( self )
422
+ else
423
+ SolrService.instance.conn.update(self.to_solr)
424
+ end
424
425
  end
425
426
 
426
427
  # An ActiveRecord-ism to udpate metadata values.
@@ -20,7 +20,9 @@ class ActiveFedora::NokogiriDatastream < ActiveFedora::Datastream
20
20
  # @tmpl ActiveFedora::MetadataDatastream
21
21
  # Careful! If you call this from a constructor, be sure to provide something 'ie. self' as the @tmpl. Otherwise, you will get an infinite loop!
22
22
  def self.from_xml(xml, tmpl=self.new) # :nodoc:
23
- if xml.kind_of? Nokogiri::XML::Node
23
+ if xml.nil?
24
+ tmpl.ng_xml = self.xml_template
25
+ elsif xml.kind_of? Nokogiri::XML::Node || xml.kind_of?(Nokogiri::XML::Document)
24
26
  tmpl.ng_xml = xml
25
27
  else
26
28
  tmpl.ng_xml = Nokogiri::XML::Document.parse(xml)
@@ -29,6 +31,10 @@ class ActiveFedora::NokogiriDatastream < ActiveFedora::Datastream
29
31
  return tmpl
30
32
  end
31
33
 
34
+ def self.xml_template
35
+ Nokogiri::XML::Document.parse("<xml/>")
36
+ end
37
+
32
38
  # class << self
33
39
  # from_xml_original = self.instance_method(:from_xml)
34
40
  #
@@ -29,6 +29,16 @@ describe ActiveFedora::NokogiriDatastream do
29
29
  test_ds1 = ActiveFedora::NokogiriDatastream.new(:blob=>"<xml><foo/></xml>")
30
30
  test_ds1.ng_xml.to_xml.should == "<?xml version=\"1.0\"?>\n<xml>\n <foo/>\n</xml>\n"
31
31
  end
32
+ it "should initialize from #xml_template if no xml is provided" do
33
+ ActiveFedora::NokogiriDatastream.expects(:xml_template).returns("fake template")
34
+ ActiveFedora::NokogiriDatastream.new.ng_xml.should == "fake template"
35
+ end
36
+ end
37
+
38
+ describe '#xml_template' do
39
+ it "should return an empty xml document" do
40
+ ActiveFedora::NokogiriDatastream.xml_template.to_xml.should == "<?xml version=\"1.0\"?>\n<xml/>\n"
41
+ end
32
42
  end
33
43
 
34
44
  describe ".update_indexed_attributes" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-fedora
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 5
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 9
10
- version: 1.1.9
9
+ - 11
10
+ version: 1.1.11
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Zumwalt