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

Commit

Permalink
Updating to CC 1.6.x
Browse files Browse the repository at this point in the history
  • Loading branch information
escowles committed Nov 2, 2016
1 parent dc1d877 commit 97899a2
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ gem 'prawn'
# Copied from curation_concerns Gemfile.extra
gem 'hydra-works', github: 'projecthydra-labs/hydra-works', branch: 'master'
gem 'hydra-pcdm', github: 'projecthydra-labs/hydra-pcdm', branch: 'master'
gem 'hydra-derivatives', github: 'projecthydra/hydra-derivatives', branch: 'master'
gem 'hydra-derivatives', '3.1.3'
gem 'active-fedora', '11.0.0.rc7'
gem 'active-triples', '~> 0.10.0'
gem 'active_fedora-noid', '2.0.0.beta6'
Expand Down
20 changes: 7 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,6 @@ GIT
hydra-pcdm (>= 0.8)
om (~> 3.1)

GIT
remote: git://github.com/projecthydra/hydra-derivatives.git
revision: b79aefd88cd76b11a2c00c0463ce618dd4d04bfd
branch: master
specs:
hydra-derivatives (3.1.4)
active-fedora (>= 9.0, < 12)
activesupport (>= 4.0, < 6)
deprecation
mime-types (> 2.0, < 4.0)
mini_magick (>= 3.2, < 5)

GIT
remote: git://github.com/pulibrary/pul_metadata_services.git
revision: c485eeff36d56c12255a95e5449727370820d53e
Expand Down Expand Up @@ -345,6 +333,12 @@ GEM
hydra-core (10.3.2)
hydra-access-controls (= 10.3.2)
railties (>= 4.0.0, < 6)
hydra-derivatives (3.1.3)
active-fedora (>= 9.0, < 12)
activesupport (>= 4.0, < 6)
deprecation
mime-types (> 2.0, < 4.0)
mini_magick (>= 3.2, < 5)
hydra-editor (3.1.2)
active-fedora (>= 9.0.0)
almond-rails (~> 0.0.3)
Expand Down Expand Up @@ -714,7 +708,7 @@ DEPENDENCIES
ezid-client
factory_girl_rails
fcrepo_wrapper (~> 0.6.0)
hydra-derivatives!
hydra-derivatives (= 3.1.3)
hydra-pcdm!
hydra-role-management (~> 0.2.0)
hydra-works!
Expand Down
2 changes: 1 addition & 1 deletion app/forms/curation_concerns/curation_concerns_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class CurationConcernsForm < CurationConcerns::Forms::WorkForm
delegate :collection_ids, to: :model

def notable_rights_statement?
RightsStatementService.notable?(rights_statement)
RightsStatementService.new.notable?(rights_statement)
end

def self.multiple?(field)
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/all_collections_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def initialize(current_ability = nil)
end

def title
"Plum Collections"
["Plum Collections"]
end

def description
Expand Down
10 changes: 7 additions & 3 deletions app/renderers/rights_statement_renderer.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class RightsStatementRenderer < CurationConcerns::Renderers::RightsAttributeRenderer
def initialize(rights_statement, rights_note, options = {})
super(:rights, rights_statement, options)
if !rights_note.nil? && RightsStatementService.notable?(rights_statement)
if !rights_note.nil? && RightsStatementService.new.notable?(rights_statement)
@rights_note = rights_note
else
@rights_note = []
Expand All @@ -15,15 +15,19 @@ def render
markup << %(<tr><th>#{label}</th>\n<td><ul class='tabular'>)
attributes = microdata_object_attributes(field).merge(class: "attribute #{field}")
Array(values).each do |value|
markup << "<li#{html_attributes(attributes)}>#{attribute_value_to_html(value.to_s)}</li>"
markup << "<li#{html_attributes(attributes)}>#{rights_attribute_to_html(value.to_s)}</li>"
end
markup << %(</ul>)
markup << simple_format(RightsStatementService.definition(values.first))
markup << simple_format(RightsStatementService.new.definition(values.first))
@rights_note.each do |note|
markup << %(<p>#{note}</p>) unless note.blank?
end
markup << simple_format(I18n.t('rights.boilerplate'))
markup << %(</td></tr>)
markup.html_safe
end

def rights_attribute_to_html(value)
%(<a href=#{ERB::Util.h(value)} target="_blank">#{RightsStatementService.new.label(value)}</a>)
end
end
20 changes: 11 additions & 9 deletions app/services/rights_statement_service.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
module RightsStatementService
include RightsService

def self.definition(id)
obj = RightsService.authority.find(id)
class RightsStatementService < CurationConcerns::LicenseService
def definition(id)
obj = authority.find(id)
obj['definition'] || ''
end

def self.valid_statements
RightsService.authority.all.map { |hash| hash['id'] }
def valid_statements
authority.all.map { |hash| hash['id'] }
end

def self.notable?(id)
def notable?(id)
id = id.first if id.is_a?(Array)
obj = RightsService.authority.find(id)
obj = authority.find(id)
obj['notable'] == true
end

def select_options
authority.all.map { |term| [term[:label], term[:id]] }
end
end
2 changes: 1 addition & 1 deletion app/validators/rights_statement_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ def inclusivity_validator
end

def valid_rights_statements
RightsStatementService.valid_statements
RightsStatementService.new.valid_statements
end
end
2 changes: 1 addition & 1 deletion app/values/file_info.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class FileInfo
attr_reader :file_info
delegate :[], :has_key?, to: :file_info
delegate :[], :has_key?, :key?, to: :file_info
def initialize(file_info)
@file_info = file_info
end
Expand Down
4 changes: 2 additions & 2 deletions app/values/scanned_resource_pdf/cover_page_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ def helper
end

def rights_statement_label(statement)
RightsService.label(statement)
RightsStatementService.new.label(statement)
end

def rights_statement_text(statement)
RightsStatementService.definition(statement).gsub(/<br\/>/, "\n")
RightsStatementService.new.definition(statement).gsub(/<br\/>/, "\n")
end

def display_text(prawn_document, text, options = {})
Expand Down
2 changes: 1 addition & 1 deletion app/views/curation_concerns/base/_form_access_policy.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<%= f.input :rights_statement,
as: :select,
collection: RightsService.select_active_options,
collection: RightsStatementService.new.select_options,
input_html: { class: 'form-control rights-statement' },
label: 'Rights Statement' %>
Expand Down
File renamed without changes.
5 changes: 1 addition & 4 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ default: &default

development:
<<: *default
adapter: postgresql
database: fcrepo
username: root
password: root
database: db/development.sqlite3

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
Expand Down
6 changes: 6 additions & 0 deletions spec/models/solr_document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,10 @@
expect(subject.ocr_language).to eq(['eng'])
end
end

describe '#method_missing' do
it 'passes through to super' do
expect { subject.send :foo }.to raise_error NoMethodError, /undefined method/
end
end
end
2 changes: 1 addition & 1 deletion spec/presenters/all_collections_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
end

it "has a title" do
expect(subject.title).to eq "Plum Collections"
expect(subject.title).to eq ["Plum Collections"]
end

it "has a description" do
Expand Down
10 changes: 7 additions & 3 deletions spec/services/rights_statement_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@

context "rights statements" do
it "provides definitions of rights statements" do
expect(described_class.definition(uri)).to include(desc)
expect(described_class.definition(uri)).to include('<br/>')
expect(described_class.new.definition(uri)).to include(desc)
expect(described_class.new.definition(uri)).to include('<br/>')
end

it "lists all valid rights statements" do
expect(described_class.valid_statements).to eq(valid_statements)
expect(described_class.new.valid_statements).to eq(valid_statements)
end

it "lists select options" do
expect(described_class.new.select_options).to include ['No Known Copyright', 'http://rightsstatements.org/vocab/NKC/1.0/']
end
end
end
3 changes: 3 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@
mocks.verify_partial_doubles = true
end
end

# prevent logging during specs
Prawn::Font::AFM.hide_m17n_warning = true

0 comments on commit 97899a2

Please sign in to comment.