Skip to content
This repository has been archived by the owner on May 14, 2022. It is now read-only.

Commit

Permalink
Merge pull request #53 from pulibrary/iiif_properties
Browse files Browse the repository at this point in the history
Add IIIF schema.
  • Loading branch information
Jon Stroop committed Sep 8, 2015
2 parents 3b98f57 + 8e378fb commit 7f241ee
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/generic_file.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Generated by curation_concerns:models:install
class GenericFile < ActiveFedora::Base
include ::CurationConcerns::GenericFileBehavior
apply_schema IIIFPageSchema
end
3 changes: 3 additions & 0 deletions app/models/scanned_book.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ class ScannedBook < ActiveFedora::Base
property :source_metadata_identifier, predicate: ::RDF::URI.new('http://library.princeton.edu/terms/metadata_id'), multiple: false
property :source_metadata, predicate: ::RDF::URI.new('http://library.princeton.edu/terms/source_metadata'), multiple: false

# IIIF
apply_schema IIIFBookSchema

validate :source_metadata_identifier_or_title
validates :access_policy, presence: { message: 'You must choose an Access Policy statement.' }
validates :use_and_reproduction, presence: { message: 'You must provide a use statement.' }
Expand Down
4 changes: 4 additions & 0 deletions app/schemas/iiif_book_schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class IIIFBookSchema < ActiveTriples::Schema
property :viewing_direction, predicate: ::RDF::Vocab::IIIF.viewingDirection, multiple: false
property :viewing_hint, predicate: ::RDF::Vocab::IIIF.viewingHint, multiple: false
end
3 changes: 3 additions & 0 deletions app/schemas/iiif_page_schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class IIIFPageSchema < ActiveTriples::Schema
property :viewing_hint, predicate: ::RDF::Vocab::IIIF.viewingHint, multiple: false
end
11 changes: 11 additions & 0 deletions spec/models/generic_file_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'rails_helper'

RSpec.describe GenericFile do
subject { described_class.new.tap { |x| x.apply_depositor_metadata("bob") } }

describe "#viewing_hint" do
it "has the right predicate" do
expect(described_class.properties["viewing_hint"].predicate).to eq ::RDF::Vocab::IIIF.viewingHint
end
end
end
12 changes: 12 additions & 0 deletions spec/models/scanned_book_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,16 @@
expect(noid_service.valid? subject.id).to be_truthy
end
end

describe "#viewing_direction" do
it "maps to the IIIF predicate" do
expect(described_class.properties["viewing_direction"].predicate).to eq RDF::Vocab::IIIF.viewingDirection
end
end

describe "#viewing_hint" do
it "maps to the IIIF predicate" do
expect(described_class.properties["viewing_hint"].predicate).to eq RDF::Vocab::IIIF.viewingHint
end
end
end

0 comments on commit 7f241ee

Please sign in to comment.