ro-crate 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: 2c4aabc50994541bbcbb2071b805f457e47c9e30176299fdde40741aa5ff1094
4
- data.tar.gz: 0f4d7df6b4eb21961446ce2e3c05fe337fa7ed9e161eb21a7651b8ea6292f988
3
+ metadata.gz: eee42ff56abf6a19d3a0e3575957c338b79a87c5609566618c032ca302ccab8d
4
+ data.tar.gz: 7d36b9517a344a2d2f9559a11229e8a51e2a2e4b02c5ada951d8b86b82051900
5
5
  SHA512:
6
- metadata.gz: f590b0e08e5f813474e4c46e3230b01999d17cf349645b8c86285c8dbe3cd371563405e1e1143a7b68d115764373847ace352029beed404a5cc069e64ef40dab
7
- data.tar.gz: 972a1e14b6faa4986bad9138fdd39861bf54af81dd5678354f84cc0f4bbc3b50252e38cf948d013bb6a979365dedc74e81c48661115f0cd3f408fcdd0744f777
6
+ metadata.gz: 82917f083837b091d304e61188dbcb06cbe9a306676e3c17e4c56d662cb3a65d90bb7f41b5c09503caaf457a0740d30a9011a4f4edc64fe2bf78556a6e9f078e
7
+ data.tar.gz: 430857f30551fb3f4e2c82fce71babfd9574cf4a039ece9dd26318766d054ff4ac9725b3fa6bab134d8e0a5ad5eed01905324aeadbdaf0053730716b57e97eca
data/README.md CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  ![Tests](https://github.com/ResearchObject/ro-crate-ruby/actions/workflows/tests.yml/badge.svg)
4
4
 
5
- This is a WIP gem for creating, manipulating and reading RO-Crates (conforming to version 1.2 of the specification). RO-Crates produced by older versions (1.0, 1.1) of the spec can still be read.
5
+ This is a WIP gem for creating, manipulating and reading RO-Crates (conforming to version 1.3 of the specification). RO-Crates produced by older versions (1.0, 1.1, 1.2) of the spec can still be read.
6
6
 
7
7
  * RO-Crate - https://www.researchobject.org/ro-crate/
8
- * RO-Crate spec (1.2) - https://www.researchobject.org/ro-crate/specification/1.2/
8
+ * RO-Crate spec (1.3) - https://www.researchobject.org/ro-crate/specification/1.3/
9
9
 
10
10
  ## Installation
11
11
 
@@ -6,8 +6,8 @@ module ROCrate
6
6
  IDENTIFIER_1_0 = 'ro-crate-metadata.jsonld'.freeze # 1.0 spec identifier
7
7
  RO_CRATE_BASE = 'https://w3id.org/ro/crate/'
8
8
 
9
- SUPPORTED_VERSIONS = %w[1.0 1.0-DRAFT 1.1 1.1-DRAFT 1.2 1.2-DRAFT].freeze
10
- DEFAULT_VERSION = '1.2'.freeze
9
+ SUPPORTED_VERSIONS = %w[1.0 1.0-DRAFT 1.1 1.1-DRAFT 1.2 1.2-DRAFT 1.3].freeze
10
+ DEFAULT_VERSION = '1.3'.freeze
11
11
 
12
12
  CONTEXT = "#{RO_CRATE_BASE}#{DEFAULT_VERSION}/context".freeze
13
13
  SPEC = "#{RO_CRATE_BASE}#{DEFAULT_VERSION}".freeze
data/ro_crate.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'ro-crate'
3
- s.version = '0.6.0'
3
+ s.version = '0.7.0'
4
4
  s.summary = 'Create, manipulate, read RO-Crates.'
5
5
  s.authors = ['Finn Bacall']
6
6
  s.email = 'finn.bacall@manchester.ac.uk'
data/test/crate_test.rb CHANGED
@@ -378,12 +378,12 @@ class CrateTest < Test::Unit::TestCase
378
378
  assert crate.get('#joehouse')
379
379
  end
380
380
 
381
- test 'defaults to RO-Crate spec 1.2' do
381
+ test 'defaults to RO-Crate spec 1.3' do
382
382
  crate = ROCrate::Crate.new
383
- assert_equal '1.2', crate.metadata.version
384
- assert_equal 'https://w3id.org/ro/crate/1.2/context', crate.metadata.context
385
- assert_equal 'https://w3id.org/ro/crate/1.2', crate.metadata.spec_url
386
- assert_equal({ '@id' => 'https://w3id.org/ro/crate/1.2' }, crate.metadata.properties['conformsTo'])
383
+ assert_equal '1.3', crate.metadata.version
384
+ assert_equal 'https://w3id.org/ro/crate/1.3/context', crate.metadata.context
385
+ assert_equal 'https://w3id.org/ro/crate/1.3', crate.metadata.spec_url
386
+ assert_equal({ '@id' => 'https://w3id.org/ro/crate/1.3' }, crate.metadata.properties['conformsTo'])
387
387
  end
388
388
 
389
389
  test 'can write older spec version' do
@@ -0,0 +1 @@
1
+ I have spaces in my name
@@ -0,0 +1,42 @@
1
+ {
2
+ "@context": "https://w3id.org/ro/crate/1.2/context",
3
+ "@graph": [
4
+ {
5
+ "@id": "ro-crate-metadata.json",
6
+ "@type": "CreativeWork",
7
+ "about": {
8
+ "@id": "./"
9
+ },
10
+ "conformsTo": {
11
+ "@id": "https://w3id.org/ro/crate/1.2"
12
+ }
13
+ },
14
+ {
15
+ "@id": "ro-crate-preview.html",
16
+ "@type": "CreativeWork",
17
+ "about": {
18
+ "@id": "./"
19
+ }
20
+ },
21
+ {
22
+ "@id": "./",
23
+ "@type": "Dataset",
24
+ "hasPart": [
25
+ {
26
+ "@id": "http://example.com/external_ref.txt"
27
+ },
28
+ {
29
+ "@id": "file%20with%20spaces.txt"
30
+ }
31
+ ]
32
+ },
33
+ {
34
+ "@id": "http://example.com/external_ref.txt",
35
+ "@type": "File"
36
+ },
37
+ {
38
+ "@id": "file%20with%20spaces.txt",
39
+ "@type": "File"
40
+ }
41
+ ]
42
+ }
@@ -0,0 +1,82 @@
1
+
2
+ <!DOCTYPE html>
3
+ <html lang="en">
4
+ <head>
5
+ <title>New RO-Crate</title>
6
+ <script type="application/ld+json">{
7
+ "@context": "https://w3id.org/ro/crate/1.2/context",
8
+ "@graph": [
9
+ {
10
+ "@id": "ro-crate-metadata.json",
11
+ "@type": "CreativeWork",
12
+ "about": {
13
+ "@id": "./"
14
+ },
15
+ "conformsTo": {
16
+ "@id": "https://w3id.org/ro/crate/1.2"
17
+ }
18
+ },
19
+ {
20
+ "@id": "ro-crate-preview.html",
21
+ "@type": "CreativeWork",
22
+ "about": {
23
+ "@id": "./"
24
+ }
25
+ },
26
+ {
27
+ "@id": "./",
28
+ "@type": "Dataset",
29
+ "hasPart": [
30
+ {
31
+ "@id": "http://example.com/external_ref.txt"
32
+ },
33
+ {
34
+ "@id": "file%20with%20spaces.txt"
35
+ }
36
+ ]
37
+ },
38
+ {
39
+ "@id": "http://example.com/external_ref.txt",
40
+ "@type": "File"
41
+ },
42
+ {
43
+ "@id": "file%20with%20spaces.txt",
44
+ "@type": "File"
45
+ }
46
+ ]
47
+ }</script>
48
+ <meta name="generator" content="https://github.com/ResearchObject/ro-crate-ruby">
49
+ <meta name="keywords" content="RO-Crate">
50
+ <meta charset="utf-8">
51
+ </head>
52
+ <body>
53
+ <h1>New RO-Crate</h1>
54
+
55
+ <p>
56
+
57
+ </p>
58
+ <dl>
59
+
60
+
61
+
62
+
63
+ </dl>
64
+
65
+ <h2>Contents</h2>
66
+ <ul>
67
+
68
+ <li>
69
+ <strong><a href="http://example.com/external_ref.txt" target="_blank">http://example.com/external_ref.txt</a></strong>
70
+
71
+
72
+ </li>
73
+
74
+ <li>
75
+ <strong>file%20with%20spaces.txt</strong>
76
+
77
+
78
+ </li>
79
+
80
+ </ul>
81
+ </body>
82
+ </html>
@@ -0,0 +1 @@
1
+ I have spaces in my name
@@ -0,0 +1,42 @@
1
+ {
2
+ "@context": "https://w3id.org/ro/crate/1.3/context",
3
+ "@graph": [
4
+ {
5
+ "@id": "ro-crate-metadata.json",
6
+ "@type": "CreativeWork",
7
+ "about": {
8
+ "@id": "./"
9
+ },
10
+ "conformsTo": {
11
+ "@id": "https://w3id.org/ro/crate/1.3"
12
+ }
13
+ },
14
+ {
15
+ "@id": "ro-crate-preview.html",
16
+ "@type": "CreativeWork",
17
+ "about": {
18
+ "@id": "./"
19
+ }
20
+ },
21
+ {
22
+ "@id": "./",
23
+ "@type": "Dataset",
24
+ "hasPart": [
25
+ {
26
+ "@id": "http://example.com/external_ref.txt"
27
+ },
28
+ {
29
+ "@id": "file%20with%20spaces.txt"
30
+ }
31
+ ]
32
+ },
33
+ {
34
+ "@id": "http://example.com/external_ref.txt",
35
+ "@type": "File"
36
+ },
37
+ {
38
+ "@id": "file%20with%20spaces.txt",
39
+ "@type": "File"
40
+ }
41
+ ]
42
+ }
@@ -0,0 +1,82 @@
1
+
2
+ <!DOCTYPE html>
3
+ <html lang="en">
4
+ <head>
5
+ <title>New RO-Crate</title>
6
+ <script type="application/ld+json">{
7
+ "@context": "https://w3id.org/ro/crate/1.3/context",
8
+ "@graph": [
9
+ {
10
+ "@id": "ro-crate-metadata.json",
11
+ "@type": "CreativeWork",
12
+ "about": {
13
+ "@id": "./"
14
+ },
15
+ "conformsTo": {
16
+ "@id": "https://w3id.org/ro/crate/1.3"
17
+ }
18
+ },
19
+ {
20
+ "@id": "ro-crate-preview.html",
21
+ "@type": "CreativeWork",
22
+ "about": {
23
+ "@id": "./"
24
+ }
25
+ },
26
+ {
27
+ "@id": "./",
28
+ "@type": "Dataset",
29
+ "hasPart": [
30
+ {
31
+ "@id": "http://example.com/external_ref.txt"
32
+ },
33
+ {
34
+ "@id": "file%20with%20spaces.txt"
35
+ }
36
+ ]
37
+ },
38
+ {
39
+ "@id": "http://example.com/external_ref.txt",
40
+ "@type": "File"
41
+ },
42
+ {
43
+ "@id": "file%20with%20spaces.txt",
44
+ "@type": "File"
45
+ }
46
+ ]
47
+ }</script>
48
+ <meta name="generator" content="https://github.com/ResearchObject/ro-crate-ruby">
49
+ <meta name="keywords" content="RO-Crate">
50
+ <meta charset="utf-8">
51
+ </head>
52
+ <body>
53
+ <h1>New RO-Crate</h1>
54
+
55
+ <p>
56
+
57
+ </p>
58
+ <dl>
59
+
60
+
61
+
62
+
63
+ </dl>
64
+
65
+ <h2>Contents</h2>
66
+ <ul>
67
+
68
+ <li>
69
+ <strong><a href="http://example.com/external_ref.txt" target="_blank">http://example.com/external_ref.txt</a></strong>
70
+
71
+
72
+ </li>
73
+
74
+ <li>
75
+ <strong>file%20with%20spaces.txt</strong>
76
+
77
+
78
+ </li>
79
+
80
+ </ul>
81
+ </body>
82
+ </html>
data/test/reader_test.rb CHANGED
@@ -188,6 +188,48 @@ class ReaderTest < Test::Unit::TestCase
188
188
  assert crate.preview.source.source.is_a?(ROCrate::PreviewGenerator)
189
189
  end
190
190
 
191
+ test 'can read a 1.2 spec crate' do
192
+ stub_request(:get, "http://example.com/external_ref.txt").to_return(status: 200, body: 'file contents')
193
+
194
+ crate = ROCrate::Reader.read_directory(fixture_file('crate-spec1.2').path)
195
+ file = crate.dereference('file with spaces.txt')
196
+ assert file
197
+ assert file.is_a?(ROCrate::File)
198
+ refute file.remote?
199
+ assert file.source.is_a?(ROCrate::Entry)
200
+ assert_equal 'file%20with%20spaces.txt', file.id
201
+
202
+ ext_file = crate.dereference('http://example.com/external_ref.txt')
203
+ assert ext_file
204
+ assert ext_file.is_a?(ROCrate::File)
205
+ assert ext_file.remote?
206
+ assert ext_file.source.is_a?(ROCrate::RemoteEntry)
207
+ assert_equal 'http://example.com/external_ref.txt', ext_file.id
208
+ assert_equal 'file contents', ext_file.source.read
209
+ assert crate.preview.source.source.is_a?(Pathname)
210
+ end
211
+
212
+ test 'can read a 1.3 spec crate' do
213
+ stub_request(:get, "http://example.com/external_ref.txt").to_return(status: 200, body: 'file contents')
214
+
215
+ crate = ROCrate::Reader.read_directory(fixture_file('crate-spec1.3').path)
216
+ file = crate.dereference('file with spaces.txt')
217
+ assert file
218
+ assert file.is_a?(ROCrate::File)
219
+ refute file.remote?
220
+ assert file.source.is_a?(ROCrate::Entry)
221
+ assert_equal 'file%20with%20spaces.txt', file.id
222
+
223
+ ext_file = crate.dereference('http://example.com/external_ref.txt')
224
+ assert ext_file
225
+ assert ext_file.is_a?(ROCrate::File)
226
+ assert ext_file.remote?
227
+ assert ext_file.source.is_a?(ROCrate::RemoteEntry)
228
+ assert_equal 'http://example.com/external_ref.txt', ext_file.id
229
+ assert_equal 'file contents', ext_file.source.read
230
+ assert crate.preview.source.source.is_a?(Pathname)
231
+ end
232
+
191
233
  test 'reading from directory with unlisted files' do
192
234
  crate = ROCrate::Reader.read_directory(fixture_file('sparse_directory_crate').path)
193
235
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ro-crate
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
  - Finn Bacall
@@ -185,6 +185,12 @@ files:
185
185
  - test/fixtures/conflicting_data_directory/nested.txt
186
186
  - test/fixtures/crate-spec1.1/file with spaces.txt
187
187
  - test/fixtures/crate-spec1.1/ro-crate-metadata.json
188
+ - test/fixtures/crate-spec1.2/file with spaces.txt
189
+ - test/fixtures/crate-spec1.2/ro-crate-metadata.json
190
+ - test/fixtures/crate-spec1.2/ro-crate-preview.html
191
+ - test/fixtures/crate-spec1.3/file with spaces.txt
192
+ - test/fixtures/crate-spec1.3/ro-crate-metadata.json
193
+ - test/fixtures/crate-spec1.3/ro-crate-preview.html
188
194
  - test/fixtures/data.csv
189
195
  - test/fixtures/dir_symlink
190
196
  - test/fixtures/directory.zip