blacklight-marc 8.0.0 → 8.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 510b8f1ae8d1d7752d0dbeadf0db9e4cc5003d88dd25c7b4a9e76ba1757c2d4e
4
- data.tar.gz: 61ffc549983a3e3ca3fe0497cfcac437bac64318fba45d7836ad0307d2f1a83a
3
+ metadata.gz: 483538c623aaace602da20c35e7b3fc349ac18e06ffe4277ac9a14f14eff237e
4
+ data.tar.gz: cfbc11131199f2895db722e609a23dfa4cec8be8e27781f542076931988aaf5c
5
5
  SHA512:
6
- metadata.gz: cc9bacb9622c2e4f68f2ff7058d9ce8495e2667ab7b8fae7c5495e571a11e82ccd9699bb73237aad5935f6d47a229e651671158eb22fe686816b14c520adaf09
7
- data.tar.gz: b8127b909fd370507c3a7a59860ae395abe2f7b23828e18dfae1c54042507ee7c7c8f7b03f7986e58d308f855ca38fad0851b1f93b6d5aab7e3ef31c632555e7
6
+ metadata.gz: bc6f9437f9c3a53fe810cf7f1fe1a831e7d6c1de22e9ab04927a0702163e4ef474c4868f322ce8bf2374a4a36fd4354a748a26788001e73b46bbe7dd8e85fe9d
7
+ data.tar.gz: 41943dec1aef4930cfb7ee783dadb6ba63d097882486547f292bb14c2e1f088685f17080a60483f2f08080878ebd61020d48a4ca739a1d0b247ee6f00ad270e6
@@ -1,26 +1,41 @@
1
- ---
2
1
  name: CI
3
2
 
4
3
  on:
5
4
  push:
6
- branches: [main]
5
+ branches: [ main ]
7
6
  pull_request:
8
- branches: [main]
7
+ branches: [ main ]
9
8
 
10
9
  jobs:
11
10
  test:
12
11
  runs-on: ubuntu-latest
12
+ continue-on-error: ${{ matrix.experimental }}
13
13
  strategy:
14
14
  matrix:
15
- rails_version: [6.1.4.7, 7.0.2.3]
16
- ruby: [2.7, '3.0']
15
+ ruby: ['3.2']
16
+ rails_version: ['7.1.3']
17
+ blacklight_version: ['~> 8.1']
18
+ experimental: [false]
17
19
  include:
18
- - rails_version: 5.2.4.4
19
- ruby: 2.7
20
- - rails_version: 6.0.3.4
21
- ruby: 2.7
20
+ - ruby: '2.7'
21
+ rails_version: '6.1.7.6'
22
+ blacklight_version: '~> 7.0'
23
+ experimental: false
24
+ - ruby: '3.0'
25
+ rails_version: '7.0.8'
26
+ blacklight_version: '~> 7.0'
27
+ experimental: false
28
+ - ruby: '3.1'
29
+ rails_version: '7.0.8'
30
+ blacklight_version: '~> 8.1'
31
+ experimental: false
32
+ - ruby: '3.2'
33
+ rails_version: '7.1.3'
34
+ blacklight_version: 'github'
35
+ experimental: true
22
36
  env:
23
37
  RAILS_VERSION: ${{ matrix.rails_version }}
38
+ BLACKLIGHT_VERSION: ${{ matrix.blacklight_version }}
24
39
  steps:
25
40
  - uses: actions/checkout@v2
26
41
  - name: Set up Ruby ${{ matrix.ruby }}
data/README.md CHANGED
@@ -35,7 +35,7 @@ include Blacklight::Marc::Catalog
35
35
  and the following code is generated into SolrDocument:
36
36
 
37
37
  ```ruby
38
- use_extension( Blacklight::Solr::Document::Marc) do |document|
38
+ use_extension( Blacklight::Marc::DocumentExtension) do |document|
39
39
  document.key?( :marc_display )
40
40
  end
41
41
  ```
@@ -12,8 +12,8 @@ module BlacklightMarcHelper
12
12
  end
13
13
 
14
14
  # For exporting a single endnote document. (endnote_catalog_path is defined by blacklight-marc and it is used for multiple document export)
15
- def single_endnote_catalog_path opts = {}, *_
16
- solr_document_path(opts.merge(format: 'endnote'))
15
+ def single_endnote_catalog_path opts = {}, **kwargs
16
+ solr_document_path(opts['id'], **kwargs.merge(opts).merge(format: 'endnote').except('id'))
17
17
  end
18
18
 
19
19
 
@@ -62,40 +62,40 @@ module Blacklight::Marc::DocumentExport
62
62
  edition = to_marc.find{|field| field.tag == '250'}
63
63
  isbn = to_marc.find{|field| field.tag == '020'}
64
64
  issn = to_marc.find{|field| field.tag == '022'}
65
- unless format.nil?
66
- format.is_a?(Array) ? format = format[0].downcase.strip : format = format.downcase.strip
65
+ format = format.first if format.is_a?(Array)
66
+ format = format.downcase.strip unless format.nil?
67
+
68
+ export_text = ""
69
+ if format == 'book'
70
+ export_text << "ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rfr_id=info%3Asid%2Fblacklight.rubyforge.org%3Agenerator&amp;rft.genre=book&amp;"
71
+ export_text << "rft.btitle=#{(title.nil? or title['a'].nil?) ? "" : CGI::escape(title['a'])}+#{(title.nil? or title['b'].nil?) ? "" : CGI::escape(title['b'])}&amp;"
72
+ export_text << "rft.title=#{(title.nil? or title['a'].nil?) ? "" : CGI::escape(title['a'])}+#{(title.nil? or title['b'].nil?) ? "" : CGI::escape(title['b'])}&amp;"
73
+ export_text << "rft.au=#{(author.nil? or author['a'].nil?) ? "" : CGI::escape(author['a'])}&amp;"
74
+ export_text << "rft.aucorp=#{CGI::escape(corp_author['a']) if corp_author['a']}+#{CGI::escape(corp_author['b']) if corp_author['b']}&amp;" unless corp_author.blank?
75
+ export_text << "rft.date=#{(publisher_info.nil? or publisher_info['c'].nil?) ? "" : CGI::escape(publisher_info['c'])}&amp;"
76
+ export_text << "rft.place=#{(publisher_info.nil? or publisher_info['a'].nil?) ? "" : CGI::escape(publisher_info['a'])}&amp;"
77
+ export_text << "rft.pub=#{(publisher_info.nil? or publisher_info['b'].nil?) ? "" : CGI::escape(publisher_info['b'])}&amp;"
78
+ export_text << "rft.edition=#{(edition.nil? or edition['a'].nil?) ? "" : CGI::escape(edition['a'])}&amp;"
79
+ export_text << "rft.isbn=#{(isbn.nil? or isbn['a'].nil?) ? "" : isbn['a']}"
80
+ elsif (format =~ /journal/i) # checking using include because institutions may use formats like Journal or Journal/Magazine
81
+ export_text << "ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rfr_id=info%3Asid%2Fblacklight.rubyforge.org%3Agenerator&amp;rft.genre=article&amp;"
82
+ export_text << "rft.title=#{(title.nil? or title['a'].nil?) ? "" : CGI::escape(title['a'])}+#{(title.nil? or title['b'].nil?) ? "" : CGI::escape(title['b'])}&amp;"
83
+ export_text << "rft.atitle=#{(title.nil? or title['a'].nil?) ? "" : CGI::escape(title['a'])}+#{(title.nil? or title['b'].nil?) ? "" : CGI::escape(title['b'])}&amp;"
84
+ export_text << "rft.aucorp=#{CGI::escape(corp_author['a']) if corp_author['a']}+#{CGI::escape(corp_author['b']) if corp_author['b']}&amp;" unless corp_author.blank?
85
+ export_text << "rft.date=#{(publisher_info.nil? or publisher_info['c'].nil?) ? "" : CGI::escape(publisher_info['c'])}&amp;"
86
+ export_text << "rft.issn=#{(issn.nil? or issn['a'].nil?) ? "" : issn['a']}"
87
+ else
88
+ export_text << "ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Fblacklight.rubyforge.org%3Agenerator&amp;"
89
+ export_text << "rft.title=" + ((title.nil? or title['a'].nil?) ? "" : CGI::escape(title['a']))
90
+ export_text << ((title.nil? or title['b'].nil?) ? "" : CGI.escape(" ") + CGI::escape(title['b']))
91
+ export_text << "&amp;rft.creator=" + ((author.nil? or author['a'].nil?) ? "" : CGI::escape(author['a']))
92
+ export_text << "&amp;rft.aucorp=#{CGI::escape(corp_author['a']) if corp_author['a']}+#{CGI::escape(corp_author['b']) if corp_author['b']}" unless corp_author.blank?
93
+ export_text << "&amp;rft.date=" + ((publisher_info.nil? or publisher_info['c'].nil?) ? "" : CGI::escape(publisher_info['c']))
94
+ export_text << "&amp;rft.place=" + ((publisher_info.nil? or publisher_info['a'].nil?) ? "" : CGI::escape(publisher_info['a']))
95
+ export_text << "&amp;rft.pub=" + ((publisher_info.nil? or publisher_info['b'].nil?) ? "" : CGI::escape(publisher_info['b']))
96
+ export_text << "&amp;rft.format=" + (format.nil? ? "" : CGI::escape(format))
67
97
  end
68
- export_text = ""
69
- if format == 'book'
70
- export_text << "ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rfr_id=info%3Asid%2Fblacklight.rubyforge.org%3Agenerator&amp;rft.genre=book&amp;"
71
- export_text << "rft.btitle=#{(title.nil? or title['a'].nil?) ? "" : CGI::escape(title['a'])}+#{(title.nil? or title['b'].nil?) ? "" : CGI::escape(title['b'])}&amp;"
72
- export_text << "rft.title=#{(title.nil? or title['a'].nil?) ? "" : CGI::escape(title['a'])}+#{(title.nil? or title['b'].nil?) ? "" : CGI::escape(title['b'])}&amp;"
73
- export_text << "rft.au=#{(author.nil? or author['a'].nil?) ? "" : CGI::escape(author['a'])}&amp;"
74
- export_text << "rft.aucorp=#{CGI::escape(corp_author['a']) if corp_author['a']}+#{CGI::escape(corp_author['b']) if corp_author['b']}&amp;" unless corp_author.blank?
75
- export_text << "rft.date=#{(publisher_info.nil? or publisher_info['c'].nil?) ? "" : CGI::escape(publisher_info['c'])}&amp;"
76
- export_text << "rft.place=#{(publisher_info.nil? or publisher_info['a'].nil?) ? "" : CGI::escape(publisher_info['a'])}&amp;"
77
- export_text << "rft.pub=#{(publisher_info.nil? or publisher_info['b'].nil?) ? "" : CGI::escape(publisher_info['b'])}&amp;"
78
- export_text << "rft.edition=#{(edition.nil? or edition['a'].nil?) ? "" : CGI::escape(edition['a'])}&amp;"
79
- export_text << "rft.isbn=#{(isbn.nil? or isbn['a'].nil?) ? "" : isbn['a']}"
80
- elsif (format =~ /journal/i) # checking using include because institutions may use formats like Journal or Journal/Magazine
81
- export_text << "ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rfr_id=info%3Asid%2Fblacklight.rubyforge.org%3Agenerator&amp;rft.genre=article&amp;"
82
- export_text << "rft.title=#{(title.nil? or title['a'].nil?) ? "" : CGI::escape(title['a'])}+#{(title.nil? or title['b'].nil?) ? "" : CGI::escape(title['b'])}&amp;"
83
- export_text << "rft.atitle=#{(title.nil? or title['a'].nil?) ? "" : CGI::escape(title['a'])}+#{(title.nil? or title['b'].nil?) ? "" : CGI::escape(title['b'])}&amp;"
84
- export_text << "rft.aucorp=#{CGI::escape(corp_author['a']) if corp_author['a']}+#{CGI::escape(corp_author['b']) if corp_author['b']}&amp;" unless corp_author.blank?
85
- export_text << "rft.date=#{(publisher_info.nil? or publisher_info['c'].nil?) ? "" : CGI::escape(publisher_info['c'])}&amp;"
86
- export_text << "rft.issn=#{(issn.nil? or issn['a'].nil?) ? "" : issn['a']}"
87
- else
88
- export_text << "ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&amp;rfr_id=info%3Asid%2Fblacklight.rubyforge.org%3Agenerator&amp;"
89
- export_text << "rft.title=" + ((title.nil? or title['a'].nil?) ? "" : CGI::escape(title['a']))
90
- export_text << ((title.nil? or title['b'].nil?) ? "" : CGI.escape(" ") + CGI::escape(title['b']))
91
- export_text << "&amp;rft.creator=" + ((author.nil? or author['a'].nil?) ? "" : CGI::escape(author['a']))
92
- export_text << "&amp;rft.aucorp=#{CGI::escape(corp_author['a']) if corp_author['a']}+#{CGI::escape(corp_author['b']) if corp_author['b']}" unless corp_author.blank?
93
- export_text << "&amp;rft.date=" + ((publisher_info.nil? or publisher_info['c'].nil?) ? "" : CGI::escape(publisher_info['c']))
94
- export_text << "&amp;rft.place=" + ((publisher_info.nil? or publisher_info['a'].nil?) ? "" : CGI::escape(publisher_info['a']))
95
- export_text << "&amp;rft.pub=" + ((publisher_info.nil? or publisher_info['b'].nil?) ? "" : CGI::escape(publisher_info['b']))
96
- export_text << "&amp;rft.format=" + (format.nil? ? "" : CGI::escape(format))
97
- end
98
- export_text.html_safe unless export_text.blank?
98
+ export_text.html_safe unless export_text.blank?
99
99
  end
100
100
 
101
101
 
@@ -299,6 +299,10 @@ module Blacklight::Marc::DocumentExport
299
299
  pub_info << clean_end_punctuation(marc["260"]["a"]).strip if marc["260"]["a"]
300
300
  pub_info << ": #{clean_end_punctuation(marc["260"]["b"]).strip}" if marc["260"]["b"]
301
301
  pub_info << ", #{setup_pub_date(marc)}" if marc["260"]["c"]
302
+ elsif marc["264"] and (marc["264"]["a"] or marc["264"]["b"])
303
+ pub_info << clean_end_punctuation(marc["264"]["a"]).strip if marc["264"]["a"]
304
+ pub_info << ": #{clean_end_punctuation(marc["264"]["b"]).strip}" if marc["264"]["b"]
305
+ pub_info << ", #{setup_pub_date(marc)}" if marc["264"]["c"]
302
306
  elsif marc["502"] and marc["502"]["a"] # MARC 502 is the Dissertation Note. This holds the correct pub info for these types of records.
303
307
  pub_info << marc["502"]["a"]
304
308
  elsif marc["502"] and (marc["502"]["b"] or marc["502"]["c"] or marc["502"]["d"]) #sometimes the dissertation note is encoded in pieces in the $b $c and $d sub fields instead of lumped into the $a
@@ -414,8 +418,8 @@ module Blacklight::Marc::DocumentExport
414
418
  text
415
419
  end
416
420
  def setup_pub_date(record)
417
- if !record.find{|f| f.tag == '260'}.nil?
418
- pub_date = record.find{|f| f.tag == '260'}
421
+ if !record.find{|f| ['260', '264'].include?(f.tag)}.nil?
422
+ pub_date = record.find{|f| ['260', '264'].include?(f.tag)}
419
423
  if pub_date.find{|s| s.code == 'c'}
420
424
  date_value = pub_date.find{|s| s.code == 'c'}.value.gsub(/[^0-9|n\.d\.]/, "")[0,4] unless pub_date.find{|s| s.code == 'c'}.value.gsub(/[^0-9|n\.d\.]/, "")[0,4].blank?
421
425
  end
@@ -425,7 +429,7 @@ module Blacklight::Marc::DocumentExport
425
429
  end
426
430
  def setup_pub_info(record)
427
431
  text = ''
428
- pub_info_field = record.find{|f| f.tag == '260'}
432
+ pub_info_field = get_publication_data(record)
429
433
  if !pub_info_field.nil?
430
434
  a_pub_info = pub_info_field.find{|s| s.code == 'a'}
431
435
  b_pub_info = pub_info_field.find{|s| s.code == 'b'}
@@ -551,6 +555,10 @@ module Blacklight::Marc::DocumentExport
551
555
  {:primary_authors => primary_authors, :translators => translators, :editors => editors, :compilers => compilers}
552
556
  end
553
557
 
558
+ def get_publication_data(record)
559
+ publication_data = record.find{|field| field.tag == '260'} || record.find{|field| field.tag == '264'}
560
+ end
561
+
554
562
  def abbreviate_name(name)
555
563
  name_parts = name.split(", ")
556
564
  first_name_parts = name_parts.last.split(" ")
@@ -1,5 +1,5 @@
1
1
  <%= render Blacklight::System::ModalComponent.new do |component| %>
2
- <% component.title { t('blacklight.search.librarian_view.title') } %>
2
+ <% component.with_title { t('blacklight.search.librarian_view.title') } %>
3
3
  <%- if @document.respond_to?(:to_marc) -%>
4
4
  <%= render "marc_view", document: @document %>
5
5
  <%- else %>
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.add_development_dependency "bundler"
29
29
  spec.add_development_dependency "rake"
30
- spec.add_development_dependency "rspec-rails", '~> 4.0'
30
+ spec.add_development_dependency "rspec-rails", '~> 6.1'
31
31
  spec.add_development_dependency "rspec-activemodel-mocks"
32
32
  spec.add_development_dependency "solr_wrapper"
33
33
  spec.add_development_dependency "capybara"
@@ -1,5 +1,5 @@
1
1
  module Blacklight
2
2
  module Marc
3
- VERSION = '8.0.0'
3
+ VERSION = '8.1.1'
4
4
  end
5
5
  end
@@ -106,7 +106,7 @@ def compute_arguments
106
106
  File.join( plugin_site_path, "config-#{::Rails.env}.properties"),
107
107
  File.join( plugin_site_path, "config.properties"),
108
108
  ].each do |file_path|
109
- if File.exists?(file_path)
109
+ if File.exist?(file_path)
110
110
  arguments[:config_properties_path] = file_path
111
111
  break
112
112
  end
@@ -147,7 +147,7 @@ def locate_path(*subpath_fragments)
147
147
  local_root = File.expand_path File.join(File.dirname(__FILE__), '..', '..')
148
148
  subpath = subpath_fragments.join('/')
149
149
  base_match = [Rails.root, local_root].find do |base|
150
- File.exists? File.join(base, subpath)
150
+ File.exist? File.join(base, subpath)
151
151
  end
152
152
  File.join(base_match.to_s, subpath) if base_match
153
153
  end
@@ -9,5 +9,10 @@ describe "Record View" do
9
9
  link = find_link("Export to Refworks")
10
10
  expect(link['href']).to include CGI.escape(solr_document_path('2008305903', format: :refworks_marc_txt))
11
11
  end
12
+
13
+ it 'has an endnote link' do
14
+ visit solr_document_path('2008305903')
15
+ expect(page).to have_link "Export to EndNote", href: solr_document_path('2008305903', format: :endnote)
16
+ end
12
17
  end
13
18
  end
@@ -23,25 +23,6 @@ describe BlacklightMarcHelper do
23
23
  expect(helper.render_endnote_texts([one, two])).to eq "one\ntwo\n"
24
24
  end
25
25
  end
26
- require 'spec_helper'
27
-
28
- describe '#document_action_path' do
29
- before do
30
- allow(helper).to receive_messages(controller_name: 'catalog')
31
- end
32
-
33
- let(:document_action_config) { Blacklight::Configuration::ToolConfig.new(tool_config) }
34
- let(:document) { SolrDocument.new(id: '123') }
35
-
36
- subject { helper.document_action_path(document_action_config, id: document) }
37
-
38
- context "for endnote" do
39
- let(:tool_config) { { if: :render_refworks_action?, partial: "document_action",
40
- name: :endnote, key: :endnote, path: :single_endnote_catalog_path } }
41
-
42
- it { is_expected.to eq '/catalog/123.endnote' }
43
- end
44
- end
45
26
 
46
27
  describe "#bookmarks_export_url" do
47
28
  it "is the bookmark url with an encrypted user token" do
@@ -629,24 +629,62 @@ describe Blacklight::Solr::Document::MarcExport do
629
629
  end
630
630
  end
631
631
 
632
- describe "export_as_openurl_ctx_kev" do
633
- it "should create the appropriate context object for books" do
634
- record = @typical_record.export_as_openurl_ctx_kev('Book')
635
- expect(record).to match(/.*mtx%3Abook.*rft.genre=book.*rft.btitle=Apples\+%3A\+botany%2C\+production%2C\+and\+uses.*rft.aucorp=Bobs\+Your\+Uncle.*rft.date=c2003.*rft.place=Oxon%2C\+U.K.*rft.pub=CABI\+Pub.*rft.isbn=/) and
636
- expect(record).not_to match(/.*rft.genre=article.*rft.issn=.*/)
637
- end
638
- it "should create the appropriate context object for journals" do
639
- record = @typical_record.export_as_openurl_ctx_kev('Journal')
640
- record_journal_other = @typical_record.export_as_openurl_ctx_kev('Journal/Magazine')
641
- expect(record).to match(/.*mtx%3Ajournal.*rft.genre=article.*rft.title=Apples\+%3A\+botany%2C\+production%2C\+and\+uses.*rft.atitle=Apples\+%3A\+botany%2C\+production%2C\+and\+uses.*rft.aucorp=Bobs\+Your\+Uncle.*rft.date=c2003.*rft.issn=/) and
642
- expect(record_journal_other).to eq(record) and
643
- expect(record).not_to match(/.*rft.genre=book.*rft.isbn=.*/)
644
- end
645
- it "should create the appropriate context object for other content" do
646
- record = @typical_record.export_as_openurl_ctx_kev('NotARealFormat')
647
- expect(record).to match(/.*mtx%3Adc.*rft.title=Apples\+%3A\+botany%2C\+production%2C\+and\+uses.*rft.creator=.*rft.aucorp=Bobs\+Your\+Uncle.*rft.date=c2003.*rft.place=Oxon%2C\+U.K.*rft.pub=CABI\+Pub.*rft.format=notarealformat/) and
648
- expect(record).not_to match(/.*rft.isbn=.*/) and
649
- expect(record).not_to match(/.*rft.issn=.*/)
632
+ describe "#export_as_openurl_ctx_kev" do
633
+ subject(:record) { @typical_record.export_as_openurl_ctx_kev(format) }
634
+
635
+ context 'with a Book' do
636
+ let(:format) { 'Book' }
637
+ it "creates the appropriate context object" do
638
+ expect(record).to match(/.*mtx%3Abook.*rft.genre=book.*rft.btitle=Apples\+%3A\+botany%2C\+production%2C\+and\+uses.*rft.aucorp=Bobs\+Your\+Uncle.*rft.date=c2003.*rft.place=Oxon%2C\+U.K.*rft.pub=CABI\+Pub.*rft.isbn=/)
639
+ expect(record).not_to match(/.*rft.genre=article.*rft.issn=.*/)
640
+ end
641
+ end
642
+
643
+ context 'with a Journal' do
644
+ let(:format) { 'Journal' }
645
+ it "creates the appropriate context object" do
646
+ expect(record).to match(/.*mtx%3Ajournal.*rft.genre=article.*rft.title=Apples\+%3A\+botany%2C\+production%2C\+and\+uses.*rft.atitle=Apples\+%3A\+botany%2C\+production%2C\+and\+uses.*rft.aucorp=Bobs\+Your\+Uncle.*rft.date=c2003.*rft.issn=/)
647
+ expect(record).not_to match(/.*rft.genre=book.*rft.isbn=.*/)
648
+ end
649
+ end
650
+
651
+ context 'with a Journal/Magazine' do
652
+ let(:format) { 'Journal/Magazine' }
653
+ it "creates the appropriate context object" do
654
+ expect(record).to match(/.*mtx%3Ajournal.*rft.genre=article.*rft.title=Apples\+%3A\+botany%2C\+production%2C\+and\+uses.*rft.atitle=Apples\+%3A\+botany%2C\+production%2C\+and\+uses.*rft.aucorp=Bobs\+Your\+Uncle.*rft.date=c2003.*rft.issn=/)
655
+ expect(record).not_to match(/.*rft.genre=book.*rft.isbn=.*/)
656
+ end
657
+ end
658
+
659
+ context 'with other formats' do
660
+ let(:format) { 'NotARealFormat' }
661
+ it "creates the appropriate context object" do
662
+ expect(record).to match(/.*mtx%3Adc.*rft.title=Apples\+%3A\+botany%2C\+production%2C\+and\+uses.*rft.creator=.*rft.aucorp=Bobs\+Your\+Uncle.*rft.date=c2003.*rft.place=Oxon%2C\+U.K.*rft.pub=CABI\+Pub.*rft.format=notarealformat/)
663
+ expect(record).not_to match(/.*rft.isbn=.*/)
664
+ expect(record).not_to match(/.*rft.issn=.*/)
665
+ end
666
+ end
667
+
668
+ context 'with an array' do
669
+ let(:format) { ['Journal'] }
670
+ it "creates the appropriate context object" do
671
+ expect(record).to match(/.*mtx%3Ajournal.*rft.genre=article.*rft.title=Apples\+%3A\+botany%2C\+production%2C\+and\+uses.*rft.atitle=Apples\+%3A\+botany%2C\+production%2C\+and\+uses.*rft.aucorp=Bobs\+Your\+Uncle.*rft.date=c2003.*rft.issn=/)
672
+ expect(record).not_to match(/.*rft.genre=book.*rft.isbn=.*/)
673
+ end
674
+ end
675
+
676
+ context 'with a nil format' do
677
+ let(:format) { nil }
678
+ it "creates the appropriate context object" do
679
+ expect(record).to match(/.*mtx%3Adc.*rft.title=Apples\+%3A\+botany%2C\+production%2C\+and\+uses.*rft.creator=.*rft.aucorp=Bobs\+Your\+Uncle.*rft.date=c2003.*rft.place=Oxon%2C\+U.K.*rft.pub=CABI\+Pub.*rft.format=/)
680
+ end
681
+ end
682
+
683
+ context 'with an empty array' do
684
+ let(:format) { [] }
685
+ it "creates the appropriate context object" do
686
+ expect(record).to match(/.*mtx%3Adc.*rft.title=Apples\+%3A\+botany%2C\+production%2C\+and\+uses.*rft.creator=.*rft.aucorp=Bobs\+Your\+Uncle.*rft.date=c2003.*rft.place=Oxon%2C\+U.K.*rft.pub=CABI\+Pub.*rft.format=/)
687
+ end
650
688
  end
651
689
  end
652
690
 
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ class MockClass260
4
+ include Blacklight::Marc::DocumentExport
5
+
6
+ def to_marc
7
+ fields = [
8
+ { "100" => { "subfields" => [{ "a" => "Borja, Ronaldo I." }]}},
9
+ { "245" => { "ind1" => " ", "ind2" => " ", "subfields" => [{ "a" => "Plasticity : ", "b" => "modeling & computation /", "c" => "Ronaldo I. Borja." }] } },
10
+ { "260" => { "ind1" => " ", "ind2" => " ", "subfields" => [{ "a" => "Berlin :", "b" => "Springer,", "c" => "[2013]" }] } }
11
+ ]
12
+ MARC::Record.new_from_hash('fields' => fields)
13
+ end
14
+ end
15
+
16
+ class MockClass264
17
+ include Blacklight::Marc::DocumentExport
18
+
19
+ def to_marc
20
+ fields = [
21
+ { "100" => { "subfields" => [{ "a" => "Borja, Ronaldo I." }]}},
22
+ { "245" => { "ind1" => " ", "ind2" => " ", "subfields" => [{ "a" => "Plasticity : ", "b" => "modeling & computation /", "c" => "Ronaldo I. Borja." }] } },
23
+ { "264" => { "ind1" => " ", "ind2" => " ", "subfields" => [{ "a" => "Berlin :", "b" => "Springer,", "c" => "[2013]" }] } }
24
+ ]
25
+ MARC::Record.new_from_hash('fields' => fields)
26
+ end
27
+ end
28
+
29
+ RSpec.describe Blacklight::Marc::DocumentExport do
30
+ describe 'export citiations from 260 field' do
31
+ it 'exports citations in apa format' do
32
+ expect(MockClass260.new.export_as_apa_citation_txt).to include('(2013)')
33
+ expect(MockClass260.new.export_as_apa_citation_txt).to include('Berlin: Springer.')
34
+ end
35
+
36
+ it 'exports citations in mla format' do
37
+ expect(MockClass260.new.export_as_mla_citation_txt).to include('2013.')
38
+ expect(MockClass260.new.export_as_mla_citation_txt).to include('Berlin: Springer,')
39
+ end
40
+
41
+ it 'exports citations in Chicago format' do
42
+ expect(MockClass260.new.export_as_chicago_citation_txt).to include('2013.')
43
+ expect(MockClass260.new.export_as_chicago_citation_txt).to include('Berlin: Springer,')
44
+ end
45
+ end
46
+
47
+ describe 'export citations from 264 field' do
48
+ it 'exports citations in apa format' do
49
+ expect(MockClass264.new.export_as_apa_citation_txt).to include('(2013)')
50
+ expect(MockClass264.new.export_as_apa_citation_txt).to include('Berlin: Springer.')
51
+ end
52
+
53
+ it 'exports citations in mla format' do
54
+ expect(MockClass264.new.export_as_mla_citation_txt).to include('2013.')
55
+ expect(MockClass264.new.export_as_mla_citation_txt).to include('Berlin: Springer,')
56
+ end
57
+
58
+ it 'exports citations in Chicago format' do
59
+ expect(MockClass264.new.export_as_chicago_citation_txt).to include('2013.')
60
+ expect(MockClass264.new.export_as_chicago_citation_txt).to include('Berlin: Springer,')
61
+ end
62
+ end
63
+ end
@@ -1,7 +1,5 @@
1
1
  module ControllerLevelHelpers
2
2
  module ControllerViewHelpers
3
- include Blacklight::Facet
4
-
5
3
  def blacklight_config
6
4
  controller.blacklight_config
7
5
  end
@@ -18,4 +16,4 @@ module ControllerLevelHelpers
18
16
  def initialize_controller_helpers(helper)
19
17
  helper.extend ControllerViewHelpers
20
18
  end
21
- end
19
+ end
@@ -1 +1,7 @@
1
1
  gem "traject", '~>3.0'
2
+
3
+ if ENV['BLACKLIGHT_VERSION'] == 'github'
4
+ gem 'blacklight', github: 'projectblacklight/blacklight'
5
+ elsif ENV['BLACKLIGHT_VERSION'] && !ENV['BLACKLIGHT_VERSION'].empty?
6
+ gem 'blacklight', ENV['BLACKLIGHT_VERSION']
7
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight-marc
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.0
4
+ version: 8.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-07 00:00:00.000000000 Z
11
+ date: 2024-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: blacklight
@@ -140,14 +140,14 @@ dependencies:
140
140
  requirements:
141
141
  - - "~>"
142
142
  - !ruby/object:Gem::Version
143
- version: '4.0'
143
+ version: '6.1'
144
144
  type: :development
145
145
  prerelease: false
146
146
  version_requirements: !ruby/object:Gem::Requirement
147
147
  requirements:
148
148
  - - "~>"
149
149
  - !ruby/object:Gem::Version
150
- version: '4.0'
150
+ version: '6.1'
151
151
  - !ruby/object:Gem::Dependency
152
152
  name: rspec-activemodel-mocks
153
153
  requirement: !ruby/object:Gem::Requirement
@@ -300,6 +300,7 @@ files:
300
300
  - spec/lib/marc_export_spec.rb
301
301
  - spec/lib/tasks/solr_marc_task_spec.rb
302
302
  - spec/lib/traject_indexer_spec.rb
303
+ - spec/models/concerns/blacklight/marc/document_export_spec.rb
303
304
  - spec/routing/routes_spec.rb
304
305
  - spec/spec_helper.rb
305
306
  - spec/support/controller_level_helpers.rb
@@ -307,7 +308,6 @@ files:
307
308
  - spec/test_app_templates/lib/generators/test_app_generator.rb
308
309
  - spec/views/bookmarks/_endnote.html.erb_spec.rb
309
310
  - spec/views/bookmarks/_refworks.html.erb_spec.rb
310
- - spec/views/catalog/_document_action.html.erb_spec.rb
311
311
  - spec/views/catalog/index.atom.builder_spec.rb
312
312
  - test_support/config/translation_maps/test_dewey.properties
313
313
  - test_support/config/translation_maps/test_formats.properties
@@ -331,7 +331,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
331
331
  - !ruby/object:Gem::Version
332
332
  version: '0'
333
333
  requirements: []
334
- rubygems_version: 3.2.32
334
+ rubygems_version: 3.5.4
335
335
  signing_key:
336
336
  specification_version: 4
337
337
  summary: MARC support for Blacklight
@@ -349,6 +349,7 @@ test_files:
349
349
  - spec/lib/marc_export_spec.rb
350
350
  - spec/lib/tasks/solr_marc_task_spec.rb
351
351
  - spec/lib/traject_indexer_spec.rb
352
+ - spec/models/concerns/blacklight/marc/document_export_spec.rb
352
353
  - spec/routing/routes_spec.rb
353
354
  - spec/spec_helper.rb
354
355
  - spec/support/controller_level_helpers.rb
@@ -356,5 +357,4 @@ test_files:
356
357
  - spec/test_app_templates/lib/generators/test_app_generator.rb
357
358
  - spec/views/bookmarks/_endnote.html.erb_spec.rb
358
359
  - spec/views/bookmarks/_refworks.html.erb_spec.rb
359
- - spec/views/catalog/_document_action.html.erb_spec.rb
360
360
  - spec/views/catalog/index.atom.builder_spec.rb
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'catalog/_document_action' do
4
- let(:document_action_config) { Blacklight::Configuration::ToolConfig.new(tool_config) }
5
- let(:document) { SolrDocument.new(id: '123') }
6
-
7
- before do
8
- allow(view).to receive_messages(controller_name: 'catalog')
9
- render 'catalog/document_action', document_action_config: document_action_config, document: document
10
- end
11
-
12
- context "for refworks" do
13
- let(:tool_config) { { if: :render_refworks_action?, partial: "document_action",
14
- name: :refworks, key: :refworks, modal: false } }
15
-
16
- it "should not be modal" do
17
- expect(rendered).to have_link('Export to Refworks')
18
- expect(rendered).not_to have_selector('a[data-ajax-modal]')
19
- end
20
- end
21
- end