Skip to content

Commit

Permalink
Merge pull request #1075 from projecthydra/deprecate_simple_ds
Browse files Browse the repository at this point in the history
Deprecate AF::SimpleDatastream
  • Loading branch information
cbeer committed May 9, 2016
2 parents 355bf99 + 42d951b commit 947410a
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 235 deletions.
2 changes: 2 additions & 0 deletions lib/active_fedora/simple_datastream.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module ActiveFedora
# This class represents a simple xml datastream.
class SimpleDatastream < OmDatastream
extend Deprecation
class_attribute :class_fields
attr_accessor :fields
self.class_fields = []
Expand All @@ -18,6 +19,7 @@ class SimpleDatastream < OmDatastream
# Constructor. this class will call self.field for each DCTERM. In short, all DCTERMS fields will already exist
# when this method returns. Each term is marked as a multivalue string.
def initialize(digital_object = nil, dsid = nil, options = {}, &block)
Deprecation.warn(SimpleDatastream, "ActiveFedora::SimpleDatastream is deprecated and will be removed in ActiveFedora 10.0")
self.fields = {}
super
end
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/attached_files_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def load_attached_files
end

describe ".metadata_streams" do
let(:mds1) { ActiveFedora::SimpleDatastream.new }
let(:mds1) { ActiveFedora::QualifiedDublinCoreDatastream.new }
let(:mds2) { ActiveFedora::QualifiedDublinCoreDatastream.new }
let(:fds) { ActiveFedora::File.new }
before do
Expand Down
8 changes: 1 addition & 7 deletions spec/integration/attributes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@ class PropertiesDatastream < ActiveFedora::OmDatastream
end
end
class TitledObject < ActiveFedora::Base
extend Deprecation

Deprecation.silence(TitledObject) do
has_metadata 'foo', type: ActiveFedora::SimpleDatastream do |m|
m.field "title", :string
end
end
has_subresource 'foo', class_name: 'ActiveFedora::QualifiedDublinCoreDatastream'
Deprecation.silence(ActiveFedora::Attributes) do
has_attributes :title, datastream: 'foo', multiple: false
end
Expand Down
163 changes: 0 additions & 163 deletions spec/integration/full_featured_model_spec.rb

This file was deleted.

17 changes: 10 additions & 7 deletions spec/integration/json_serialization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@

context "with properties and datastream attributes" do
before do
class Foo < ActiveFedora::Base
extend Deprecation
Deprecation.silence(Foo) do
has_metadata 'descMetadata', type: ActiveFedora::SimpleDatastream do |m|
m.field "foo", :text
m.field "bar", :text
end
class MyDS < ActiveFedora::OmDatastream
set_terminology do |t|
t.root(path: "durh")
t.foo
t.bar
end
end

class Foo < ActiveFedora::Base
has_subresource 'descMetadata', class_name: 'MyDS'
Deprecation.silence(ActiveFedora::Attributes) do
has_attributes :foo, datastream: 'descMetadata', multiple: true
has_attributes :bar, datastream: 'descMetadata', multiple: false
Expand All @@ -25,6 +27,7 @@ class Foo < ActiveFedora::Base

after do
Object.send(:remove_const, :Foo)
Object.send(:remove_const, :MyDS)
end

let(:obj) { Foo.new(foo: ["baz"], bar: 'quix', title: ['My Title']) }
Expand Down
17 changes: 10 additions & 7 deletions spec/integration/solr_hit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

describe ActiveFedora::SolrHit do
before do
class Foo < ActiveFedora::Base
extend Deprecation
Deprecation.silence(self) do
has_metadata 'descMetadata', type: ActiveFedora::SimpleDatastream do |m|
m.field "foo", :text
m.field "bar", :text
end
class MyDS < ActiveFedora::OmDatastream
set_terminology do |t|
t.root(path: "durh")
t.foo
t.bar
end
end

class Foo < ActiveFedora::Base
has_subresource 'descMetadata', class_name: 'MyDS'
Deprecation.silence(ActiveFedora::Attributes) do
has_attributes :foo, datastream: 'descMetadata', multiple: true
has_attributes :bar, datastream: 'descMetadata', multiple: false
Expand All @@ -32,6 +34,7 @@ class Foo < ActiveFedora::Base

after do
Object.send(:remove_const, :Foo)
Object.send(:remove_const, :MyDS)
end

describe "#reify" do
Expand Down
16 changes: 10 additions & 6 deletions spec/integration/solr_instance_loader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

describe ActiveFedora::SolrInstanceLoader do
before do
class MyDS < ActiveFedora::OmDatastream
set_terminology do |t|
t.root(path: "durh")
t.foo
t.bar
end
end

class Foo < ActiveFedora::Base
extend Deprecation
Deprecation.silence(Foo) do
has_metadata 'descMetadata', type: ActiveFedora::SimpleDatastream do |m|
m.field "foo", :text
m.field "bar", :text
end
end
has_subresource 'descMetadata', class_name: 'MyDS'
Deprecation.silence(ActiveFedora::Attributes) do
has_attributes :foo, datastream: 'descMetadata', multiple: true
has_attributes :bar, datastream: 'descMetadata', multiple: false
Expand Down Expand Up @@ -41,6 +44,7 @@ class Bar < ActiveFedora::Base
after do
Object.send(:remove_const, :Foo)
Object.send(:remove_const, :Bar)
Object.send(:remove_const, :MyDS)
end

context "without a solr doc" do
Expand Down
12 changes: 6 additions & 6 deletions spec/unit/attached_files_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class Z < ActiveFedora::File
end
class FooHistory < ActiveFedora::Base
has_subresource 'dsid', class_name: 'ActiveFedora::SimpleDatastream'
has_subresource 'dsid', class_name: 'ActiveFedora::QualifiedDublinCoreDatastream'
has_subresource 'complex_ds', autocreate: true, class_name: 'Z'
has_subresource 'thumbnail'
has_subresource 'child_resource', class_name: 'ActiveFedora::Base'
Expand All @@ -30,8 +30,8 @@ class FooHistory < ActiveFedora::Base
end

it "raises an error if you don't give a dsid" do
expect { FooHistory.has_subresource nil, type: ActiveFedora::SimpleDatastream }.to raise_error ArgumentError,
"You must provide a path name (f.k.a. dsid) for the resource"
expect { FooHistory.has_subresource nil, type: ActiveFedora::QualifiedDublinCoreDatastream }.to raise_error ArgumentError,
"You must provide a path name (f.k.a. dsid) for the resource"
end
end

Expand All @@ -42,7 +42,7 @@ class Z < ActiveFedora::File
class FooHistory < ActiveFedora::Base
extend Deprecation
Deprecation.silence(FooHistory) do
has_metadata name: 'dsid', type: ActiveFedora::SimpleDatastream
has_metadata name: 'dsid', type: ActiveFedora::QualifiedDublinCoreDatastream
has_metadata 'complex_ds', autocreate: true, type: 'Z'
end
end
Expand All @@ -57,7 +57,7 @@ class FooHistory < ActiveFedora::Base
end

it "has reasonable defaults" do
expect(FooHistory.child_resource_reflections[:dsid].options).to include(class_name: 'ActiveFedora::SimpleDatastream')
expect(FooHistory.child_resource_reflections[:dsid].options).to include(class_name: 'ActiveFedora::QualifiedDublinCoreDatastream')
end

it "lets you override defaults" do
Expand All @@ -77,7 +77,7 @@ class FooHistory < ActiveFedora::Base
it "raises an error if you don't give a dsid" do
expect {
Deprecation.silence(FooHistory) do
FooHistory.has_metadata type: ActiveFedora::SimpleDatastream
FooHistory.has_metadata type: ActiveFedora::QualifiedDublinCoreDatastream
end
}.to raise_error ArgumentError,
"You must provide a path name (f.k.a. dsid) for the resource"
Expand Down
29 changes: 12 additions & 17 deletions spec/unit/attributes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,18 @@ class BarHistory4 < ActiveFedora::Base

describe "first level delegation" do
before do
class BarHistory2 < ActiveFedora::Base
extend Deprecation
Deprecation.silence(self) do
has_metadata type: ActiveFedora::SimpleDatastream, name: "someData" do |m|
m.field "fubar", :string
m.field "bandana", :string
m.field "swank", :text
m.field "animal_id", :string
end
has_metadata type: ActiveFedora::SimpleDatastream, name: "withText" do |m|
m.field "fubar", :text
end
has_metadata type: ActiveFedora::SimpleDatastream, name: "withText2" do |m|
m.field "fubar", :text
end
class MyDS1 < ActiveFedora::NtriplesRDFDatastream
property :animal_id, predicate: ::RDF::Vocab::DC.publisher
end
class MyDS2 < ActiveFedora::OmDatastream
set_terminology do |t|
t.root(path: "durh")
t.fubar
end

end
class BarHistory2 < ActiveFedora::Base
has_subresource 'someData', class_name: 'MyDS1'
has_subresource "withText", class_name: 'MyDS2'
has_subresource 'xmlish', class_name: 'BarStream2'
Deprecation.silence(ActiveFedora::Attributes) do
has_attributes :cow, datastream: 'xmlish' # for testing the default value of multiple
Expand Down Expand Up @@ -345,7 +340,7 @@ class BarHistory3 < BarHistory2

describe ".datastream_class_for_name" do
it "returns the specifed class" do
expect(BarHistory2.send(:datastream_class_for_name, 'someData')).to eq ActiveFedora::SimpleDatastream
expect(BarHistory2.send(:datastream_class_for_name, 'someData')).to eq MyDS1
end
end
end
Expand Down
Loading

0 comments on commit 947410a

Please sign in to comment.