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

Commit

Permalink
use ark noid in gbl slug
Browse files Browse the repository at this point in the history
  • Loading branch information
tampakis committed Dec 8, 2016
1 parent c24d2bb commit d261630
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module GeoConcerns
module Discovery
class DocumentBuilder
class SlugBuilder
attr_reader :geo_concern

def initialize(geo_concern)
@geo_concern = geo_concern
end

def build(document)
document.slug = slug
end

# Returns the document slug for use in discovery systems.
# @return [String] document slug
def slug
identifier = geo_concern.identifier || geo_concern.id
id = identifier.gsub(%r(ark:/\d{5}/), '')
return id unless geo_concern.provenance
"#{geo_concern.provenance.parameterize}-#{id}"
end
end
end
end
end
26 changes: 26 additions & 0 deletions spec/services/geo_concerns/slug_builder_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require 'rails_helper'

describe GeoConcerns::Discovery::DocumentBuilder::SlugBuilder do
subject { described_class.new(geo_concern_presenter) }

let(:geo_concern_presenter) { GeoConcerns::VectorWorkShowPresenter.new(SolrDocument.new(geo_concern.to_solr), nil) }
let(:geo_concern) { FactoryGirl.build(:vector_work, attributes) }
let(:attributes) { { id: 'geo-work-1',
title: ['Geo Work'],
description: ['This is a Geo Work'],
creator: ['Yosiwo George'],
publisher: ['National Geographic'],
spatial: ['Micronesia'],
temporal: ['2011'],
subject: ['Human settlements'],
language: ['Esperanto'],
identifier: ['ark:/99999/fk4']
}
}

describe 'vector work slug' do
it 'uses ark noid fowlling the provenance' do
expect(subject.slug).to eq('princeton-university-library-fk4')
end
end
end

0 comments on commit d261630

Please sign in to comment.