mods_display 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c2d5c102f64b65d4313c4aad186328f17edf6475908f360762591ec4ded1f044
4
- data.tar.gz: fefe5bd0aa2a29fe4cb60ad94e40840a3a1fe4a12b30ffccfc08b32361d04a5b
3
+ metadata.gz: b98625a861414ce3c06cd365c9850454a50ccd83719124820a49f4fcb7ff107d
4
+ data.tar.gz: e0c7ded47f3f3f38b821294f4bb9252e0fd7ffdb3fae837dc4da340bc225ab44
5
5
  SHA512:
6
- metadata.gz: 5230f9bda246de22ebaaab5d01f3dc8a6d02f7a92f56a6caa1aa8e7d39039d8cb2d2fd8f39e8797d0757fb49dea269e680191ba9d495ae45ddf20cdfbfb3ae55
7
- data.tar.gz: 5d5144f39760608dcb3a628022d1e8335e54b23a0c6e2b172c7705c68bd1a2fc12fa8b3155635c77bae9c74842bb3aeefc61639ea3c717f0495df7860faf6853
6
+ metadata.gz: efd399144bc193f4db0bfd4b3185346dce1e8cc523fad133af38f61a19d2f41b42e8d05a4fad6ea77dab744eeba2b7727b2dfe911f34c49844ca94fd433320fa
7
+ data.tar.gz: 121a7fa3ba9a0af4887fbc5fac992c95be7c19b888cb632fede718bb2796b1ceb783ce98f16e06de415e149b344584f6c4046dfa2f25c1bcc01823ade826ee46
data/.travis.yml CHANGED
@@ -1,5 +1,4 @@
1
1
  notifications:
2
2
  email: false
3
3
  rvm:
4
- - 2.4.1
5
- - 2.3.4
4
+ - 2.5.3
@@ -1,5 +1,53 @@
1
1
  module ModsDisplay
2
2
  class AccessCondition < Field
3
+ LICENSES = {
4
+ 'cc-none' => { desc: '' },
5
+ 'cc-by' => {
6
+ link: 'http://creativecommons.org/licenses/by/3.0/',
7
+ desc: 'This work is licensed under a Creative Commons Attribution 3.0 Unported License'
8
+ },
9
+ 'cc-by-sa' => {
10
+ link: 'http://creativecommons.org/licenses/by-sa/3.0/',
11
+ desc: 'This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License'
12
+ },
13
+ 'cc-by-nd' => {
14
+ link: 'http://creativecommons.org/licenses/by-nd/3.0/',
15
+ desc: 'This work is licensed under a Creative Commons Attribution-No Derivative Works 3.0 Unported License'
16
+ },
17
+ 'cc-by-nc' => {
18
+ link: 'http://creativecommons.org/licenses/by-nc/3.0/',
19
+ desc: 'This work is licensed under a Creative Commons Attribution-Noncommercial 3.0 Unported License'
20
+ },
21
+ 'cc-by-nc-sa' => {
22
+ link: 'http://creativecommons.org/licenses/by-nc-sa/3.0/',
23
+ desc: 'This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License'
24
+ },
25
+ 'cc-by-nc-nd' => {
26
+ link: 'http://creativecommons.org/licenses/by-nc-nd/3.0/',
27
+ desc: 'This work is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Unported License'
28
+ },
29
+ 'cc-pdm' => {
30
+ link: 'http://creativecommons.org/publicdomain/mark/1.0/',
31
+ desc: 'This work is in the public domain per Creative Commons Public Domain Mark 1.0'
32
+ },
33
+ 'odc-odc-pddl' => {
34
+ link: 'http://opendatacommons.org/licenses/pddl/',
35
+ desc: 'This work is licensed under a Open Data Commons Public Domain Dedication and License (PDDL)'
36
+ },
37
+ 'odc-pddl' => {
38
+ link: 'http://opendatacommons.org/licenses/pddl/',
39
+ desc: 'This work is licensed under a Open Data Commons Public Domain Dedication and License (PDDL)'
40
+ },
41
+ 'odc-odc-by' => {
42
+ link: 'http://opendatacommons.org/licenses/by/',
43
+ desc: 'This work is licensed under a Open Data Commons Attribution License'
44
+ },
45
+ 'odc-odc-odbl' => {
46
+ link: 'http://opendatacommons.org/licenses/odbl/',
47
+ desc: 'This work is licensed under a Open Data Commons Open Database License (ODbL)'
48
+ }
49
+ }.freeze
50
+
3
51
  def fields
4
52
  return_fields = @values.map do |value|
5
53
  ModsDisplay::Values.new(
@@ -28,26 +76,32 @@ module ModsDisplay
28
76
  end
29
77
 
30
78
  def license_statement(element)
31
- element.text[/^(.*) (.*):(.*)$/]
32
- output = "<div class='#{[Regexp.last_match(1), Regexp.last_match(2)].join('-').downcase}'>"
33
- if license_link(Regexp.last_match(1), Regexp.last_match(2))
34
- link = "<a href='#{license_link(Regexp.last_match(1), Regexp.last_match(2))}'>#{Regexp.last_match(3).strip}</a>"
35
- output << link
36
- else
37
- output << Regexp.last_match(3).strip
38
- end
79
+ matches = element.text.match(/^(?<code>.*) (?<type>.*):(?<description>.*)$/)
80
+ code = matches[:code].downcase
81
+ type = matches[:type].downcase
82
+ description = license_description(code, type) || matches[:description]
83
+ url = license_url(code, type)
84
+ output = "<div class='#{code}-#{type}'>"
85
+ output << if url
86
+ "<a href='#{url}'>#{description}</a>"
87
+ else
88
+ description
89
+ end
39
90
  output << '</div>'
40
91
  end
41
92
 
42
- def license_code_urls
43
- { 'cc' => 'http://creativecommons.org/licenses/',
44
- 'odc' => 'http://opendatacommons.org/licenses/' }
93
+ def license_url(code, type)
94
+ key = "#{code}-#{type}"
95
+ return unless LICENSES.key?(key)
96
+
97
+ LICENSES[key][:link]
45
98
  end
46
99
 
47
- def license_link(code, type)
48
- code = code.downcase
49
- return unless license_code_urls.key?(code)
50
- "#{license_code_urls[code]}#{type.downcase}#{"/#{@config.cc_license_version}/" if code == 'cc'}"
100
+ def license_description(code, type)
101
+ key = "#{code}-#{type}"
102
+ return unless LICENSES.key?(key) && LICENSES[key][:desc]
103
+
104
+ LICENSES[key][:desc]
51
105
  end
52
106
 
53
107
  def access_label(element)
@@ -1,3 +1,3 @@
1
1
  module ModsDisplay
2
- VERSION = '0.6.0'
2
+ VERSION = '0.7.0'
3
3
  end
@@ -8,14 +8,6 @@ def mods_display_access_condition(mods_record)
8
8
  )
9
9
  end
10
10
 
11
- def mods_display_versioned_access_condition(mods_record, version)
12
- ModsDisplay::AccessCondition.new(
13
- mods_record,
14
- ModsDisplay::Configuration::AccessCondition.new { cc_license_version version },
15
- double('controller')
16
- )
17
- end
18
-
19
11
  def mods_display_non_ignore_access_condition(mods_record)
20
12
  ModsDisplay::AccessCondition.new(
21
13
  mods_record,
@@ -68,31 +60,19 @@ describe ModsDisplay::AccessCondition do
68
60
  expect(fields.first.values.length).to eq(1)
69
61
  expect(fields.first.values.first).to include("<a href='http://creativecommons.org/licenses/by-sa/3.0/'>")
70
62
  expect(fields.first.values.first).to include(
71
- 'This work is licensed under a Creative Commons Attribution-Noncommercial 3.0 Unported License'
63
+ 'This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License'
72
64
  )
73
65
  end
74
66
  it 'should itentify and link OpenDataCommons licenses properly' do
75
67
  fields = mods_display_access_condition(@odc_license_note).fields
76
68
  expect(fields.length).to eq(1)
77
69
  expect(fields.first.values.length).to eq(1)
78
- expect(fields.first.values.first).to include("<a href='http://opendatacommons.org/licenses/pddl'>")
70
+ expect(fields.first.values.first).to include("<a href='http://opendatacommons.org/licenses/pddl/'>")
79
71
  expect(fields.first.values.first).to include(
80
72
  'This work is licensed under a Open Data Commons Public Domain Dedication and License (PDDL)'
81
73
  )
82
74
  end
83
- it 'should have a configurable version for CC licenses' do
84
- fields = mods_display_versioned_access_condition(@cc_license_note, '4.0').fields
85
- expect(fields.length).to eq(1)
86
- expect(fields.first.values.length).to eq(1)
87
- expect(fields.first.values.first).to include('http://creativecommons.org/licenses/by-sa/4.0/')
88
- expect(fields.first.values.first).not_to include('http://creativecommons.org/licenses/by-sa/3.0/')
89
- end
90
- it 'should not apply configured version to NON-CC licenses' do
91
- fields = mods_display_versioned_access_condition(@odc_license_note, '4.0').fields
92
- expect(fields.length).to eq(1)
93
- expect(fields.first.values.length).to eq(1)
94
- expect(fields.first.values.first).not_to include('/4.0/')
95
- end
75
+
96
76
  it 'should not attempt unknown license types' do
97
77
  fields = mods_display_access_condition(@no_link_license_note).fields
98
78
  expect(fields.length).to eq(1)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mods_display
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jessie Keck
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-01 00:00:00.000000000 Z
11
+ date: 2019-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: stanford-mods
@@ -226,8 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
226
226
  - !ruby/object:Gem::Version
227
227
  version: '0'
228
228
  requirements: []
229
- rubyforge_project:
230
- rubygems_version: 2.7.6
229
+ rubygems_version: 3.0.3
231
230
  signing_key:
232
231
  specification_version: 4
233
232
  summary: The MODS Display gem allows implementers to configure a customized display