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
Showing
12 changed files
with
151 additions
and
12 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module CurationConcerns | ||
# Provide select options for the license (dcterms:rights) field | ||
class LicenseService < QaSelectService | ||
def initialize | ||
super('licenses') | ||
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module CurationConcerns | ||
# This is an abstract class to provide select options from a | ||
# questioning authority backed authority | ||
class QaSelectService | ||
attr_reader :authority | ||
|
||
def initialize(authority_name) | ||
@authority = Qa::Authorities::Local.subauthority_for(authority_name) | ||
end | ||
|
||
def select_all_options | ||
authority.all.map do |element| | ||
[element[:label], element[:id]] | ||
end | ||
end | ||
|
||
def select_active_options | ||
active_elements.map { |e| [e[:label], e[:id]] } | ||
end | ||
|
||
def active?(id) | ||
authority.find(id).fetch('active') | ||
end | ||
|
||
def label(id) | ||
authority.find(id).fetch('term') | ||
end | ||
|
||
def active_elements | ||
authority.all.select { |e| active?(e.fetch('id')) } | ||
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module CurationConcerns | ||
# Provide select options for the copyright status (edm:rights) field | ||
class RightsStatements < QaSelectService | ||
def initialize | ||
super('rights_statements') | ||
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
File renamed without changes.
37 changes: 37 additions & 0 deletions
37
lib/generators/curation_concerns/templates/config/authorities/rights_statements.yml
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,37 @@ | ||
terms: | ||
- id: http://rightsstatements.org/vocab/InC/1.0/ | ||
term: "In Copyright" | ||
active: true | ||
- id: http://rightsstatements.org/vocab/InC-OW-EU/1.0/ | ||
term: "In Copyright - EU Orphan Work" | ||
active: true | ||
- id: http://rightsstatements.org/vocab/InC-EDU/1.0/ | ||
term: "In Copyright - Educational Use Permitted" | ||
active: true | ||
- id: http://rightsstatements.org/vocab/InC-NC/1.0/ | ||
term: "In Copyright - Non-Commercial Use Permitted" | ||
active: true | ||
- id: http://rightsstatements.org/vocab/InC-RUU/1.0/ | ||
term: "In Copyright - Rights-holder(s) Unlocatable or Unidentifiable" | ||
active: true | ||
- id: http://rightsstatements.org/vocab/NoC-CR/1.0/ | ||
term: "No Copyright - Contractual Restrictions" | ||
active: true | ||
- id: http://rightsstatements.org/vocab/NoC-NC/1.0/ | ||
term: "No Copyright - Non-Commercial Use Only " | ||
active: true | ||
- id: http://rightsstatements.org/vocab/NoC-OKLR/1.0/ | ||
term: "No Copyright - Other Known Legal Restrictions" | ||
active: true | ||
- id: http://rightsstatements.org/vocab/NoC-US/1.0/ | ||
term: "No Copyright - United States" | ||
active: true | ||
- id: http://rightsstatements.org/vocab/CNE/1.0/ | ||
term: "Copyright Not Evaluated" | ||
active: true | ||
- id: http://rightsstatements.org/vocab/UND/1.0/ | ||
term: "Copyright Undetermined" | ||
active: true | ||
- id: http://rightsstatements.org/vocab/NKC/1.0/ | ||
term: "No Known Copyright" | ||
active: true |
File renamed without changes.
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,36 @@ | ||
require 'spec_helper' | ||
|
||
describe CurationConcerns::LicenseService do | ||
before do | ||
# Configure QA to use fixtures | ||
qa_fixtures = { local_path: File.expand_path('spec/fixtures/authorities') } | ||
allow(Qa::Authorities::Local).to receive(:config).and_return(qa_fixtures) | ||
end | ||
let(:service) { described_class.new } | ||
|
||
describe "#select_active_options" do | ||
it "returns active terms" do | ||
expect(service.select_active_options).to include(["First Active Term", "demo_id_01"], ["Second Active Term", "demo_id_02"]) | ||
end | ||
|
||
it "does not return inactive terms" do | ||
expect(service.select_active_options).not_to include(["Third is an Inactive Term", "demo_id_03"], ["Fourth is an Inactive Term", "demo_id_04"]) | ||
end | ||
end | ||
|
||
describe "#select_all_options" do | ||
it "returns both active and inactive terms" do | ||
expect(service.select_all_options).to include(["Fourth is an Inactive Term", "demo_id_04"], ["First Active Term", "demo_id_01"]) | ||
end | ||
end | ||
|
||
describe "#label" do | ||
it "resolves for ids of active terms" do | ||
expect(service.label('demo_id_01')).to eq("First Active Term") | ||
end | ||
|
||
it "resolves for ids of inactive terms" do | ||
expect(service.label('demo_id_03')).to eq("Third is an Inactive Term") | ||
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require 'spec_helper' | ||
|
||
describe CurationConcerns::RightsStatements do | ||
let(:service) { described_class.new } | ||
|
||
describe "#select_active_options" do | ||
it "returns active terms" do | ||
expect(service.select_active_options).to include(["In Copyright", "http://rightsstatements.org/vocab/InC/1.0/"], ["No Known Copyright", "http://rightsstatements.org/vocab/NKC/1.0/"]) | ||
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