active_fedora_relsint 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+ # see active_fedora_relsint.gemspec
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,128 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ active_fedora_relsint (0.1.0)
5
+ active-fedora (>= 4.2.0)
6
+ activesupport (~> 3.2.0)
7
+ rubydora (~> 0.5.11)
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ RedCloth (4.2.9)
13
+ active-fedora (4.4.1)
14
+ activeresource (>= 3.0.0)
15
+ activesupport (>= 3.0.0)
16
+ deprecation
17
+ equivalent-xml
18
+ mediashelf-loggable
19
+ om (~> 1.6.0)
20
+ rdf
21
+ rdf-rdfxml (~> 0.3.8)
22
+ rsolr
23
+ rubydora (~> 0.5.11)
24
+ solrizer (~> 1.2.0)
25
+ activemodel (3.2.6)
26
+ activesupport (= 3.2.6)
27
+ builder (~> 3.0.0)
28
+ activeresource (3.2.6)
29
+ activemodel (= 3.2.6)
30
+ activesupport (= 3.2.6)
31
+ activesupport (3.2.6)
32
+ i18n (~> 0.6)
33
+ multi_json (~> 1.0)
34
+ addressable (2.3.1)
35
+ akami (1.2.0)
36
+ gyoku (>= 0.4.0)
37
+ nokogiri (>= 1.4.0)
38
+ backports (2.6.2)
39
+ builder (3.0.0)
40
+ daemons (1.1.8)
41
+ deprecation (0.0.5)
42
+ activesupport
43
+ diff-lcs (1.1.3)
44
+ equivalent-xml (0.2.9)
45
+ nokogiri (>= 1.4.3)
46
+ fastercsv (1.5.5)
47
+ gyoku (0.4.6)
48
+ builder (>= 2.1.2)
49
+ hooks (0.2.0)
50
+ httpi (1.1.1)
51
+ rack
52
+ i18n (0.6.0)
53
+ mediashelf-loggable (0.4.9)
54
+ metaclass (0.0.1)
55
+ mime-types (1.19)
56
+ mocha (0.10.5)
57
+ metaclass (~> 0.0.1)
58
+ multi_json (1.3.6)
59
+ nokogiri (1.5.5)
60
+ nori (1.1.3)
61
+ om (1.6.1)
62
+ mediashelf-loggable
63
+ nokogiri (>= 1.4.2)
64
+ rack (1.4.1)
65
+ rake (0.9.2.2)
66
+ rdf (0.3.7)
67
+ addressable (>= 2.2.6)
68
+ rdf-rdfxml (0.3.8)
69
+ rdf (>= 0.3.4)
70
+ rdf-xsd (>= 0.3.5)
71
+ rdf-xsd (0.3.7)
72
+ backports
73
+ nokogiri (>= 1.5.0)
74
+ rdf (>= 0.3.4)
75
+ rest-client (1.6.7)
76
+ mime-types (>= 1.16)
77
+ rsolr (1.0.8)
78
+ builder (>= 2.1.2)
79
+ rspec (2.11.0)
80
+ rspec-core (~> 2.11.0)
81
+ rspec-expectations (~> 2.11.0)
82
+ rspec-mocks (~> 2.11.0)
83
+ rspec-core (2.11.1)
84
+ rspec-expectations (2.11.1)
85
+ diff-lcs (~> 1.1.3)
86
+ rspec-mocks (2.11.1)
87
+ rubydora (0.5.12)
88
+ activemodel
89
+ activesupport
90
+ deprecation
91
+ fastercsv
92
+ hooks
93
+ mime-types
94
+ nokogiri
95
+ rest-client
96
+ savon
97
+ savon (1.1.0)
98
+ akami (~> 1.2.0)
99
+ builder (>= 2.1.2)
100
+ gyoku (~> 0.4.5)
101
+ httpi (~> 1.1.0)
102
+ nokogiri (>= 1.4.0)
103
+ nori (~> 1.1.0)
104
+ wasabi (~> 2.5.0)
105
+ solrizer (1.2.2)
106
+ daemons
107
+ mediashelf-loggable (~> 0.4.7)
108
+ nokogiri
109
+ om (>= 1.5.0)
110
+ stomp
111
+ xml-simple
112
+ stomp (1.2.4)
113
+ wasabi (2.5.0)
114
+ httpi (~> 1.0)
115
+ nokogiri (>= 1.4.0)
116
+ xml-simple (1.1.1)
117
+ yard (0.8.2.1)
118
+
119
+ PLATFORMS
120
+ ruby
121
+
122
+ DEPENDENCIES
123
+ RedCloth
124
+ active_fedora_relsint!
125
+ mocha (= 0.10.5)
126
+ rake
127
+ rspec (>= 2.9.0)
128
+ yard
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Columbia University Libraries, New York, NY
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.textile ADDED
@@ -0,0 +1,46 @@
1
+ ActiveFedora::RelsInt
2
+
3
+ A mixin for ActiveFedora to allow use and updating of the RELS-INT datastream.
4
+
5
+ RELS-INT is similar to RELS-EXT: A shallow (depth = 1) XML serialization of a RDF graph.
6
+ However, the subjects of triples in the RELS-INT graph are an object's datastreams.
7
+
8
+ For example, consider a Fedora object with a PID of 'test:1' that hold a TIFF image in a datastream called 'content'.
9
+ You may add various derivative images in additional datastreams, but feel that relying on encoded
10
+ datastream IDs is too fragile an approach to indicating their relationship to 'content'. You may
11
+ indicate these relationships in a RELS-INT like the below:
12
+
13
+ bc. <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
14
+ <rdf:Description rdf:about="info:fedora/test:1/content">
15
+ <pixelXDimension xmlns="http://www.kanzaki.com/ns/exif#">2400</pixelXDimension>
16
+ <pixelYDimension xmlns="http://www.kanzaki.com/ns/exif#">1600</pixelYDimension>
17
+ <thumbnail xmlns="http://xmlns.com/foaf/0.1/" rdf:resource="info:fedora/test:1/ds1" />
18
+ </rdf:Description>
19
+ <rdf:Description rdf:about="info:fedora/test:1/ds1">
20
+ <pixelXDimension xmlns="http://www.kanzaki.com/ns/exif#">150</pixelXDimension>
21
+ <pixelYDimension xmlns="http://www.kanzaki.com/ns/exif#">100</pixelYDimension>
22
+ </rdf:Description>
23
+ <rdf:Description rdf:about="info:fedora/test:1/ds2">
24
+ <pixelXDimension xmlns="http://www.kanzaki.com/ns/exif#">1500</pixelXDimension>
25
+ <pixelYDimension xmlns="http://www.kanzaki.com/ns/exif#">1000</pixelYDimension>
26
+ </rdf:Description>
27
+ </rdf:RDF>
28
+
29
+ Then with a supporting ActiveFedora model:
30
+
31
+ bc. class GenericImage < ActiveFedora::Base
32
+ include ActiveFedora::RelsInt
33
+ end
34
+
35
+ You can identify the thumbnail image by querying the RELS-INT graph:
36
+
37
+ bc. my_obj = GenericImage.find('test:1')
38
+ statement = my_obj.rels_int.relationships(my_obj.datastreams['content'],"http://xmlns.com/foaf/0.1/thumbnail").first
39
+ unless statement.nil?
40
+ dsid = statement.object.to_s.split('/')[-1] # this will be a RDF::Statement
41
+ thumb_ds = my_obj.datastreams[dsid]
42
+ end
43
+
44
+ You can also add or delete statements to the RELS-INT graph as tested in spec/unit/relsint_spec.rb
45
+
46
+ Note that the RELS-INT datastream is not able to monitor the object, so datastream deletions would require a seperate removal of the deleted datastreams subgraph in RELS-INT.
@@ -0,0 +1,35 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "active_fedora_relsint/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "active_fedora_relsint"
7
+ s.version = ActiveFedora::RelsInt::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Benjamin Armintor"]
10
+ s.email = ["armintor@gmail.com"]
11
+ s.homepage = %q{https://github.com/cul/active_fedora_rels_int}
12
+ s.summary = %q{ActiveFedora library supporting RELS-INT datastreams}
13
+ s.description = %q{ActiveFedora library to allow use of RELS-INT to track RDF assertions about datastreams via a similar api to the ActiveFedora RELS-EXT implementation}
14
+
15
+ s.rubygems_version = %q{1.3.7}
16
+
17
+ s.add_dependency('active-fedora', '>=4.2.0')
18
+ s.add_dependency("activesupport", '~>3.2.0')
19
+ s.add_dependency("rubydora", '~>0.5.11')
20
+ s.add_development_dependency("yard")
21
+ s.add_development_dependency("RedCloth") # for RDoc formatting
22
+ s.add_development_dependency("rake")
23
+ s.add_development_dependency("rspec", ">= 2.9.0")
24
+ s.add_development_dependency("mocha", "0.10.5")
25
+
26
+ s.files = `git ls-files`.split("\n")
27
+ s.test_files = `git ls-files -- {test,spec}/*`.split("\n")
28
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
29
+ s.extra_rdoc_files = [
30
+ "LICENSE.txt",
31
+ "README.textile"
32
+ ]
33
+ s.require_paths = ["lib"]
34
+
35
+ end
data/config/fedora.yml ADDED
@@ -0,0 +1,12 @@
1
+ development:
2
+ user: fedoraAdmin
3
+ password: fedoraAdmin
4
+ url: http://127.0.0.1:8983/fedora
5
+ test:
6
+ user: fedoraAdmin
7
+ password: fedoraAdmin
8
+ url: http://127.0.0.1:8983/fedora-test
9
+ production:
10
+ user: fedoraAdmin
11
+ password: fedoraAdmin
12
+ url: http://127.0.0.1:8080/fedora
@@ -0,0 +1,52 @@
1
+ # The default namespace maps to the default namespace for generating rels_ext from solr
2
+ :default_namespace: info:fedora/fedora-system:def/relations-external#
3
+
4
+ # namespace mappings---
5
+ # you can add specific mappings for your institution by providing the following:
6
+ # namespace_uri:
7
+ # :relationship_symbol: relationship_identifier
8
+ #
9
+ # For example, if you have the following element in your rels_ext:
10
+ #
11
+ # <oai:itemID>oai:example.edu:changeme:500</oai:itemID>
12
+ #
13
+ # With the last two lines of this file uncommented, the relationships hash of your object will include:
14
+ # :oai_item_id => ["info:fedora/oai:example.edu:changeme:500"]
15
+ #
16
+ :predicate_mapping:
17
+ info:fedora/fedora-system:def/relations-external#:
18
+ :conforms_to: conformsTo
19
+ :has_annotation: hasAnnotation
20
+ :has_collection_member: hasCollectionMember
21
+ :has_constituent: hasConstituent
22
+ :has_dependent: hasDependent
23
+ :has_derivation: hasDerivation
24
+ :has_description: hasDescription
25
+ :has_equivalent: hasEquivalent
26
+ :has_metadata: hasMetadata
27
+ :has_member: hasMember
28
+ :has_model: hasModel
29
+ :has_part: hasPart
30
+ :has_subset: hasSubset
31
+ :has_topic: hasTopic
32
+ :is_annotation_of: isAnnotationOf
33
+ :is_constituent_of: isConstituentOf
34
+ :is_dependent_of: isDependentOf
35
+ :is_derivation_of: isDerivationOf
36
+ :is_description_of: isDescriptionOf
37
+ :is_member_of: isMemberOf
38
+ :is_member_of_collection: isMemberOfCollection
39
+ :is_metadata_for: isMetadataFor
40
+ :is_part_of: isPartOf
41
+ :is_subset_of: isSubsetOf
42
+ :is_topic_of: isTopicOf
43
+ info:fedora/fedora-system:def/model#:
44
+ :is_contractor_of: isContractorOf
45
+ :is_deployment_of: isDeploymentOf
46
+ :has_service: hasService
47
+ :has_model: hasModel
48
+ http://www.openarchives.org/OAI/2.0/:
49
+ :oai_item_id: itemID
50
+ http://projecthydra.org/ns/relations#:
51
+ :is_governed_by: isGovernedBy
52
+ :asserts: asserts
data/config/solr.yml ADDED
@@ -0,0 +1,15 @@
1
+ development:
2
+ default:
3
+ url: http://localhost:8983/solr/development
4
+ full_text:
5
+ url: http://localhost:8983/solr/development
6
+ test:
7
+ default:
8
+ url: http://localhost:8983/solr/test
9
+ full_text:
10
+ url: http://localhost:8983/solr/test
11
+ production:
12
+ default:
13
+ url: http://localhost:8080/solr/production
14
+ full_text:
15
+ url: http://localhost:8080/solr/production
@@ -0,0 +1,2 @@
1
+ <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
2
+ </rdf:RDF>
@@ -0,0 +1,19 @@
1
+ <datastreamProfile xmlns="http://www.fedora.info/definitions/1/0/management/"
2
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+ xsi:schemaLocation="http://www.fedora.info/definitions/1/0/management/ http://www.fedora.info/definitions/1/0/datastreamProfile.xsd"
4
+ pid="test:relsint" dsID="RELS-INT">
5
+ <dsLabel>Mock Profile Response</dsLabel>
6
+ <dsVersionID>RELS-INT.0</dsVersionID>
7
+ <dsCreateDate>2012-07-23T21:56:16.636Z</dsCreateDate>
8
+ <dsState>A</dsState>
9
+ <dsMIME>application/rdf+xml</dsMIME>
10
+ <dsFormatURI />
11
+ <dsControlGroup>X</dsControlGroup>
12
+ <dsSize>802</dsSize>
13
+ <dsVersionable>true</dsVersionable>
14
+ <dsInfoType/>
15
+ <dsLocation>mocked+object</dsLocation>
16
+ <dsLocationType/>
17
+ <dsChecksumType>DISABLED</dsChecksumType>
18
+ <dsChecksum>none</dsChecksum>
19
+ </datastreamProfile>
@@ -0,0 +1,11 @@
1
+ <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
2
+ <rdf:Description rdf:about="info:fedora/test:relsint/DC">
3
+ <isMetadataFor rdf:resource="info:fedora/test:relsint/RELS-INT" xmlns="info:fedora/fedora-system:def/relations-external#"/>
4
+ </rdf:Description>
5
+ <rdf:Description rdf:about="info:fedora/test:relsint/RELS-EXT">
6
+ <asserts xmlns="http://projecthydra.org/ns/relations#">FOO</asserts>
7
+ </rdf:Description>
8
+ <rdf:Description rdf:about="info:fedora/test:relsint/RELS-INT">
9
+ <asserts xmlns="http://projecthydra.org/ns/relations#">BAR</asserts>
10
+ </rdf:Description>
11
+ </rdf:RDF>
@@ -0,0 +1,116 @@
1
+ module ActiveFedora
2
+ module RelsInt
3
+ class Datastream < ActiveFedora::Datastream
4
+ attr_accessor :relationships_loaded
5
+ def serialize!
6
+ self.content = to_rels_int() if changed_attributes.include? 'relationships'
7
+ changed_attributes.delete 'relationships'
8
+ end
9
+
10
+ def relationships_will_change!
11
+ changed_attributes['relationships'] = nil
12
+ end
13
+
14
+ def content
15
+ if self.new? and @content.nil?
16
+ content=ActiveFedora::RelsInt::Datastream.xml_template
17
+ else
18
+ super
19
+ end
20
+ end
21
+
22
+ def content= new_content
23
+ super
24
+ relationships_loaded=false
25
+ load_relationships
26
+ end
27
+
28
+ def to_resource(object, literal=false)
29
+ if object.is_a? ActiveFedora::Datastream
30
+ RDF::URI.new(object.digital_object.internal_uri + '/' + object.dsid)
31
+ elsif object.respond_to? :internal_uri
32
+ RDF::URI.new(object.internal_uri)
33
+ elsif object.is_a? RDF::Resource
34
+ object
35
+ elsif literal
36
+ RDF::Literal.new(object)
37
+ else
38
+ RDF::URI.new(object.to_s)
39
+ end
40
+ end
41
+
42
+ def to_predicate(arg)
43
+ return :p if arg.nil?
44
+ if arg.is_a? Symbol
45
+ arg = ActiveFedora::Predicates.find_graph_predicate(arg)
46
+ elsif arg.is_a? RDF::Resource
47
+ arg
48
+ else
49
+ RDF::URI.new(arg.to_s)
50
+ end
51
+ end
52
+
53
+ def build_statement(datastream, predicate, object, literal=false)
54
+ subject = to_resource(datastream)
55
+ predicate = to_predicate(predicate)
56
+ object = to_resource(object,literal)
57
+ RDF::Statement.new(subject,predicate,object)
58
+ end
59
+
60
+ def add_relationship(datastream, predicate, target, literal=false)
61
+ stmt = build_statement(datastream, predicate, target, literal)
62
+ graph.insert(stmt) unless graph.has_statement? stmt
63
+ relationships_will_change!
64
+ end
65
+
66
+ def remove_relationship(datastream, predicate, target, literal=false)
67
+ stmt = build_statement(datastream, predicate, target, literal)
68
+ graph.delete(stmt)
69
+ relationships_will_change!
70
+ end
71
+
72
+ def clear_relationship(datastream, predicate)
73
+ graph.delete [to_resource(datastream), predicate, nil]
74
+ relationships_will_change!
75
+ end
76
+
77
+ def relationships(*args)
78
+ q_args = args.empty? ? [:s, :p, :o] : [to_resource(args.first), to_predicate(args[1]), (args[2] || :o)]
79
+ query = RDF::Query.new do |query|
80
+ query << q_args
81
+ end
82
+ query.execute(graph).map(&:to_hash).map do |hash|
83
+ stmt = q_args.map {|k| hash[k] || k}
84
+ RDF::Statement.new(*stmt)
85
+ end
86
+ end
87
+
88
+ def load_relationships
89
+ # load from content
90
+ g = RDF::Graph.new
91
+ RDF::RDFXML::Reader.new(content).each do |stmt|
92
+ g << stmt
93
+ end
94
+ self.relationships_loaded = true
95
+ changed_attributes.delete 'relationships'
96
+ @graph = g
97
+ end
98
+
99
+ def graph
100
+ @graph ||= load_relationships
101
+ end
102
+
103
+ def to_rels_int
104
+ xml = ActiveFedora::RDFXMLWriter.buffer(:max_depth=>1) do |writer|
105
+ writer.prefixes.merge! ActiveFedora::Predicates.predicate_namespaces
106
+ writer.write_graph(graph)
107
+ end
108
+ xml
109
+ end
110
+
111
+ def self.xml_template
112
+ "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"></rdf:RDF>"
113
+ end
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,5 @@
1
+ module ActiveFedora
2
+ module RelsInt
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,19 @@
1
+ require 'active_support'
2
+ module ActiveFedora
3
+ module RelsInt
4
+ extend ActiveSupport::Concern
5
+ autoload :Datastream, 'active_fedora_relsint/datastream'
6
+ included do
7
+ self.has_metadata :name=>"RELS-INT", :type=>ActiveFedora::RelsInt::Datastream
8
+ end
9
+
10
+ def rels_int
11
+ if !datastreams.has_key?("RELS-INT")
12
+ ds = ActiveFedora::RelsInt::Datastream.new(@inner_object, "RELS-INT")
13
+ add_datastream(ds)
14
+ end
15
+ return datastreams["RELS-INT"]
16
+ end
17
+ end
18
+ end
19
+ require 'active_fedora_relsint/version'
@@ -0,0 +1,33 @@
1
+ ENV["environment"] ||= 'test'
2
+ require "bundler/setup"
3
+
4
+ if ENV['COVERAGE'] and RUBY_VERSION =~ /^1.9/
5
+ require 'simplecov'
6
+ require 'simplecov-rcov'
7
+
8
+ SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
9
+ SimpleCov.start
10
+ end
11
+
12
+ require 'active-fedora'
13
+ require 'active_fedora_relsint'
14
+ require 'rspec'
15
+ require 'equivalent-xml/rspec_matchers'
16
+ logger.level = Logger::WARN if logger.respond_to? :level ###MediaShelf StubLogger doesn't have a level= method
17
+ $VERBOSE=nil
18
+
19
+ # This loads the Fedora and Solr config info from /config/fedora.yml
20
+ # You can load it from a different location by passing a file path as an argument.
21
+ def restore_spec_configuration
22
+ ActiveFedora.init(:fedora_config_path=>File.join(File.dirname(__FILE__), "..", "config", "fedora.yml"))
23
+ end
24
+ restore_spec_configuration
25
+
26
+ RSpec.configure do |config|
27
+ config.mock_with :mocha
28
+ config.color_enabled = true
29
+ end
30
+
31
+ def fixture(file)
32
+ File.open(File.join(File.dirname(__FILE__), '..','fixtures', file), 'rb')
33
+ end
@@ -0,0 +1,88 @@
1
+ require 'spec_helper'
2
+
3
+ describe ActiveFedora::RelsInt do
4
+ before :all do
5
+ class Foo < ActiveFedora::Base
6
+ include ActiveFedora::RelsInt
7
+ end
8
+ end
9
+
10
+ after :all do
11
+ Object.send(:remove_const, :Foo) # cleanup
12
+ end
13
+
14
+ describe "modules" do
15
+ it "should exist" do
16
+ (defined? ActiveFedora::RelsInt).should be_true
17
+ (defined? ActiveFedora::RelsInt::Datastream).should be_true
18
+ end
19
+ end
20
+
21
+ it "should add the appropriate ds_spec and accessor methods when mixed in" do
22
+ Foo.ds_specs.keys.should include 'RELS-INT'
23
+ Foo.ds_specs['RELS-INT'][:type].should == ActiveFedora::RelsInt::Datastream
24
+ end
25
+
26
+ it "should serialize to appropriate RDF-XML" do
27
+ blank_relsint = fixture('rels_int_blank.xml').read
28
+ inner = mock("DigitalObject")
29
+ inner.stubs(:pid).returns("test:relsint")
30
+ repo = mock("Repository")
31
+ #repo.expects(:datastream_dissemination).with(:dsid=>"RELS-INT", :pid=>"test:relsint").returns("")
32
+ #inner.stubs(:repository).returns(repo)
33
+ test_obj = ActiveFedora::RelsInt::Datastream.new(inner,"RELS-INT")
34
+ Nokogiri::XML.parse(test_obj.content).should be_equivalent_to Nokogiri::XML.parse(blank_relsint)
35
+ end
36
+
37
+ describe ActiveFedora::RelsInt::Datastream do
38
+ it "should load relationships from foxml into the appropriate graphs" do
39
+ test_relsint = fixture('rels_int_test.xml').read
40
+ inner = mock("DigitalObject")
41
+ inner.stubs(:pid).returns("test:relsint")
42
+ inner.stubs(:internal_uri).returns("info:fedora/test:relsint")
43
+ repo = mock("Repository")
44
+ profile_xml = fixture('rels_int_profile.xml').read
45
+ repo.expects(:datastream).with(:pid=>inner.pid,:dsid=>"RELS-INT").returns(profile_xml)
46
+ repo.expects(:datastream_dissemination).with(:pid=>inner.pid,:dsid=>"RELS-INT").returns(test_relsint)
47
+ repo.stubs(:config).returns({})
48
+ inner.stubs(:repository).returns(repo)
49
+ test_obj = ActiveFedora::RelsInt::Datastream.new(inner,"RELS-INT")
50
+ test_obj.changed?.should be_false
51
+ dc = ActiveFedora::Datastream.new(inner,"DC")
52
+ triples = test_obj.relationships(dc,:is_metadata_for)
53
+ e = ['info:fedora/test:relsint/DC','info:fedora/fedora-system:def/relations-external#isMetadataFor','info:fedora/test:relsint/RELS-INT'].
54
+ map {|x| RDF::URI.new(x)}
55
+ triples.should == [RDF::Statement.new(*e)]
56
+ end
57
+ it "should load relationships into appropriate graphs when assigned content" do
58
+ test_relsint = fixture('rels_int_test.xml').read
59
+ inner = mock("DigitalObject")
60
+ inner.stubs(:pid).returns("test:relsint")
61
+ inner.stubs(:internal_uri).returns("info:fedora/test:relsint")
62
+ test_obj = ActiveFedora::RelsInt::Datastream.new(inner,"RELS-INT")
63
+ test_obj.content=test_relsint
64
+ test_obj.changed?.should be_true
65
+ dc = ActiveFedora::Datastream.new(inner,"DC")
66
+ triples = test_obj.relationships(dc,:is_metadata_for)
67
+ e = ['info:fedora/test:relsint/DC','info:fedora/fedora-system:def/relations-external#isMetadataFor','info:fedora/test:relsint/RELS-INT'].
68
+ map {|x| RDF::URI.new(x)}
69
+ triples.should == [RDF::Statement.new(*e)]
70
+ end
71
+ it "should propagate relationship changes to the appropriate graph in RELS-INT" do
72
+ test_relsint = fixture('rels_int_test.xml').read
73
+ inner = mock("DigitalObject")
74
+ inner.stubs(:pid).returns("test:relsint")
75
+ inner.stubs(:internal_uri).returns("info:fedora/test:relsint")
76
+ test_obj = ActiveFedora::RelsInt::Datastream.new(inner,"RELS-INT")
77
+ dc = ActiveFedora::Datastream.new(inner,"DC")
78
+ rels_ext = ActiveFedora::Datastream.new(inner,"RELS-EXT")
79
+ test_obj.add_relationship(dc,:is_metadata_for, test_obj)
80
+ test_obj.add_relationship(rels_ext,:asserts, "FOO", true)
81
+ test_obj.add_relationship(test_obj,:asserts, "BAR", true)
82
+ test_obj.serialize!
83
+ test_obj.changed?.should be_true
84
+ puts test_obj.content
85
+ Nokogiri::XML.parse(test_obj.content).should be_equivalent_to Nokogiri::XML.parse(test_relsint)
86
+ end
87
+ end
88
+ end
metadata ADDED
@@ -0,0 +1,195 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: active_fedora_relsint
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Benjamin Armintor
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: active-fedora
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 4.2.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 4.2.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: activesupport
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 3.2.0
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 3.2.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: rubydora
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.5.11
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.5.11
62
+ - !ruby/object:Gem::Dependency
63
+ name: yard
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: RedCloth
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rake
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rspec
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: 2.9.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: 2.9.0
126
+ - !ruby/object:Gem::Dependency
127
+ name: mocha
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - '='
132
+ - !ruby/object:Gem::Version
133
+ version: 0.10.5
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - '='
140
+ - !ruby/object:Gem::Version
141
+ version: 0.10.5
142
+ description: ActiveFedora library to allow use of RELS-INT to track RDF assertions
143
+ about datastreams via a similar api to the ActiveFedora RELS-EXT implementation
144
+ email:
145
+ - armintor@gmail.com
146
+ executables: []
147
+ extensions: []
148
+ extra_rdoc_files:
149
+ - LICENSE.txt
150
+ - README.textile
151
+ files:
152
+ - Gemfile
153
+ - Gemfile.lock
154
+ - LICENSE.txt
155
+ - README.textile
156
+ - active_fedora_relsint.gemspec
157
+ - config/fedora.yml
158
+ - config/predicate_mappings.yml
159
+ - config/solr.yml
160
+ - fixtures/rels_int_blank.xml
161
+ - fixtures/rels_int_profile.xml
162
+ - fixtures/rels_int_test.xml
163
+ - lib/active_fedora_relsint.rb
164
+ - lib/active_fedora_relsint/datastream.rb
165
+ - lib/active_fedora_relsint/version.rb
166
+ - spec/spec_helper.rb
167
+ - spec/unit/relsint_spec.rb
168
+ homepage: https://github.com/cul/active_fedora_rels_int
169
+ licenses: []
170
+ post_install_message:
171
+ rdoc_options: []
172
+ require_paths:
173
+ - lib
174
+ required_ruby_version: !ruby/object:Gem::Requirement
175
+ none: false
176
+ requirements:
177
+ - - ! '>='
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ required_rubygems_version: !ruby/object:Gem::Requirement
181
+ none: false
182
+ requirements:
183
+ - - ! '>='
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
186
+ requirements: []
187
+ rubyforge_project:
188
+ rubygems_version: 1.8.24
189
+ signing_key:
190
+ specification_version: 3
191
+ summary: ActiveFedora library supporting RELS-INT datastreams
192
+ test_files:
193
+ - spec/spec_helper.rb
194
+ - spec/unit/relsint_spec.rb
195
+ has_rdoc: