-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from mlibrary/alma-digital
adds logic to handle a digital holding
- Loading branch information
Showing
5 changed files
with
131 additions
and
1 deletion.
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
42 changes: 42 additions & 0 deletions
42
umich_catalog_indexing/lib/umich_traject/digital_holding.rb
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,42 @@ | ||
module Traject | ||
module UMich | ||
class DigitalHolding | ||
def initialize(avd) | ||
@avd = avd | ||
end | ||
def note | ||
@avd["z"] | ||
end | ||
def link | ||
URI::Parser.new.escape(@avd["u"].sub("01UMICH_INST:FLINT","01UMICH_INST:UMICH")) | ||
end | ||
def library | ||
"ELEC" | ||
end | ||
def status | ||
"Available" | ||
end | ||
def link_text | ||
"Available online" | ||
end | ||
def description | ||
"" | ||
end | ||
def finding_aid | ||
false | ||
end | ||
def to_h | ||
{ | ||
finding_aid: finding_aid, | ||
library: library, | ||
link: link, | ||
link_text: link_text, | ||
note: note, | ||
status: status, | ||
description: description | ||
} | ||
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
Large diffs are not rendered by default.
Oops, something went wrong.
70 changes: 70 additions & 0 deletions
70
umich_catalog_indexing/spec/traject/umich/digital_holding_spec.rb
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,70 @@ | ||
require "traject" | ||
require "umich_traject" | ||
describe Traject::UMich::DigitalHolding do | ||
def get_record(path) | ||
reader = MARC::XMLReader.new(path) | ||
for r in reader | ||
return r | ||
end | ||
end | ||
let(:arborist) do | ||
get_record('./spec/fixtures/arborist_avd.xml') | ||
end | ||
let(:avd) do | ||
arborist.fields("AVD").first | ||
end | ||
subject do | ||
described_class.new(avd) | ||
end | ||
context "#link" do | ||
it "returns the link with the UMICH view" do | ||
expect(subject.link).to eq("https://umich-psb.alma.exlibrisgroup.com/discovery/delivery/01UMICH_INST:UMICH/121230624780006381") | ||
end | ||
end | ||
context "#note" do | ||
it "returns the z field" do | ||
expect(subject.note).to eq("This is a Public Note") | ||
end | ||
end | ||
context "#library" do | ||
it "shows ELEC" do | ||
expect(subject.library).to eq("ELEC") | ||
end | ||
end | ||
context "#status" do | ||
it "shows Available" do | ||
expect(subject.status).to eq("Available") | ||
end | ||
end | ||
context "#link_text" do | ||
it "shows Available online" do | ||
expect(subject.link_text).to eq("Available online") | ||
end | ||
end | ||
context "#description" do | ||
it "shows empty string" do | ||
expect(subject.description).to eq("") | ||
end | ||
end | ||
context "#finding_aid" do | ||
it "is false" do | ||
expect(subject.finding_aid).to eq(false) | ||
end | ||
end | ||
context "#to_h" do | ||
it "returns expected hash" do | ||
expect(subject.to_h).to eq( | ||
{ | ||
finding_aid: false, | ||
library: "ELEC", | ||
link: "https://umich-psb.alma.exlibrisgroup.com/discovery/delivery/01UMICH_INST:UMICH/121230624780006381", | ||
link_text: "Available online", | ||
note: "This is a Public Note", | ||
status: "Available", | ||
description: "" | ||
} | ||
) | ||
end | ||
end | ||
end | ||
|