This repository has been archived by the owner on Jun 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
88316a2
commit 15863bf
Showing
14 changed files
with
241 additions
and
95 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 |
---|---|---|
|
@@ -13,8 +13,6 @@ script: "bundle exec rake dul_hydra:ci:build" | |
notifications: | ||
email: | ||
- [email protected] | ||
env: | ||
- EXTERNAL_FILE_STORE="/tmp" | ||
# To exclude antivirus tests: | ||
# env: | ||
# - SPEC_OPTS="--tag ~antivirus" | ||
|
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module DulHydra | ||
module DatastreamBehavior | ||
|
||
# Returns a list of the external file paths for all versions of the datastream. | ||
def file_paths | ||
raise "The `file_paths' method is valid only for external datastreams." unless external? | ||
return Array(file_path) if new? | ||
versions.map(&:file_path).compact | ||
end | ||
|
||
# Returns the external file path for the datastream. | ||
# Returns nil if dsLocation is not a file URI. | ||
def file_path | ||
raise "The `file_path' method is valid only for external datastreams." unless external? | ||
DulHydra::Utils.path_from_uri(dsLocation) if DulHydra::Utils.file_uri?(dsLocation) | ||
end | ||
|
||
# Returns the file name of the external file for the datastream. | ||
# See #external_datastream_file_path(ds) | ||
def file_name | ||
raise "The `file_name' method is valid only for external datastreams." unless external? | ||
if path = file_path | ||
File.basename(path) | ||
end | ||
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
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
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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module ActiveFedora | ||
class Datastream | ||
include DulHydra::DatastreamBehavior | ||
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require 'spec_helper' | ||
|
||
module ActiveFedora | ||
describe Datastream do | ||
|
||
describe "extensions for external datastreams" do | ||
subject { described_class.new(nil, nil, controlGroup: "E") } | ||
|
||
describe "#file_path" do | ||
it "should return nil when dsLocation is not set" do | ||
expect(subject.file_path).to be_nil | ||
end | ||
it "should return nil when dsLocation is not a file URI" do | ||
subject.dsLocation = "http://library.duke.edu/" | ||
expect(subject.file_path).to be_nil | ||
end | ||
it "should return the file path when dsLocation is a file URI" do | ||
subject.dsLocation = "file:/tmp/foo/bar.txt" | ||
expect(subject.file_path).to eq "/tmp/foo/bar.txt" | ||
end | ||
end | ||
|
||
describe "#file_name" do | ||
it "should return nil when dsLocation is not set" do | ||
expect(subject.file_name).to be_nil | ||
end | ||
it "should return nil when dsLocation is not a file URI" do | ||
subject.dsLocation = "http://library.duke.edu/" | ||
expect(subject.file_name).to be_nil | ||
end | ||
it "should return the file name when dsLocation is a file URI" do | ||
subject.dsLocation = "file:/tmp/foo/bar.txt" | ||
expect(subject.file_name).to eq "bar.txt" | ||
end | ||
end | ||
|
||
end # external datastreams | ||
|
||
end | ||
end |
Oops, something went wrong.