Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6x dependencies #1157

Merged
merged 4 commits into from
Oct 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
sudo: false
language: ruby
rvm:
- 1.9.3
- 2.0.0
- 2.1.2
- 2.2.0

gemfile:
- gemfiles/gemfile.rails3
- gemfiles/gemfile.rails4
- 2.2.5
- 2.3.1

notifications:
irc: "irc.freenode.org#projecthydra"

before_install:
- gem install bundler

jdk: oraclejdk8
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source "http://rubygems.org"
source "https://rubygems.org"

# Bundler will rely on active-fedora.gemspec for dependency information.

Expand All @@ -10,3 +10,5 @@ group :development, :test do
end

gem 'jruby-openssl', :platform=> :jruby

gem 'activemodel', '~> 4.2'
15 changes: 7 additions & 8 deletions active-fedora.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ Gem::Specification.new do |s|
s.required_ruby_version = '>= 1.9.3'

s.add_dependency('rsolr')
s.add_dependency('om', '~> 3.0.0')
s.add_dependency('om', '~> 3.0')
s.add_dependency('nom-xml', '>=0.5.1')
s.add_dependency("activesupport", '>= 3.0.0')
s.add_dependency("activesupport", '>= 3')
s.add_dependency("mediashelf-loggable")
s.add_dependency("rubydora", '~> 1.7.4')
s.add_dependency("rdf", '~> 1.1.1.1')
s.add_dependency("rdf-rdfxml", '1.0.1')
s.add_dependency("rubydora", '~>1.6', '>= 1.6.5')
s.add_dependency("rdf", '~> 1.1', '>= 1.1.1.1')
s.add_dependency("rdf-rdfxml", '~>1.1')
s.add_dependency("deprecation")
s.add_development_dependency("rdoc")
s.add_development_dependency("yard")
s.add_development_dependency("RedCloth") # for RDoc formatting
s.add_development_dependency("rake")
s.add_development_dependency("jettywrapper", ">=1.4.0")
s.add_development_dependency("rspec", "~> 2.9")
s.add_development_dependency("rspec", "~> 2.99")
s.add_development_dependency("equivalent-xml")
s.add_development_dependency("rest-client")
s.add_development_dependency("webmock")

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
Expand All @@ -43,4 +43,3 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]

end

11 changes: 0 additions & 11 deletions gemfiles/gemfile.rails3

This file was deleted.

10 changes: 0 additions & 10 deletions gemfiles/gemfile.rails4

This file was deleted.

1 change: 1 addition & 0 deletions lib/active_fedora/om_datastream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def content=(new_content)

def content_changed?
return false if !xml_loaded
return true if changed_attributes.any?
super
end

Expand Down
93 changes: 31 additions & 62 deletions lib/active_fedora/rdf_xml_writer.rb
Original file line number Diff line number Diff line change
@@ -1,80 +1,49 @@
require 'uri'
require 'rdf/rdfxml'

module ActiveFedora
# This class ensures that the RELS-EXT datastream is always serialized
# with an rdf:Description container for the properties
# the default behavior for RDF:RDFXML::Writer is to change that element if
# an rdf:type assertion is present; this is incompatible with Fedora
# an rdf:type assertion is present; this is incompatible with Fedora 3
class RDFXMLWriter < RDF::RDFXML::Writer
def subject(subject, parent_node)

raise RDF::WriterError, "Illegal use of subject #{subject.inspect}, not supported in RDF/XML" unless subject.resource?

node = if !is_done?(subject)
subject_not_done(subject, parent_node)
elsif @force_RDF_about.include?(subject)
force_about(subject, parent_node)
end
@force_RDF_about.delete(subject)
# Display a subject.
#
# If the Haml template contains an entry matching the subject's rdf:type URI, that entry will be used as the template for this subject and it's properties.
#
# @example Displays a subject as a Resource Definition:
# <div typeof="rdfs:Resource" about="http://example.com/resource">
# <h1 property="dc:title">label</h1>
# <ul>
# <li content="2009-04-30T06:15:51Z" property="dc:created">2009-04-30T06:15:51+00:00</li>
# </ul>
# </div>
#
# @param [RDF::Resource] subject
# @param [Hash{Symbol => Object}] options
# @option options [:li, nil] :element(:div)
# Serialize using &lt;li&gt; rather than template default element
# @option options [RDF::Resource] :rel (nil)
# Optional @rel property
# @return [Nokogiri::XML::Element, {Namespace}]
#
def subject(subject, options = {})
return if is_done?(subject)

parent_node.add_child(node) if node
end

private

def force_about(subject, parent_node)
add_debug {"subject: #{subject.inspect}, force about"}
node = Nokogiri::XML::Element.new("rdf:Description", parent_node.document)
if subject.is_a?(RDF::Node)
node["rdf:nodeID"] = subject.id
else
node["rdf:about"] = relativize(subject)
end
node
end

def subject_not_done(subject, parent_node)
subject_done(subject)
properties = @graph.properties(subject)
add_debug {"subject: #{subject.inspect}, props: #{properties.inspect}"}

@graph.query(:subject => subject).each do |st|
raise RDF::WriterError, "Illegal use of predicate #{st.predicate.inspect}, not supported in RDF/XML" unless st.predicate.uri?
end

properties = properties_for_subject(subject)
typeof = type_of(properties[RDF.type.to_s], subject)
prop_list = order_properties(properties)
add_debug {"=> property order: #{prop_list.to_sentence}"}

qname = "rdf:Description"
prefixes[:rdf] = RDF.to_uri
add_debug {"subject: #{curie.inspect}, typeof: #{typeof.inspect}, props: #{prop_list.inspect}"}

node = Nokogiri::XML::Element.new(qname, parent_node.document)

if subject.is_a?(RDF::Node)
# Only need nodeID if it's referenced elsewhere
if ref_count(subject) > (@depth == 0 ? 0 : 1)
node["rdf:nodeID"] = subject.id
else
node.add_child(Nokogiri::XML::Comment.new(node.document, "Serialization for #{subject}")) if RDF::RDFXML::debug?
end
else
node["rdf:about"] = relativize(subject)
end
render_opts = {:typeof => typeof, :property_values => properties}.merge(options)

prop_list.each do |prop|
prop_ref = RDF::URI.intern(prop)

properties[prop].each do |object|
raise RDF::WriterError, "Illegal use of object #{object.inspect}, not supported in RDF/XML" unless object.resource? || object.literal?

@depth += 1
predicate(prop_ref, object, node, properties[prop].length == 1)
@depth -= 1
end
end
node
render_subject_template(subject, prop_list, render_opts)
end

def type_of(type, subject)
""
end
end
end
2 changes: 1 addition & 1 deletion spec/integration/complex_rdf_datastream_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class MediatorUser
comp = SpecDatastream::MediatorUser.new ds.graph
comp.title = ['Doctor']
ds.mediator = comp
expect(ds.mediator.first.type.first).to be_instance_of RDF::URI
expect(ds.mediator.first.type.first).to be_instance_of RDF::Vocabulary::Term
expect(ds.mediator.first.type.first.to_s).to eq('http://purl.org/dc/terms/AgentClass')
expect(ds.mediator.first.title.first).to eq('Doctor')
end
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/active_fedora_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class OtherSiblingClass
it "should raise a NameError if the class isn't found" do
expect {
ActiveFedora.class_from_string('FooClass', ParentClass::OtherSiblingClass)
}.to raise_error NameError, 'uninitialized constant FooClass'
}.to raise_error NameError, /uninitialized constant FooClass/
end
end
end
61 changes: 19 additions & 42 deletions spec/unit/rdf_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,15 @@ class TemporalElement
subject[1].elementValue = 'Relations with Mexican Americans'
subject[2] = RDF::URI.new 'http://library.ucsd.edu/ark:/20775/bbXXXXXXX4'
subject[3] = DemoList::List::TemporalElement.new(ds.graph)
subject[3].elementValue = '20th century'
expected_xml = <<END
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:mads="http://www.loc.gov/mads/rdf/v1#">

<rdf:Description rdf:about="info:fedora/foo">
<mads:elementList rdf:parseType="Collection">
<rdf:Description rdf:about="http://library.ucsd.edu/ark:/20775/bbXXXXXXX6"/>
<mads:TopicElement>
<mads:elementValue>Relations with Mexican Americans</mads:elementValue>
</mads:TopicElement>
<rdf:Description rdf:about="http://library.ucsd.edu/ark:/20775/bbXXXXXXX4"/>
<mads:TemporalElement>
<mads:elementValue>20th century</mads:elementValue>
</mads:TemporalElement>
</mads:elementList>
</rdf:Description>
</rdf:RDF>
END
expect(ds.content).to be_equivalent_to expected_xml
subject[3].elementValue = "20th century"
doc = Nokogiri::XML(ds.content)
ns = {rdf: "http://www.w3.org/1999/02/22-rdf-syntax-ns#", mads: "http://www.loc.gov/mads/rdf/v1#"}
expect(doc.xpath('/rdf:RDF/rdf:Description/@rdf:about', ns).map(&:value)).to eq ["info:fedora/foo"]
expect(doc.xpath('//rdf:Description/mads:elementList/@rdf:parseType', ns).map(&:value)).to eq ["Collection"]
expect(doc.xpath('//rdf:Description/mads:elementList/*[position() = 1]/@rdf:about', ns).map(&:value)).to eq ["http://library.ucsd.edu/ark:/20775/bbXXXXXXX6"]
expect(doc.xpath('//rdf:Description/mads:elementList/*[position() = 2]/mads:elementValue', ns).map(&:text)).to eq ["Relations with Mexican Americans"]
expect(doc.xpath('//rdf:Description/mads:elementList/*[position() = 3]/@rdf:about', ns).map(&:value)).to eq ["http://library.ucsd.edu/ark:/20775/bbXXXXXXX4"]
expect(doc.xpath('//rdf:Description/mads:elementList/*[position() = 4]/mads:elementValue', ns).map(&:text)).to eq ["20th century"]
end
end

Expand Down Expand Up @@ -187,28 +176,16 @@ class TemporalElement
expect(list.size).to eq(4)
end

it 'should update fields' do
list[3].elementValue = ['1900s']
expected_xml = <<END
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:mads="http://www.loc.gov/mads/rdf/v1#">

<mads:ComplexSubject rdf:about="info:fedora/foo">
<mads:elementList rdf:parseType="Collection">
<rdf:Description rdf:about="http://library.ucsd.edu/ark:/20775/bbXXXXXXX6"/>
<mads:TopicElement>
<mads:elementValue>Relations with Mexican Americans</mads:elementValue>
</mads:TopicElement>
<rdf:Description rdf:about="http://library.ucsd.edu/ark:/20775/bbXXXXXXX4"/>
<mads:TemporalElement>
<mads:elementValue>1900s</mads:elementValue>
</mads:TemporalElement>
</mads:elementList>
</mads:ComplexSubject>
</rdf:RDF>

END
expect(subject.content).to be_equivalent_to expected_xml
it "should update fields" do
list[3].elementValue = ["1900s"]
doc = Nokogiri::XML(subject.content)
ns = {rdf: "http://www.w3.org/1999/02/22-rdf-syntax-ns#", mads: "http://www.loc.gov/mads/rdf/v1#"}
expect(doc.xpath('/rdf:RDF/mads:ComplexSubject/@rdf:about', ns).map(&:value)).to eq ["info:fedora/foo"]
expect(doc.xpath('//mads:ComplexSubject/mads:elementList/@rdf:parseType', ns).map(&:value)).to eq ["Collection"]
expect(doc.xpath('//mads:ComplexSubject/mads:elementList/*[position() = 1]/@rdf:about', ns).map(&:value)).to eq ["http://library.ucsd.edu/ark:/20775/bbXXXXXXX6"]
expect(doc.xpath('//mads:ComplexSubject/mads:elementList/*[position() = 2]/mads:elementValue', ns).map(&:text)).to eq ["Relations with Mexican Americans"]
expect(doc.xpath('//mads:ComplexSubject/mads:elementList/*[position() = 3]/@rdf:about', ns).map(&:value)).to eq ["http://library.ucsd.edu/ark:/20775/bbXXXXXXX4"]
expect(doc.xpath('//mads:ComplexSubject/mads:elementList/*[position() = 4]/mads:elementValue', ns).map(&:text)).to eq ["1900s"]
end
end
end
3 changes: 1 addition & 2 deletions spec/unit/rels_ext_datastream_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@
new_ds.model = model
ActiveFedora::RelsExtDatastream.from_xml(xml, new_ds)
new_ext = new_ds.to_rels_ext()
expect(new_ext).to match '<ns0:itemID>oai:hull.ac.uk:hull:2708</ns0:itemID>'

new_ext.should match "<ns2:itemID>oai:hull.ac.uk:hull:2708</ns2:itemID>"
end
end

Expand Down