active-fedora 2.2.0 → 2.2.1
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/.gitignore +30 -0
- data/.gitmodules +3 -0
- data/.rvmrc +33 -0
- data/CONSOLE_GETTING_STARTED.textile +337 -0
- data/Gemfile +6 -1
- data/Gemfile.lock +39 -23
- data/NOKOGIRI_DATASTREAMS.textile +107 -0
- data/README.textile +41 -17
- data/Rakefile +5 -30
- data/active-fedora.gemspec +34 -496
- data/lib/active_fedora.rb +6 -1
- data/lib/active_fedora/base.rb +7 -5
- data/lib/active_fedora/datastream.rb +9 -8
- data/lib/active_fedora/metadata_datastream.rb +10 -3
- data/lib/active_fedora/model.rb +8 -4
- data/lib/active_fedora/nokogiri_datastream.rb +30 -24
- data/lib/active_fedora/qualified_dublin_core_datastream.rb +3 -2
- data/lib/active_fedora/rels_ext_datastream.rb +14 -5
- data/lib/active_fedora/samples.rb +3 -0
- data/lib/active_fedora/samples/hydra-mods_article_datastream.rb +517 -0
- data/lib/active_fedora/samples/hydra-rights_metadata_datastream.rb +206 -0
- data/lib/active_fedora/samples/marpa-dc_datastream.rb +97 -0
- data/lib/active_fedora/samples/special_thing.rb +45 -0
- data/lib/active_fedora/semantic_node.rb +16 -13
- data/lib/active_fedora/version.rb +3 -0
- data/lib/fedora/base.rb +5 -5
- data/lib/fedora/datastream.rb +1 -1
- data/lib/fedora/fedora_object.rb +1 -1
- data/lib/fedora/repository.rb +4 -0
- data/lib/tasks/active_fedora.rake +126 -0
- data/lib/tasks/active_fedora_dev.rake +127 -0
- data/solr/conf/schema.xml +278 -0
- data/solr/conf/solrconfig.xml +840 -0
- data/spec/integration/full_featured_model_spec.rb +2 -2
- data/spec/integration/mods_article_integration_spec.rb +2 -2
- data/spec/integration/nokogiri_datastream_spec.rb +2 -2
- data/spec/rcov.opts +2 -0
- data/spec/samples/models/hydrangea_article.rb +12 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/nokogiri_datastream_spec.rb +10 -7
- metadata +189 -886
- data/NG_XML_DATASTREAM.textile +0 -25
- data/USING_OM_DATASTREAMS.textile +0 -60
- data/VERSION +0 -1
- data/lib/hydra.rb +0 -2
- data/lib/hydra/sample_mods_datastream.rb +0 -63
- data/tasks/hoe.rake +0 -0
- data/tasks/rspec.rake +0 -29
data/NG_XML_DATASTREAM.textile
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
h1. Setting the XML in a NokogiriDatastream from a file
|
2
|
-
|
3
|
-
h2. Setting the Datastream's XML
|
4
|
-
|
5
|
-
We will make this smoother soon, but right now you have to manually parse your new xml as a Nokogiri XML Document and then put the Nokogiri Document in the datastream's ng_xml attribute.
|
6
|
-
|
7
|
-
Example (you will have to change the path to point to the xml file you want)
|
8
|
-
|
9
|
-
<pre>
|
10
|
-
my_path = "../om/spec/fixtures/mods_articles/hydrangea_article1.xml"
|
11
|
-
f = File.new(my_path)
|
12
|
-
xml = Nokogiri::XML::Document.parse(f)
|
13
|
-
ha = HydrangeaArticle.new
|
14
|
-
ha.datastreams["descMetadata"].to_xml
|
15
|
-
ha.datastreams["descMetadata"].ng_xml = xml
|
16
|
-
ha.datastreams["descMetadata"].to_xml
|
17
|
-
</pre>
|
18
|
-
|
19
|
-
h2. Saving the Datastream
|
20
|
-
|
21
|
-
In order to make sure that your updated datastream is saved to fedora, call .save _on the datastream_. If you call .save on the _object_, the changes you've made to the datastream might not be saved.
|
22
|
-
|
23
|
-
<pre>
|
24
|
-
ha.datastreams["descMetadata"].save
|
25
|
-
</pre>
|
@@ -1,60 +0,0 @@
|
|
1
|
-
h1. Using OM-based NokogiriDatastreams
|
2
|
-
|
3
|
-
h2. Setup
|
4
|
-
|
5
|
-
This tutorial assumes that you've run script/console from the root of Hydrangea and have imported Hydrangea's fixtures.
|
6
|
-
|
7
|
-
The HydrangeaArticle model definition is located at https://github.com/projecthydra/hydrangea/blob/master/vendor/plugins/hydrangea_articles/app/models/hydrangea_article.rb
|
8
|
-
|
9
|
-
Look in the "Hydra::ModsArticle":https://github.com/projecthydra/hydrangea/blob/master/vendor/plugins/hydra_repository/lib/hydra/mods_article.rb and "Hydra::RightsMetadata":https://github.com/projecthydra/hydrangea/blob/master/vendor/plugins/hydra_repository/lib/hydra/rights_metadata.rb" datastream definitions to see the OM Terminologies they define.
|
10
|
-
|
11
|
-
h2. The Tour
|
12
|
-
|
13
|
-
First, create some objects to play around with.
|
14
|
-
|
15
|
-
<pre>
|
16
|
-
ha = HydrangeaArticle.new
|
17
|
-
fixture_article = HydrangeaArticle.load_instance("hydrangea:fixture_mods_article1")
|
18
|
-
<pre>
|
19
|
-
|
20
|
-
<pre>
|
21
|
-
ha.datastreams.keys
|
22
|
-
fixture_article.datastreams.keys
|
23
|
-
</pre>
|
24
|
-
|
25
|
-
Each datastream is associated with a class that is aware of its content. These classes are specified in the model.
|
26
|
-
|
27
|
-
<pre>
|
28
|
-
ha.datastreams["rightsMetadata"].class
|
29
|
-
ha.datastreams["descMetadata"].class
|
30
|
-
<pre>
|
31
|
-
|
32
|
-
You can retrieve the xml from the object as xml (string) using to_xml, or you can access it as a Nokogiri::XML::Document using .ng_xml
|
33
|
-
|
34
|
-
<pre>
|
35
|
-
ha.datastreams["rightsMetadata"].to_xml
|
36
|
-
ha.datastreams["rightsMetadata"].ng_xml.class
|
37
|
-
</pre>
|
38
|
-
|
39
|
-
FYI, an OM terminology is attached to the datastream's class. OM's convenience methods use the terminology to look up nodes and values for you.
|
40
|
-
|
41
|
-
<pre>
|
42
|
-
ha.datastreams["rightsMetadata"].class.terminology
|
43
|
-
</pre>
|
44
|
-
|
45
|
-
The ModsArticle Terminology lets you retrieve values from the descMetadata datastream's MODS content.
|
46
|
-
|
47
|
-
<pre>
|
48
|
-
fixture_mods_ds = fixture_article.datastreams["descMetadata"]
|
49
|
-
fixture_mods_ds.term_values(:person, :first_name)
|
50
|
-
fixture_mods_ds.term_values(:person, :last_name)
|
51
|
-
</pre>
|
52
|
-
|
53
|
-
You can use OM's find_by_terms method to retrieve xml nodes from the datastream. It returns Nokogiri::XML::Node objects.
|
54
|
-
|
55
|
-
<pre>
|
56
|
-
fixture_mods_ds.find_by_terms(:person)
|
57
|
-
fixture_mods_ds.find_by_terms(:person).length
|
58
|
-
fixture_mods_ds.find_by_terms(:person).each {|n| puts n.to_xml}
|
59
|
-
</pre>
|
60
|
-
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.2.0
|
data/lib/hydra.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
require "hydra"
|
2
|
-
module Hydra
|
3
|
-
class Hydra::SampleModsDatastream < ActiveFedora::NokogiriDatastream
|
4
|
-
|
5
|
-
set_terminology do |t|
|
6
|
-
t.root(:path=>"mods", :xmlns=>"http://www.loc.gov/mods/v3", :schema=>"http://www.loc.gov/standards/mods/v3/mods-3-2.xsd")
|
7
|
-
|
8
|
-
t.title_info(:path=>"titleInfo") {
|
9
|
-
t.main_title(:path=>"title", :label=>"title")
|
10
|
-
t.language(:path=>{:attribute=>"lang"})
|
11
|
-
}
|
12
|
-
t.abstract
|
13
|
-
t.topic_tag(:path=>"subject", :default_content_path=>"topic")
|
14
|
-
# This is a mods:name. The underscore is purely to avoid namespace conflicts.
|
15
|
-
t.name_ {
|
16
|
-
# this is a namepart
|
17
|
-
t.namePart(:index_as=>[:searchable, :displayable, :facetable, :sortable], :required=>:true, :type=>:string, :label=>"generic name")
|
18
|
-
# affiliations are great
|
19
|
-
t.affiliation
|
20
|
-
t.displayForm
|
21
|
-
t.role(:ref=>[:role])
|
22
|
-
t.description
|
23
|
-
t.date(:path=>"namePart", :attributes=>{:type=>"date"})
|
24
|
-
t.last_name(:path=>"namePart", :attributes=>{:type=>"family"})
|
25
|
-
t.first_name(:path=>"namePart", :attributes=>{:type=>"given"}, :label=>"first name")
|
26
|
-
t.terms_of_address(:path=>"namePart", :attributes=>{:type=>"termsOfAddress"})
|
27
|
-
}
|
28
|
-
# lookup :person, :first_name
|
29
|
-
t.person(:ref=>:name, :attributes=>{:type=>"personal"})
|
30
|
-
t.organizaton(:ref=>:name, :attributes=>{:type=>"institutional"})
|
31
|
-
t.conference(:ref=>:name, :attributes=>{:type=>"conference"})
|
32
|
-
|
33
|
-
t.role {
|
34
|
-
t.text(:path=>"roleTerm",:attributes=>{:type=>"text"})
|
35
|
-
t.code(:path=>"roleTerm",:attributes=>{:type=>"code"})
|
36
|
-
}
|
37
|
-
t.journal(:path=>'relatedItem', :attributes=>{:type=>"host"}) {
|
38
|
-
t.title_info
|
39
|
-
t.origin_info(:path=>"originInfo") {
|
40
|
-
t.publisher
|
41
|
-
t.date_issued(:path=>"dateIssued")
|
42
|
-
}
|
43
|
-
t.issn(:path=>"identifier", :attributes=>{:type=>"issn"})
|
44
|
-
t.issue(:path=>"part") {
|
45
|
-
t.volume(:path=>"detail", :attributes=>{:type=>"volume"}, :default_content_path=>"number")
|
46
|
-
t.level(:path=>"detail", :attributes=>{:type=>"number"}, :default_content_path=>"number")
|
47
|
-
t.extent
|
48
|
-
t.pages(:path=>"extent", :attributes=>{:type=>"pages"}) {
|
49
|
-
t.start
|
50
|
-
t.end
|
51
|
-
}
|
52
|
-
t.publication_date(:path=>"date")
|
53
|
-
}
|
54
|
-
}
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
# Changes from OM::Properties implementation
|
59
|
-
# renamed family_name => last_name
|
60
|
-
# start_page & end_page now accessible as [:journal, :issue, :pages, :start] (etc.)
|
61
|
-
|
62
|
-
end
|
63
|
-
end
|
data/tasks/hoe.rake
DELETED
File without changes
|
data/tasks/rspec.rake
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'spec'
|
3
|
-
rescue LoadError
|
4
|
-
require 'rubygems'
|
5
|
-
require 'spec'
|
6
|
-
end
|
7
|
-
begin
|
8
|
-
require 'spec/rake/spectask'
|
9
|
-
rescue LoadError
|
10
|
-
puts <<-EOS
|
11
|
-
To use rspec for testing you must install rspec gem:
|
12
|
-
gem install rspec
|
13
|
-
EOS
|
14
|
-
exit(0)
|
15
|
-
end
|
16
|
-
|
17
|
-
desc "Run the specs under spec/models"
|
18
|
-
Spec::Rake::SpecTask.new do |t|
|
19
|
-
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
-
end
|
22
|
-
|
23
|
-
namespace :spec do
|
24
|
-
desc "run the unit specs"
|
25
|
-
Spec::Rake::SpecTask.new(:units) do |t|
|
26
|
-
t.spec_opts = ['--options', "spec/spec.opts"]
|
27
|
-
t.spec_files = FileList['spec/unit/**/*_spec.rb']
|
28
|
-
end
|
29
|
-
end
|