cirneco 0.9.16 → 0.9.17

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.
Files changed (94) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile.lock +70 -67
  3. data/cirneco.gemspec +3 -3
  4. data/lib/cirneco/data_center.rb +0 -2
  5. data/lib/cirneco/doi.rb +2 -90
  6. data/lib/cirneco/media.rb +1 -3
  7. data/lib/cirneco/metadata.rb +0 -2
  8. data/lib/cirneco/utils.rb +3 -3
  9. data/lib/cirneco/version.rb +1 -1
  10. data/lib/cirneco/work.rb +0 -2
  11. data/spec/api_spec.rb +8 -7
  12. data/spec/doi_spec.rb +4 -63
  13. data/spec/fixtures/vcr_cassettes/Cirneco_Work/media/includes_media.yml +42 -56
  14. data/spec/fixtures/vcr_cassettes/Cirneco_Work/schema/BlogPosting.yml +42 -56
  15. data/spec/utils_spec.rb +9 -10
  16. data/spec/work_spec.rb +2 -2
  17. metadata +10 -93
  18. data/data/authors.yml +0 -0
  19. data/data/references.yaml +0 -0
  20. data/data/site.yml +0 -0
  21. data/lib/cirneco/file_utils.rb +0 -371
  22. data/resources/jats-1.1/JATS-journalpublishing1-elements.xsd +0 -8608
  23. data/resources/jats-1.1/JATS-journalpublishing1-mathml3-elements.xsd +0 -8608
  24. data/resources/jats-1.1/JATS-journalpublishing1-mathml3.xsd +0 -48
  25. data/resources/jats-1.1/JATS-journalpublishing1.xsd +0 -59
  26. data/resources/jats-1.1/module-ali.xsd +0 -46
  27. data/resources/jats-1.1/standard-modules/mathml2/common/common-attribs.xsd +0 -44
  28. data/resources/jats-1.1/standard-modules/mathml2/common/math.xsd +0 -126
  29. data/resources/jats-1.1/standard-modules/mathml2/common/xlink-href.xsd +0 -20
  30. data/resources/jats-1.1/standard-modules/mathml2/content/arith.xsd +0 -90
  31. data/resources/jats-1.1/standard-modules/mathml2/content/calculus.xsd +0 -146
  32. data/resources/jats-1.1/standard-modules/mathml2/content/common-attrib.xsd +0 -30
  33. data/resources/jats-1.1/standard-modules/mathml2/content/constants.xsd +0 -83
  34. data/resources/jats-1.1/standard-modules/mathml2/content/constructs.xsd +0 -260
  35. data/resources/jats-1.1/standard-modules/mathml2/content/elementary-functions.xsd +0 -117
  36. data/resources/jats-1.1/standard-modules/mathml2/content/functions.xsd +0 -73
  37. data/resources/jats-1.1/standard-modules/mathml2/content/linear-algebra.xsd +0 -173
  38. data/resources/jats-1.1/standard-modules/mathml2/content/logic.xsd +0 -53
  39. data/resources/jats-1.1/standard-modules/mathml2/content/relations.xsd +0 -55
  40. data/resources/jats-1.1/standard-modules/mathml2/content/semantics.xsd +0 -85
  41. data/resources/jats-1.1/standard-modules/mathml2/content/sets.xsd +0 -236
  42. data/resources/jats-1.1/standard-modules/mathml2/content/statistics.xsd +0 -136
  43. data/resources/jats-1.1/standard-modules/mathml2/content/tokens.xsd +0 -120
  44. data/resources/jats-1.1/standard-modules/mathml2/content/vector-calculus.xsd +0 -88
  45. data/resources/jats-1.1/standard-modules/mathml2/content/zzz.tokens.xsd.from.zip +0 -120
  46. data/resources/jats-1.1/standard-modules/mathml2/mathml2.xsd +0 -59
  47. data/resources/jats-1.1/standard-modules/mathml2/presentation/action.xsd +0 -44
  48. data/resources/jats-1.1/standard-modules/mathml2/presentation/characters.xsd +0 -37
  49. data/resources/jats-1.1/standard-modules/mathml2/presentation/common-attribs.xsd +0 -113
  50. data/resources/jats-1.1/standard-modules/mathml2/presentation/common-types.xsd +0 -103
  51. data/resources/jats-1.1/standard-modules/mathml2/presentation/error.xsd +0 -40
  52. data/resources/jats-1.1/standard-modules/mathml2/presentation/layout.xsd +0 -195
  53. data/resources/jats-1.1/standard-modules/mathml2/presentation/scripts.xsd +0 -186
  54. data/resources/jats-1.1/standard-modules/mathml2/presentation/space.xsd +0 -52
  55. data/resources/jats-1.1/standard-modules/mathml2/presentation/style.xsd +0 -69
  56. data/resources/jats-1.1/standard-modules/mathml2/presentation/table.xsd +0 -216
  57. data/resources/jats-1.1/standard-modules/mathml2/presentation/tokens.xsd +0 -124
  58. data/resources/jats-1.1/standard-modules/xlink.xsd +0 -100
  59. data/resources/jats-1.1/standard-modules/xml.xsd +0 -287
  60. data/spec/file_utils_spec.rb +0 -203
  61. data/spec/fixtures/apa.csl +0 -621
  62. data/spec/fixtures/authors.yml +0 -19
  63. data/spec/fixtures/cool-dois/index.html +0 -404
  64. data/spec/fixtures/cool-dois-minted/index.html +0 -359
  65. data/spec/fixtures/cool-dois-minted.html.md +0 -99
  66. data/spec/fixtures/cool-dois-missing-metadata/index.html +0 -356
  67. data/spec/fixtures/cool-dois-no-accession-number.html.md +0 -97
  68. data/spec/fixtures/cool-dois-no-json-ld/index.html +0 -352
  69. data/spec/fixtures/cool-dois.html.md +0 -100
  70. data/spec/fixtures/cool-dois.yml +0 -10
  71. data/spec/fixtures/index-minted.html +0 -271
  72. data/spec/fixtures/index.html +0 -320
  73. data/spec/fixtures/index.html.erb +0 -42
  74. data/spec/fixtures/references.bib +0 -506
  75. data/spec/fixtures/references.yaml +0 -1060
  76. data/spec/fixtures/site.yml +0 -8
  77. data/spec/fixtures/vcr_cassettes/Cirneco_DataCenter/jats/should_generate_jats_for_all_urls.yml +0 -38
  78. data/spec/fixtures/vcr_cassettes/Cirneco_DataCenter/mint_and_hide_DOIs/should_hide_for_all_urls.yml +0 -38
  79. data/spec/fixtures/vcr_cassettes/Cirneco_DataCenter/mint_and_hide_DOIs/should_mint_and_hide_for_all_urls.yml +0 -38
  80. data/spec/fixtures/vcr_cassettes/Cirneco_DataCenter/mint_and_hide_DOIs/should_mint_for_all_urls.yml +0 -38
  81. data/spec/fixtures/vcr_cassettes/Cirneco_Doi/jats/writes_jats_for_list_of_urls.yml +0 -38
  82. data/spec/fixtures/vcr_cassettes/Cirneco_Doi/mint_and_hide_DOIs/hides_dois_for_list_of_urls.yml +0 -38
  83. data/spec/fixtures/vcr_cassettes/Cirneco_Doi/mint_and_hide_DOIs/mints_and_hides_dois_for_list_of_urls.yml +0 -38
  84. data/spec/fixtures/vcr_cassettes/Cirneco_Doi/mint_and_hide_DOIs/mints_dois_for_list_of_urls.yml +0 -38
  85. data/spec/fixtures/vcr_cassettes/Cirneco_Work/DOI_API/get/should_get_all_dois.yml +0 -121
  86. data/spec/fixtures/vcr_cassettes/Cirneco_Work/DOI_API/get/should_get_doi.yml +0 -121
  87. data/spec/fixtures/vcr_cassettes/Cirneco_Work/DOI_API/get/should_get_doi_not_found.yml +0 -121
  88. data/spec/fixtures/vcr_cassettes/Cirneco_Work/DOI_API/get/username_missing.yml +0 -121
  89. data/spec/fixtures/vcr_cassettes/Cirneco_Work/DOI_API/put/should_put_doi.yml +0 -121
  90. data/spec/fixtures/vcr_cassettes/Cirneco_Work/Media_API/get/should_get_media.yml +0 -121
  91. data/spec/fixtures/vcr_cassettes/Cirneco_Work/Media_API/post/should_post_media.yml +0 -121
  92. data/spec/fixtures/vcr_cassettes/Cirneco_Work/Metadata_API/delete/should_delete_metadata.yml +0 -121
  93. data/spec/fixtures/vcr_cassettes/Cirneco_Work/Metadata_API/get/should_get_metadata.yml +0 -121
  94. data/spec/fixtures/vcr_cassettes/Cirneco_Work/Metadata_API/post/should_post_metadata.yml +0 -121
@@ -1,287 +0,0 @@
1
- <?xml version='1.0'?>
2
- <?xml-stylesheet href="../2008/09/xsd.xsl" type="text/xsl"?>
3
- <xs:schema targetNamespace="http://www.w3.org/XML/1998/namespace"
4
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
5
- xmlns ="http://www.w3.org/1999/xhtml"
6
- xml:lang="en">
7
-
8
- <xs:annotation>
9
- <xs:documentation>
10
- <div>
11
- <h1>About the XML namespace</h1>
12
-
13
- <div class="bodytext">
14
- <p>
15
- This schema document describes the XML namespace, in a form
16
- suitable for import by other schema documents.
17
- </p>
18
- <p>
19
- See <a href="http://www.w3.org/XML/1998/namespace.html">
20
- http://www.w3.org/XML/1998/namespace.html</a> and
21
- <a href="http://www.w3.org/TR/REC-xml">
22
- http://www.w3.org/TR/REC-xml</a> for information
23
- about this namespace.
24
- </p>
25
- <p>
26
- Note that local names in this namespace are intended to be
27
- defined only by the World Wide Web Consortium or its subgroups.
28
- The names currently defined in this namespace are listed below.
29
- They should not be used with conflicting semantics by any Working
30
- Group, specification, or document instance.
31
- </p>
32
- <p>
33
- See further below in this document for more information about <a
34
- href="#usage">how to refer to this schema document from your own
35
- XSD schema documents</a> and about <a href="#nsversioning">the
36
- namespace-versioning policy governing this schema document</a>.
37
- </p>
38
- </div>
39
- </div>
40
- </xs:documentation>
41
- </xs:annotation>
42
-
43
- <xs:attribute name="lang">
44
- <xs:annotation>
45
- <xs:documentation>
46
- <div>
47
-
48
- <h3>lang (as an attribute name)</h3>
49
- <p>
50
- denotes an attribute whose value
51
- is a language code for the natural language of the content of
52
- any element; its value is inherited. This name is reserved
53
- by virtue of its definition in the XML specification.</p>
54
-
55
- </div>
56
- <div>
57
- <h4>Notes</h4>
58
- <p>
59
- Attempting to install the relevant ISO 2- and 3-letter
60
- codes as the enumerated possible values is probably never
61
- going to be a realistic possibility.
62
- </p>
63
- <p>
64
- See BCP 47 at <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">
65
- http://www.rfc-editor.org/rfc/bcp/bcp47.txt</a>
66
- and the IANA language subtag registry at
67
- <a href="http://www.iana.org/assignments/language-subtag-registry">
68
- http://www.iana.org/assignments/language-subtag-registry</a>
69
- for further information.
70
- </p>
71
- <p>
72
- The union allows for the 'un-declaration' of xml:lang with
73
- the empty string.
74
- </p>
75
- </div>
76
- </xs:documentation>
77
- </xs:annotation>
78
- <xs:simpleType>
79
- <xs:union memberTypes="xs:language">
80
- <xs:simpleType>
81
- <xs:restriction base="xs:string">
82
- <xs:enumeration value=""/>
83
- </xs:restriction>
84
- </xs:simpleType>
85
- </xs:union>
86
- </xs:simpleType>
87
- </xs:attribute>
88
-
89
- <xs:attribute name="space">
90
- <xs:annotation>
91
- <xs:documentation>
92
- <div>
93
-
94
- <h3>space (as an attribute name)</h3>
95
- <p>
96
- denotes an attribute whose
97
- value is a keyword indicating what whitespace processing
98
- discipline is intended for the content of the element; its
99
- value is inherited. This name is reserved by virtue of its
100
- definition in the XML specification.</p>
101
-
102
- </div>
103
- </xs:documentation>
104
- </xs:annotation>
105
- <xs:simpleType>
106
- <xs:restriction base="xs:NCName">
107
- <xs:enumeration value="default"/>
108
- <xs:enumeration value="preserve"/>
109
- </xs:restriction>
110
- </xs:simpleType>
111
- </xs:attribute>
112
-
113
- <xs:attribute name="base" type="xs:anyURI"> <xs:annotation>
114
- <xs:documentation>
115
- <div>
116
-
117
- <h3>base (as an attribute name)</h3>
118
- <p>
119
- denotes an attribute whose value
120
- provides a URI to be used as the base for interpreting any
121
- relative URIs in the scope of the element on which it
122
- appears; its value is inherited. This name is reserved
123
- by virtue of its definition in the XML Base specification.</p>
124
-
125
- <p>
126
- See <a
127
- href="http://www.w3.org/TR/xmlbase/">http://www.w3.org/TR/xmlbase/</a>
128
- for information about this attribute.
129
- </p>
130
- </div>
131
- </xs:documentation>
132
- </xs:annotation>
133
- </xs:attribute>
134
-
135
- <xs:attribute name="id" type="xs:ID">
136
- <xs:annotation>
137
- <xs:documentation>
138
- <div>
139
-
140
- <h3>id (as an attribute name)</h3>
141
- <p>
142
- denotes an attribute whose value
143
- should be interpreted as if declared to be of type ID.
144
- This name is reserved by virtue of its definition in the
145
- xml:id specification.</p>
146
-
147
- <p>
148
- See <a
149
- href="http://www.w3.org/TR/xml-id/">http://www.w3.org/TR/xml-id/</a>
150
- for information about this attribute.
151
- </p>
152
- </div>
153
- </xs:documentation>
154
- </xs:annotation>
155
- </xs:attribute>
156
-
157
- <xs:attributeGroup name="specialAttrs">
158
- <xs:attribute ref="xml:base"/>
159
- <xs:attribute ref="xml:lang"/>
160
- <xs:attribute ref="xml:space"/>
161
- <xs:attribute ref="xml:id"/>
162
- </xs:attributeGroup>
163
-
164
- <xs:annotation>
165
- <xs:documentation>
166
- <div>
167
-
168
- <h3>Father (in any context at all)</h3>
169
-
170
- <div class="bodytext">
171
- <p>
172
- denotes Jon Bosak, the chair of
173
- the original XML Working Group. This name is reserved by
174
- the following decision of the W3C XML Plenary and
175
- XML Coordination groups:
176
- </p>
177
- <blockquote>
178
- <p>
179
- In appreciation for his vision, leadership and
180
- dedication the W3C XML Plenary on this 10th day of
181
- February, 2000, reserves for Jon Bosak in perpetuity
182
- the XML name "xml:Father".
183
- </p>
184
- </blockquote>
185
- </div>
186
- </div>
187
- </xs:documentation>
188
- </xs:annotation>
189
-
190
- <xs:annotation>
191
- <xs:documentation>
192
- <div xml:id="usage" id="usage">
193
- <h2><a name="usage">About this schema document</a></h2>
194
-
195
- <div class="bodytext">
196
- <p>
197
- This schema defines attributes and an attribute group suitable
198
- for use by schemas wishing to allow <code>xml:base</code>,
199
- <code>xml:lang</code>, <code>xml:space</code> or
200
- <code>xml:id</code> attributes on elements they define.
201
- </p>
202
- <p>
203
- To enable this, such a schema must import this schema for
204
- the XML namespace, e.g. as follows:
205
- </p>
206
- <pre>
207
- &lt;schema . . .>
208
- . . .
209
- &lt;import namespace="http://www.w3.org/XML/1998/namespace"
210
- schemaLocation="http://www.w3.org/2001/xml.xsd"/>
211
- </pre>
212
- <p>
213
- or
214
- </p>
215
- <pre>
216
- &lt;import namespace="http://www.w3.org/XML/1998/namespace"
217
- schemaLocation="http://www.w3.org/2009/01/xml.xsd"/>
218
- </pre>
219
- <p>
220
- Subsequently, qualified reference to any of the attributes or the
221
- group defined below will have the desired effect, e.g.
222
- </p>
223
- <pre>
224
- &lt;type . . .>
225
- . . .
226
- &lt;attributeGroup ref="xml:specialAttrs"/>
227
- </pre>
228
- <p>
229
- will define a type which will schema-validate an instance element
230
- with any of those attributes.
231
- </p>
232
- </div>
233
- </div>
234
- </xs:documentation>
235
- </xs:annotation>
236
-
237
- <xs:annotation>
238
- <xs:documentation>
239
- <div id="nsversioning" xml:id="nsversioning">
240
- <h2><a name="nsversioning">Versioning policy for this schema document</a></h2>
241
- <div class="bodytext">
242
- <p>
243
- In keeping with the XML Schema WG's standard versioning
244
- policy, this schema document will persist at
245
- <a href="http://www.w3.org/2009/01/xml.xsd">
246
- http://www.w3.org/2009/01/xml.xsd</a>.
247
- </p>
248
- <p>
249
- At the date of issue it can also be found at
250
- <a href="http://www.w3.org/2001/xml.xsd">
251
- http://www.w3.org/2001/xml.xsd</a>.
252
- </p>
253
- <p>
254
- The schema document at that URI may however change in the future,
255
- in order to remain compatible with the latest version of XML
256
- Schema itself, or with the XML namespace itself. In other words,
257
- if the XML Schema or XML namespaces change, the version of this
258
- document at <a href="http://www.w3.org/2001/xml.xsd">
259
- http://www.w3.org/2001/xml.xsd
260
- </a>
261
- will change accordingly; the version at
262
- <a href="http://www.w3.org/2009/01/xml.xsd">
263
- http://www.w3.org/2009/01/xml.xsd
264
- </a>
265
- will not change.
266
- </p>
267
- <p>
268
- Previous dated (and unchanging) versions of this schema
269
- document are at:
270
- </p>
271
- <ul>
272
- <li><a href="http://www.w3.org/2009/01/xml.xsd">
273
- http://www.w3.org/2009/01/xml.xsd</a></li>
274
- <li><a href="http://www.w3.org/2007/08/xml.xsd">
275
- http://www.w3.org/2007/08/xml.xsd</a></li>
276
- <li><a href="http://www.w3.org/2004/10/xml.xsd">
277
- http://www.w3.org/2004/10/xml.xsd</a></li>
278
- <li><a href="http://www.w3.org/2001/03/xml.xsd">
279
- http://www.w3.org/2001/03/xml.xsd</a></li>
280
- </ul>
281
- </div>
282
- </div>
283
- </xs:documentation>
284
- </xs:annotation>
285
-
286
- </xs:schema>
287
-
@@ -1,203 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Cirneco::DataCenter, vcr: true, :order => :defined do
4
- let(:prefix) { ENV['PREFIX'] }
5
- let(:username) { ENV['MDS_USERNAME'] }
6
- let(:password) { ENV['MDS_PASSWORD'] }
7
- let(:source_dir) { "/spec/fixtures/" }
8
- let(:bibliography) { "spec/fixtures/references.yaml" }
9
- let(:options) { { username: username,
10
- password: password,
11
- sandbox: true,
12
- build_dir: source_dir,
13
- source_dir: source_dir } }
14
-
15
- subject { Cirneco::DataCenter.new(prefix: prefix,
16
- username: username,
17
- password: password) }
18
-
19
- context "accession_number" do
20
- it 'should get existing' do
21
- filepath = fixture_path + 'cool-dois.html.md'
22
- response = subject.get_accession_number(filepath)
23
- expect(response).to eq(123)
24
- end
25
-
26
- it 'should get existing for folder' do
27
- response = subject.get_all_accession_numbers(fixture_path)
28
- expect(response).to eq([123, 124])
29
- end
30
-
31
- it 'should update for file' do
32
- filepath = fixture_path + 'cool-dois.html.md'
33
- response = subject.update_accession_number(filepath)
34
- expect(response).to eq("Accession number MS-123 not changed for cool-dois.html.md")
35
- end
36
-
37
- it 'should update for all files' do
38
- response = subject.update_all_accession_numbers(fixture_path, opt_in: true)
39
- expect(response).to eq(["Accession number MS-124 not changed for cool-dois-minted.html.md", "File cool-dois-no-accession-number.html.md ignored: no empty accession_number", "Accession number MS-123 not changed for cool-dois.html.md"])
40
- end
41
- end
42
-
43
- context "mint and hide DOIs" do
44
- it 'get urls for works' do
45
- filepath = fixture_path + 'index.html'
46
- response = subject.get_urls_for_works(filepath)
47
- expect(response.length).to eq(2)
48
- end
49
-
50
- it 'should mint for url' do
51
- filepath = fixture_path + 'cool-dois/index.html'
52
- response = subject.mint_doi_for_url(filepath, options)
53
- expect(response).to eq("DOI 10.5438/55e5-t5c0 minted for cool-dois.html.md")
54
- end
55
-
56
- it 'should hide for url' do
57
- filepath = fixture_path + 'cool-dois-minted/index.html'
58
- response = subject.hide_doi_for_url(filepath, options)
59
- expect(response).to eq("DOI 10.5438/55e5-t5c0 hidden for cool-dois-minted.html.md")
60
- end
61
-
62
- it 'should mint and hide for url' do
63
- filepath = fixture_path + 'cool-dois/index.html'
64
- response = subject.mint_and_hide_doi_for_url(filepath, options)
65
- expect(response).to eq("DOI 10.5438/55e5-t5c0 minted and hidden for cool-dois.html.md")
66
- end
67
-
68
- it 'should mint for all urls' do
69
- filepath = fixture_path + 'index.html'
70
- response = subject.mint_dois_for_all_urls(filepath, options)
71
- expect(response).to eq("DOI 10.5438/55e5-t5c0 minted for cool-dois.html.md\nDOI 10.5438/0007-nw90 minted for index.html.erb")
72
- end
73
-
74
- it 'should hide for all urls' do
75
- filepath = fixture_path + 'index-minted.html'
76
- response = subject.hide_dois_for_all_urls(filepath, options)
77
- expect(response).to eq("No DOI for cool-dois.html.md\nErrors for DOI 10.5438/0000-nw90: Not found\n")
78
- end
79
-
80
- it 'should mint and hide for all urls' do
81
- filepath = fixture_path + 'index.html'
82
- response = subject.mint_and_hide_dois_for_all_urls(filepath, options)
83
- expect(response).to eq("DOI 10.5438/55e5-t5c0 minted and hidden for cool-dois.html.md\nDOI 10.5438/0000-00ss minted and hidden for index.html.erb")
84
- end
85
-
86
- it 'should get_json_ld_from_work' do
87
- filepath = fixture_path + 'cool-dois/index.html'
88
- json = subject.get_json_ld_from_work(filepath)
89
- metadata = JSON.parse(json)
90
- expect(metadata["url"]).to eq("https://blog.datacite.org/cool-dois/")
91
- expect(metadata["author"]).to eq([{"@type"=>"Person", "@id"=>"http://orcid.org/0000-0003-1419-2405", "givenName"=>"Martin", "familyName"=>"Fenner", "name"=>"Martin Fenner"}])
92
- expect(metadata["description"]).to eq("In 1998 Tim Berners-Lee coined the term cool URIs (1998), that is URIs that don’t change. We know that URLs referenced in the scholarly literature are often not cool, leading to link rot (Klein et al., 2014) and making it hard or impossible to find...")
93
- expect(metadata["citation"]).to eq([{"@type"=>"CreativeWork",
94
- "@id"=>"https://www.w3.org/Provider/Style/URI"},
95
- {"@type"=>"CreativeWork",
96
- "@id"=>"https://doi.org/10.1371/journal.pone.0115253"}])
97
- expect(metadata["isPartOf"]).to eq("@type"=>"Blog", "@id"=>"https://blog.datacite.org", "name"=>"DataCite Blog")
98
- end
99
-
100
- it 'should post_metadata_for_work' do
101
- filepath = fixture_path + 'cool-dois/index.html'
102
- json = subject.get_json_ld_from_work(filepath)
103
- response = subject.post_metadata_for_work(json, options)
104
- expect(response.body["data"]).to eq("OK")
105
- expect(response.status).to eq(201)
106
- end
107
-
108
- it 'should hide_metadata_for_work' do
109
- filepath = fixture_path + 'cool-dois/index.html'
110
- json = subject.get_json_ld_from_work(filepath)
111
- response = subject.hide_metadata_for_work(json, options)
112
- expect(response.body["data"]).to eq("OK")
113
- expect(response.status).to eq(200)
114
- end
115
- end
116
-
117
- context "jats" do
118
- it 'should generate metadata for jats' do
119
- filepath = fixture_path + 'cool-dois/index.html'
120
- metadata = subject.generate_metadata_for_jats(filepath)
121
- expect(metadata["author"]).to eq([{"given_name"=>"Martin", "family_name"=>"Fenner", "orcid"=>"0000-0003-1419-2405"}])
122
- expect(metadata["license_url"]).to eq("https://creativecommons.org/licenses/by/4.0/")
123
- end
124
-
125
- it 'should generate jats xml' do
126
- filepath = fixture_path + 'cool-dois/index.html'
127
- expect(subject.generate_jats_for_url(filepath, options.merge(bibliography: bibliography))).to eq("JATS XML written for cool-dois.html.md")
128
- end
129
-
130
- it 'should generate jats for all urls' do
131
- filepath = fixture_path + 'index.html'
132
- response = subject.generate_jats_for_all_urls(filepath, options)
133
- expect(response).to eq("JATS XML written for cool-dois.html.md\nJATS XML written for index.html.erb")
134
- end
135
-
136
- # it 'should validate jats xml' do
137
- # filepath = fixture_path + 'cool-dois/index.html'
138
- # expect(subject.generate_jats_for_url(filepath, options.merge(bibliography: bibliography))).to eq("JATS XML written for cool-dois.html.md")
139
- # xml = IO.read(fixture_path + 'cool-dois/cool-dois.xml')
140
- # expect(subject.validate_jats(xml).body["errors"]).to be_empty
141
- # end
142
- end
143
-
144
- context "get_related_identifiers" do
145
- it 'isPartOf' do
146
- metadata = { "isPartOf" => {
147
- "@type" => "Blog",
148
- "@id" => "https://blog.datacite.org",
149
- "name" => "DataCite Blog" } }
150
- expect(subject.get_related_identifiers(metadata)).to eq([{:value=>"https://blog.datacite.org/", :related_identifier_type=>"URL", :relation_type=>"IsPartOf"}])
151
- end
152
- end
153
-
154
- context "filepath from url" do
155
- it 'https://blog.datacite.org/' do
156
- url = 'https://blog.datacite.org/'
157
- filename, build_path, source_path = subject.filepath_from_url(url, build_dir: source_dir, source_dir: source_dir)
158
- expect(filename).to eq("index.html.erb")
159
- expect(source_path).to eq(fixture_path + "index.html.erb")
160
- expect(build_path).to eq(fixture_path + "index.html")
161
- end
162
-
163
- it 'https://blog.datacite.org' do
164
- url = 'https://blog.datacite.org'
165
- filename, build_path, source_path = subject.filepath_from_url(url, build_dir: source_dir, source_dir: source_dir)
166
- expect(filename).to eq("index.html.erb")
167
- expect(source_path).to eq(fixture_path + "index.html.erb")
168
- expect(build_path).to eq(fixture_path + "index.html")
169
- end
170
-
171
- it 'index.html' do
172
- url = fixture_path + 'index.html'
173
- filename, build_path, source_path = subject.filepath_from_url(url, build_dir: source_dir, source_dir: source_dir)
174
- expect(filename).to eq("index.html.erb")
175
- expect(source_path).to eq(fixture_path + "index.html.erb")
176
- expect(build_path).to eq(fixture_path + "index.html")
177
- end
178
-
179
- it 'index.html basename' do
180
- url = 'index.html'
181
- filename, build_path, source_path = subject.filepath_from_url(url, build_dir: source_dir, source_dir: source_dir)
182
- expect(filename).to eq("index.html.erb")
183
- expect(source_path).to eq(fixture_path + "index.html.erb")
184
- expect(build_path).to eq(fixture_path + "index.html")
185
- end
186
-
187
- it 'cool-dois.html' do
188
- url = fixture_path + 'cool-dois.html'
189
- filename, build_path, source_path = subject.filepath_from_url(url, build_dir: source_dir, source_dir: source_dir)
190
- expect(filename).to eq("cool-dois.html.md")
191
- expect(source_path).to eq(fixture_path + "cool-dois.html.md")
192
- expect(build_path).to eq(fixture_path + "cool-dois/index.html")
193
- end
194
-
195
- it 'cool-dois.html basename' do
196
- url = 'cool-dois.html'
197
- filename, build_path, source_path = subject.filepath_from_url(url, build_dir: source_dir, source_dir: source_dir)
198
- expect(filename).to eq("cool-dois.html.md")
199
- expect(source_path).to eq(fixture_path + "cool-dois.html.md")
200
- expect(build_path).to eq(fixture_path + "cool-dois/index.html")
201
- end
202
- end
203
- end