-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation of PCDM::File. Fixes #19
- Loading branch information
Showing
4 changed files
with
30 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'activefedora-aggregation', github: 'projecthydra-labs/activefedora-aggregation', branch: 'master' | ||
gem 'activefedora-aggregation', github: 'projecthydra-labs/activefedora-aggregation' | ||
gem 'active-fedora', github: 'projecthydra/active_fedora' | ||
|
||
# Specify your gem's dependencies in hydra-pcdm.gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,10 @@ | ||
module Hydra::PCDM | ||
class File < ActiveFedora::File | ||
type RDFVocabularies::PCDMTerms.File # TODO switch to using generated vocabulary when ready | ||
|
||
# behavior: | ||
# 1) PCDM::File can NOT aggregate anything | ||
# 2) PCDM::File can NOT contain PCDM::File | ||
# 3) PCDM::File can have technical metadata about one uploaded binary file | ||
# TODO: add code to enforce behavior rules | ||
|
||
# TODO: The only expected additional behavior for PCDM::File beyond ActiveFedora::File is the expression | ||
# of additional technical metadata | ||
include ActiveFedora::WithMetadata | ||
|
||
metadata do | ||
configure type: RDFVocabularies::PCDMTerms.File | ||
property :label, predicate: ::RDF::RDFS.label | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,25 @@ | ||
require 'spec_helper' | ||
|
||
describe 'Hydra::PCDM::File' do | ||
describe Hydra::PCDM::File do | ||
|
||
# subject { Hydra::PCDM::Object.new } | ||
|
||
# There isn't a #members method on Hydra::PCDM::File, so no need to test what can and can't be aggregated. | ||
# 1) Hydra::PCDM::File can NOT aggregate anything | ||
|
||
# There isn't a #contains method on Hydra::PCDM::File, so no need to test if Hydra::PCDM::File can contain Hydra::PCDM::File | ||
# 2) Hydra::PCDM::File can NOT contain Hydra::PCDM::File | ||
|
||
# TODO: What method is used to set metadata in a Hydra::PCDM::File | ||
describe '#METHOD_NAME' do | ||
xit 'should be able to add metadata about an uploaded file' do | ||
# 3) Hydra::PCDM::File can set/hold technical metadata for an uploaded file | ||
|
||
# TODO Write test | ||
let(:file) { Hydra::PCDM::File.new } | ||
let(:reloaded) { Hydra::PCDM::File.new(file.uri) } | ||
|
||
describe "when saving" do | ||
it "sets an RDF type" do | ||
file.content = 'stuff' | ||
expect(file.save).to be true | ||
expect(reloaded.metadata_node.query(predicate: RDF.type, object: RDFVocabularies::PCDMTerms.File).map(&:object)).to eq [RDFVocabularies::PCDMTerms.File] | ||
end | ||
|
||
end | ||
|
||
describe "#label" do | ||
it "saves a label" do | ||
file.content = 'stuff' | ||
file.label = 'foo' | ||
expect(file.label).to eq ['foo'] | ||
expect(file.save).to be true | ||
expect(reloaded.label).to eq ['foo'] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters