active-fedora 8.4.1 → 8.4.2

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: 868a6d33b74e815c12f4ee931c13d0decb74e7a8
4
- data.tar.gz: 7416e36e700403b856ea27ddc8fb94d47dad6ac1
3
+ metadata.gz: a785fa56e5709791afe64fc36b3eaf3f51fd5557
4
+ data.tar.gz: a4871a6e43d779bdfea81e96726532131d8bde9f
5
5
  SHA512:
6
- metadata.gz: a194f8dd5012761d67bc059bcedde55cb64ffc269bed64fce33505cb0e0275986acf0b0cee44df9ebad1f4f7b6828f3b500a8a79c494014fbba132553c29bd63
7
- data.tar.gz: 8448af2cda3d69965d9b23507e68437aa60d271271e1f0b79bc5da0201d968588e7f3481f86289c320bc9502bd9036a02a1e9ee20900b643e99f89389740720c
6
+ metadata.gz: 54a6209639d2a5f51d1d41b0478b5a712d8eeec86fb1358ff7ea5e567ae4ecc18a8e5c325c3f4fafff26277b0de3e472e61a84c235278cec783a8808fdd181b6
7
+ data.tar.gz: 086cbeb31c69b9c61ab31dd4750588dee86442f82fff454de9c096bc3f5aac7ef3f3d558f861aca90fd73d669731845c2f57275de0615141b36386f6ef561875
@@ -1,12 +1,12 @@
1
1
  module ActiveFedora
2
- #This class represents a simple xml datastream.
2
+ #This class represents a simple xml datastream.
3
3
  class SimpleDatastream < OmDatastream
4
4
 
5
5
  class_attribute :class_fields
6
6
  attr_accessor :fields
7
7
  self.class_fields = []
8
-
9
-
8
+
9
+
10
10
  set_terminology do |t|
11
11
  t.root(:path=>"fields", :xmlns=>nil)
12
12
  end
@@ -16,7 +16,7 @@ module ActiveFedora
16
16
  xml.text(name)
17
17
  end
18
18
  end
19
-
19
+
20
20
 
21
21
  #Constructor. this class will call self.field for each DCTERM. In short, all DCTERMS fields will already exist
22
22
  #when this method returns. Each term is marked as a multivalue string.
@@ -27,15 +27,15 @@ module ActiveFedora
27
27
 
28
28
  # This method generates the various accessor and mutator methods on self for the datastream metadata attributes.
29
29
  # each field will have the 2 magic methods:
30
- # name=(arg)
31
- # name
30
+ # name=(arg)
31
+ # name
32
32
  #
33
33
  #
34
34
  # 'datatype' is a datatype, currently :string, :integer and :date are supported.
35
35
  #
36
36
  # opts is an options hash, which will affect the generation of the xml representation of this datastream.
37
37
  #
38
- # Currently supported modifiers:
38
+ # Currently supported modifiers:
39
39
  # For +SimpleDatastream+:
40
40
  # :element_attrs =>{:foo=>:bar} - hash of xml element attributes
41
41
  # :xml_node => :nodename - The xml node to be used to represent this object (in dcterms namespace)
@@ -45,8 +45,8 @@ module ActiveFedora
45
45
  #
46
46
  #There is quite a good example of this class in use in spec/examples/oral_history.rb
47
47
  #
48
- #!! Careful: If you declare two fields that correspond to the same xml node without any qualifiers to differentiate them,
49
- #you will end up replicating the values in the underlying datastream, resulting in mysterious dubling, quadrupling, etc.
48
+ #!! Careful: If you declare two fields that correspond to the same xml node without any qualifiers to differentiate them,
49
+ #you will end up replicating the values in the underlying datastream, resulting in mysterious dubling, quadrupling, etc.
50
50
  #whenever you edit the field's values.
51
51
  def field(name, datatype=:string, opts={})
52
52
  fields ||= {}
@@ -59,9 +59,9 @@ module ActiveFedora
59
59
  self.class.terminology.add_term(term)
60
60
  term.generate_xpath_queries!
61
61
  end
62
-
62
+
63
63
  end
64
-
64
+
65
65
  def update_indexed_attributes(params={}, opts={})
66
66
  raise "can't modify frozen #{self.class}" if frozen?
67
67
  # if the params are just keys, not an array, make then into an array.
@@ -75,25 +75,20 @@ module ActiveFedora
75
75
  end
76
76
  super(new_params, opts)
77
77
  end
78
-
79
78
 
80
79
  def self.xml_template
81
- Nokogiri::XML::Document.parse("<fields/>")
80
+ Nokogiri::XML::Document.parse("<fields/>")
82
81
  end
83
82
 
84
83
  def to_solr(solr_doc = Hash.new) # :nodoc:
85
84
  @fields.each do |field_key, field_info|
86
85
  next if field_key == :location ## FIXME HYDRA-825
87
- things = send(field_key)
88
- if things
89
- field_symbol = ActiveFedora::SolrService.solr_name(field_key, type: field_info[:type])
90
- things.val.each do |val|
91
- ::Solrizer::Extractor.insert_solr_field_value(solr_doc, field_symbol, val.to_s )
92
- end
86
+ field_symbol = ActiveFedora::SolrService.solr_name(field_key, type: field_info[:type])
87
+ om_term_values(field_key).each do |val|
88
+ ::Solrizer::Extractor.insert_solr_field_value(solr_doc, field_symbol, val.to_s)
93
89
  end
94
90
  end
95
- return solr_doc
91
+ solr_doc
96
92
  end
97
-
98
93
  end
99
94
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "8.4.1"
2
+ VERSION = "8.4.2"
3
3
  end
@@ -3,26 +3,40 @@ require 'spec_helper'
3
3
  describe ActiveFedora::SimpleDatastream do
4
4
 
5
5
  before do
6
- @sample_xml = "<fields><coverage>coverage1</coverage><coverage>coverage2</coverage><creation_date>2012-01-15</creation_date><mydate>fake-date</mydate><publisher>publisher1</publisher></fields>"
6
+ @sample_xml = "<fields><coverage>coverage1</coverage><coverage>coverage2</coverage><creation_date>2012-01-15</creation_date><mydate>fake-date</mydate><prefix>foobar</prefix><publisher>publisher1</publisher></fields>"
7
7
  @test_ds = ActiveFedora::SimpleDatastream.from_xml(@sample_xml )
8
8
  @test_ds.field :coverage
9
9
  @test_ds.field :creation_date, :date
10
10
  @test_ds.field :mydate
11
+ @test_ds.field :prefix
11
12
  @test_ds.field :publisher
12
-
13
13
  end
14
+
14
15
  it "from_xml should parse everything correctly" do
15
16
  expect(@test_ds.ng_xml).to be_equivalent_to @sample_xml
16
17
  end
17
18
 
18
-
19
+ describe "#to_solr" do
20
+ it "should work as expected" do
21
+ expect(@test_ds.to_solr).to eq(
22
+ {
23
+ 'coverage_tesim' => ['coverage1', 'coverage2'],
24
+ 'creation_date_dtsim' => '2012-01-15',
25
+ 'mydate_tesim' => 'fake-date',
26
+ 'prefix_tesim' => 'foobar',
27
+ 'publisher_tesim' => 'publisher1'
28
+ }
29
+ )
30
+ end
31
+ end
32
+
19
33
  describe '#new' do
20
- describe "model methods" do
34
+ describe "model methods" do
21
35
 
22
36
  [:coverage, :mydate, :publisher].each do |el|
23
37
  it "should respond to getters and setters for the string typed #{el} element" do
24
38
  value = "Hey #{el}"
25
- @test_ds.send("#{el.to_s}=", value)
39
+ @test_ds.send("#{el.to_s}=", value)
26
40
  expect(@test_ds.send(el).first).to eq(value) #Looking at first because creator has 2 nodes
27
41
  end
28
42
  end
@@ -34,7 +48,7 @@ describe ActiveFedora::SimpleDatastream do
34
48
  end
35
49
  end
36
50
  end
37
-
51
+
38
52
  describe '.to_xml' do
39
53
  it 'should output the fields hash as Qualified Dublin Core XML' do
40
54
  @test_ds.publisher= "charlie"
@@ -46,6 +60,7 @@ describe ActiveFedora::SimpleDatastream do
46
60
  <coverage>20%</coverage>
47
61
  <creation_date>2012-01-15</creation_date>
48
62
  <mydate>fake-date</mydate>
63
+ <prefix>foobar</prefix>
49
64
  <publisher>charlie</publisher>
50
65
  </fields>')
51
66
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-fedora
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.4.1
4
+ version: 8.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Zumwalt
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-07-12 00:00:00.000000000 Z
13
+ date: 2018-03-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rsolr
@@ -563,7 +563,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
563
563
  version: '0'
564
564
  requirements: []
565
565
  rubyforge_project:
566
- rubygems_version: 2.6.11
566
+ rubygems_version: 2.5.1
567
567
  signing_key:
568
568
  specification_version: 4
569
569
  summary: A convenience libary for manipulating documents in the Fedora Repository.