mods_display 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/lib/mods_display/fields/access_condition.rb +69 -15
- data/lib/mods_display/version.rb +1 -1
- data/spec/fields/access_condition_spec.rb +3 -23
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b98625a861414ce3c06cd365c9850454a50ccd83719124820a49f4fcb7ff107d
|
4
|
+
data.tar.gz: e0c7ded47f3f3f38b821294f4bb9252e0fd7ffdb3fae837dc4da340bc225ab44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efd399144bc193f4db0bfd4b3185346dce1e8cc523fad133af38f61a19d2f41b42e8d05a4fad6ea77dab744eeba2b7727b2dfe911f34c49844ca94fd433320fa
|
7
|
+
data.tar.gz: 121a7fa3ba9a0af4887fbc5fac992c95be7c19b888cb632fede718bb2796b1ceb783ce98f16e06de415e149b344584f6c4046dfa2f25c1bcc01823ade826ee46
|
data/.travis.yml
CHANGED
@@ -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
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
43
|
-
|
44
|
-
|
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
|
48
|
-
|
49
|
-
return unless
|
50
|
-
|
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)
|
data/lib/mods_display/version.rb
CHANGED
@@ -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-
|
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
|
-
|
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.
|
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:
|
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
|
-
|
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
|