ro-crate 0.4.9 → 0.4.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +13 -13
- data/README.md +39 -0
- data/lib/ro_crate/model/crate.rb +48 -6
- data/lib/ro_crate/model/data_entity.rb +5 -4
- data/lib/ro_crate/model/directory.rb +2 -4
- data/lib/ro_crate/model/entity.rb +41 -4
- data/lib/ro_crate/model/entry.rb +2 -2
- data/lib/ro_crate/model/file.rb +2 -4
- data/lib/ro_crate/model/metadata.rb +9 -1
- data/lib/ro_crate/model/organization.rb +1 -1
- data/lib/ro_crate/model/preview.rb +3 -15
- data/lib/ro_crate/model/preview_generator.rb +40 -0
- data/lib/ro_crate/model/remote_entry.rb +1 -12
- data/lib/ro_crate/reader.rb +76 -19
- data/lib/ro_crate/writer.rb +4 -4
- data/lib/ro_crate.rb +2 -1
- data/ro_crate.gemspec +3 -3
- data/test/crate_test.rb +58 -3
- data/test/directory_test.rb +21 -21
- data/test/entity_test.rb +114 -0
- data/test/fixtures/biobb_hpc_workflows-condapack.zip +0 -0
- data/test/fixtures/conflicting_data_directory/info.txt +1 -0
- data/test/fixtures/conflicting_data_directory/nested.txt +1 -0
- data/test/fixtures/nested_directory.zip +0 -0
- data/test/fixtures/ro-crate-galaxy-sortchangecase/LICENSE +176 -0
- data/test/fixtures/ro-crate-galaxy-sortchangecase/README.md +6 -0
- data/test/fixtures/ro-crate-galaxy-sortchangecase/ro-crate-metadata.json +133 -0
- data/test/fixtures/ro-crate-galaxy-sortchangecase/sort-and-change-case.ga +118 -0
- data/test/fixtures/ro-crate-galaxy-sortchangecase/test/test1/input.bed +3 -0
- data/test/fixtures/ro-crate-galaxy-sortchangecase/test/test1/output_exp.bed +3 -0
- data/test/fixtures/ro-crate-galaxy-sortchangecase/test/test1/sort-and-change-case-test.yml +8 -0
- data/test/fixtures/sparse_directory_crate/ro-crate-preview.html +60 -59
- data/test/reader_test.rb +83 -40
- data/test/test_helper.rb +5 -1
- data/test/writer_test.rb +59 -2
- metadata +26 -8
@@ -0,0 +1,133 @@
|
|
1
|
+
{
|
2
|
+
"@context": [
|
3
|
+
"https://w3id.org/ro/crate/1.1/context",
|
4
|
+
{
|
5
|
+
"TestSuite": "https://w3id.org/ro/terms/test#TestSuite",
|
6
|
+
"TestInstance": "https://w3id.org/ro/terms/test#TestInstance",
|
7
|
+
"TestService": "https://w3id.org/ro/terms/test#TestService",
|
8
|
+
"TestDefinition": "https://w3id.org/ro/terms/test#TestDefinition",
|
9
|
+
"PlanemoEngine": "https://w3id.org/ro/terms/test#PlanemoEngine",
|
10
|
+
"JenkinsService": "https://w3id.org/ro/terms/test#JenkinsService",
|
11
|
+
"TravisService": "https://w3id.org/ro/terms/test#TravisService",
|
12
|
+
"GithubService": "https://w3id.org/ro/terms/test#GithubService",
|
13
|
+
"instance": "https://w3id.org/ro/terms/test#instance",
|
14
|
+
"runsOn": "https://w3id.org/ro/terms/test#runsOn",
|
15
|
+
"resource": "https://w3id.org/ro/terms/test#resource",
|
16
|
+
"definition": "https://w3id.org/ro/terms/test#definition",
|
17
|
+
"engineVersion": "https://w3id.org/ro/terms/test#engineVersion"
|
18
|
+
}
|
19
|
+
],
|
20
|
+
"@graph": [
|
21
|
+
{
|
22
|
+
"@id": "ro-crate-metadata.json",
|
23
|
+
"@type": "CreativeWork",
|
24
|
+
"about": {
|
25
|
+
"@id": "./"
|
26
|
+
},
|
27
|
+
"conformsTo": {
|
28
|
+
"@id": "https://w3id.org/ro/crate/1.1"
|
29
|
+
}
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"@id": "./",
|
33
|
+
"@type": "Dataset",
|
34
|
+
"name": "sort-and-change-case",
|
35
|
+
"description": "sort lines and change text to upper case",
|
36
|
+
"license": "Apache-2.0",
|
37
|
+
"mainEntity": {
|
38
|
+
"@id": "sort-and-change-case.ga"
|
39
|
+
},
|
40
|
+
"hasPart": [
|
41
|
+
{
|
42
|
+
"@id": "sort-and-change-case.ga"
|
43
|
+
},
|
44
|
+
{
|
45
|
+
"@id": "LICENSE"
|
46
|
+
},
|
47
|
+
{
|
48
|
+
"@id": "README.md"
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"@id": "test/test1/sort-and-change-case-test.yml"
|
52
|
+
}
|
53
|
+
],
|
54
|
+
"mentions": [
|
55
|
+
{
|
56
|
+
"@id": "#test1"
|
57
|
+
}
|
58
|
+
]
|
59
|
+
},
|
60
|
+
{
|
61
|
+
"@id": "sort-and-change-case.ga",
|
62
|
+
"@type": [
|
63
|
+
"File",
|
64
|
+
"SoftwareSourceCode",
|
65
|
+
"ComputationalWorkflow"
|
66
|
+
],
|
67
|
+
"programmingLanguage": {
|
68
|
+
"@id": "#galaxy"
|
69
|
+
},
|
70
|
+
"name": "sort-and-change-case"
|
71
|
+
},
|
72
|
+
{
|
73
|
+
"@id": "LICENSE",
|
74
|
+
"@type": "File"
|
75
|
+
},
|
76
|
+
{
|
77
|
+
"@id": "README.md",
|
78
|
+
"@type": "File"
|
79
|
+
},
|
80
|
+
{
|
81
|
+
"@id": "#galaxy",
|
82
|
+
"@type": "ComputerLanguage",
|
83
|
+
"name": "Galaxy",
|
84
|
+
"identifier": {
|
85
|
+
"@id": "https://galaxyproject.org/"
|
86
|
+
},
|
87
|
+
"url": {
|
88
|
+
"@id": "https://galaxyproject.org/"
|
89
|
+
}
|
90
|
+
},
|
91
|
+
{
|
92
|
+
"@id": "#test1",
|
93
|
+
"name": "test1",
|
94
|
+
"@type": "TestSuite",
|
95
|
+
"mainEntity": {
|
96
|
+
"@id": "sort-and-change-case.ga"
|
97
|
+
},
|
98
|
+
"instance": [
|
99
|
+
{"@id": "#test1_1"}
|
100
|
+
],
|
101
|
+
"definition": {"@id": "test/test1/sort-and-change-case-test.yml"}
|
102
|
+
},
|
103
|
+
{
|
104
|
+
"@id": "#test1_1",
|
105
|
+
"name": "test1_1",
|
106
|
+
"@type": "TestInstance",
|
107
|
+
"runsOn": {"@id": "https://w3id.org/ro/terms/test#JenkinsService"},
|
108
|
+
"url": "http://example.org/jenkins",
|
109
|
+
"resource": "job/tests/"
|
110
|
+
},
|
111
|
+
{
|
112
|
+
"@id": "test/test1/sort-and-change-case-test.yml",
|
113
|
+
"@type": [
|
114
|
+
"File",
|
115
|
+
"TestDefinition"
|
116
|
+
],
|
117
|
+
"conformsTo": {"@id": "https://w3id.org/ro/terms/test#PlanemoEngine"},
|
118
|
+
"engineVersion": ">=0.70"
|
119
|
+
},
|
120
|
+
{
|
121
|
+
"@id": "https://w3id.org/ro/terms/test#JenkinsService",
|
122
|
+
"@type": "TestService",
|
123
|
+
"name": "Jenkins",
|
124
|
+
"url": {"@id": "https://www.jenkins.io"}
|
125
|
+
},
|
126
|
+
{
|
127
|
+
"@id": "https://w3id.org/ro/terms/test#PlanemoEngine",
|
128
|
+
"@type": "SoftwareApplication",
|
129
|
+
"name": "Planemo",
|
130
|
+
"url": {"@id": "https://github.com/galaxyproject/planemo"}
|
131
|
+
}
|
132
|
+
]
|
133
|
+
}
|
@@ -0,0 +1,118 @@
|
|
1
|
+
{
|
2
|
+
"uuid": "e2a8566c-c025-4181-9e90-7ed29d4e4df1",
|
3
|
+
"tags": [],
|
4
|
+
"format-version": "0.1",
|
5
|
+
"name": "sort-and-change-case",
|
6
|
+
"version": 0,
|
7
|
+
"steps": {
|
8
|
+
"0": {
|
9
|
+
"tool_id": null,
|
10
|
+
"tool_version": null,
|
11
|
+
"outputs": [],
|
12
|
+
"workflow_outputs": [],
|
13
|
+
"input_connections": {},
|
14
|
+
"tool_state": "{}",
|
15
|
+
"id": 0,
|
16
|
+
"uuid": "5a36fad2-66c7-4b9e-8759-0fbcae9b8541",
|
17
|
+
"errors": null,
|
18
|
+
"name": "Input dataset",
|
19
|
+
"label": "bed_input",
|
20
|
+
"inputs": [],
|
21
|
+
"position": {
|
22
|
+
"top": 200,
|
23
|
+
"left": 200
|
24
|
+
},
|
25
|
+
"annotation": "",
|
26
|
+
"content_id": null,
|
27
|
+
"type": "data_input"
|
28
|
+
},
|
29
|
+
"1": {
|
30
|
+
"tool_id": "sort1",
|
31
|
+
"tool_version": "1.1.0",
|
32
|
+
"outputs": [
|
33
|
+
{
|
34
|
+
"type": "input",
|
35
|
+
"name": "out_file1"
|
36
|
+
}
|
37
|
+
],
|
38
|
+
"workflow_outputs": [
|
39
|
+
{
|
40
|
+
"output_name": "out_file1",
|
41
|
+
"uuid": "8237f71a-bc2a-494e-a63c-09c1e65ef7c8",
|
42
|
+
"label": "sorted_bed"
|
43
|
+
}
|
44
|
+
],
|
45
|
+
"input_connections": {
|
46
|
+
"input": {
|
47
|
+
"output_name": "output",
|
48
|
+
"id": 0
|
49
|
+
}
|
50
|
+
},
|
51
|
+
"tool_state": "{\"__page__\": null, \"style\": \"\\\"alpha\\\"\", \"column\": \"\\\"1\\\"\", \"__rerun_remap_job_id__\": null, \"column_set\": \"[]\", \"input\": \"{\\\"__class__\\\": \\\"RuntimeValue\\\"}\", \"header_lines\": \"\\\"0\\\"\", \"order\": \"\\\"ASC\\\"\"}",
|
52
|
+
"id": 1,
|
53
|
+
"uuid": "0b6b3cda-c75f-452b-85b1-8ae4f3302ba4",
|
54
|
+
"errors": null,
|
55
|
+
"name": "Sort",
|
56
|
+
"post_job_actions": {},
|
57
|
+
"label": "sort",
|
58
|
+
"inputs": [
|
59
|
+
{
|
60
|
+
"name": "input",
|
61
|
+
"description": "runtime parameter for tool Sort"
|
62
|
+
}
|
63
|
+
],
|
64
|
+
"position": {
|
65
|
+
"top": 200,
|
66
|
+
"left": 420
|
67
|
+
},
|
68
|
+
"annotation": "",
|
69
|
+
"content_id": "sort1",
|
70
|
+
"type": "tool"
|
71
|
+
},
|
72
|
+
"2": {
|
73
|
+
"tool_id": "ChangeCase",
|
74
|
+
"tool_version": "1.0.0",
|
75
|
+
"outputs": [
|
76
|
+
{
|
77
|
+
"type": "tabular",
|
78
|
+
"name": "out_file1"
|
79
|
+
}
|
80
|
+
],
|
81
|
+
"workflow_outputs": [
|
82
|
+
{
|
83
|
+
"output_name": "out_file1",
|
84
|
+
"uuid": "c31cd733-dab6-4d50-9fec-b644d162397b",
|
85
|
+
"label": "uppercase_bed"
|
86
|
+
}
|
87
|
+
],
|
88
|
+
"input_connections": {
|
89
|
+
"input": {
|
90
|
+
"output_name": "out_file1",
|
91
|
+
"id": 1
|
92
|
+
}
|
93
|
+
},
|
94
|
+
"tool_state": "{\"__page__\": null, \"casing\": \"\\\"up\\\"\", \"__rerun_remap_job_id__\": null, \"cols\": \"\\\"c1\\\"\", \"delimiter\": \"\\\"TAB\\\"\", \"input\": \"{\\\"__class__\\\": \\\"RuntimeValue\\\"}\"}",
|
95
|
+
"id": 2,
|
96
|
+
"uuid": "9698bcde-0729-48fe-b88d-ccfb6f6153b4",
|
97
|
+
"errors": null,
|
98
|
+
"name": "Change Case",
|
99
|
+
"post_job_actions": {},
|
100
|
+
"label": "change_case",
|
101
|
+
"inputs": [
|
102
|
+
{
|
103
|
+
"name": "input",
|
104
|
+
"description": "runtime parameter for tool Change Case"
|
105
|
+
}
|
106
|
+
],
|
107
|
+
"position": {
|
108
|
+
"top": 200,
|
109
|
+
"left": 640
|
110
|
+
},
|
111
|
+
"annotation": "",
|
112
|
+
"content_id": "ChangeCase",
|
113
|
+
"type": "tool"
|
114
|
+
}
|
115
|
+
},
|
116
|
+
"annotation": "",
|
117
|
+
"a_galaxy_workflow": "true"
|
118
|
+
}
|
@@ -1,66 +1,67 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
3
|
<head>
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
}</script>
|
37
|
-
|
38
|
-
|
4
|
+
<title>New RO-Crate</title>
|
5
|
+
<script type="application/ld+json">{
|
6
|
+
"@context": "https://w3id.org/ro/crate/1.0/context",
|
7
|
+
"@graph": [
|
8
|
+
{
|
9
|
+
"@id": "ro-crate-metadata.jsonld",
|
10
|
+
"@type": "CreativeWork",
|
11
|
+
"about": {
|
12
|
+
"@id": "./"
|
13
|
+
}
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"@id": "ro-crate-preview.html",
|
17
|
+
"@type": "CreativeWork",
|
18
|
+
"about": {
|
19
|
+
"@id": "./"
|
20
|
+
}
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"@id": "./",
|
24
|
+
"@type": "Dataset",
|
25
|
+
"hasPart": [
|
26
|
+
{
|
27
|
+
"@id": "listed_file.txt"
|
28
|
+
}
|
29
|
+
]
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"@id": "listed_file.txt",
|
33
|
+
"@type": "File"
|
34
|
+
}
|
35
|
+
]
|
36
|
+
}</script>
|
37
|
+
<meta name="generator" content="https://github.com/fbacall/ro-crate-ruby">
|
38
|
+
<meta name="keywords" content="RO-Crate">
|
39
39
|
</head>
|
40
40
|
<body>
|
41
|
-
|
42
|
-
|
43
|
-
<p>
|
44
|
-
|
45
|
-
</p>
|
46
|
-
<dl>
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
</dl>
|
41
|
+
<h1>New RO-Crate</h1>
|
42
|
+
Some stuff has been added here blablabla
|
52
43
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
44
|
+
<p>
|
45
|
+
|
46
|
+
</p>
|
47
|
+
<dl>
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
</dl>
|
53
|
+
|
54
|
+
<h2>Contents</h2>
|
55
|
+
<ul>
|
56
|
+
|
57
|
+
<li id="__data_entity_listed_file.txt">
|
58
|
+
|
59
|
+
<strong>listed_file.txt</strong>
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
</li>
|
64
|
+
|
65
|
+
</ul>
|
65
66
|
</body>
|
66
|
-
</html>
|
67
|
+
</html>
|
data/test/reader_test.rb
CHANGED
@@ -88,12 +88,12 @@ class ReaderTest < Test::Unit::TestCase
|
|
88
88
|
test 'reading from zip with directories' do
|
89
89
|
crate = ROCrate::Reader.read_zip(fixture_file('directory.zip'))
|
90
90
|
|
91
|
-
assert crate.
|
92
|
-
assert_equal '1234', crate.
|
93
|
-
assert crate.
|
94
|
-
assert crate.
|
95
|
-
assert crate.
|
96
|
-
assert crate.
|
91
|
+
assert crate.payload['fish/info.txt']
|
92
|
+
assert_equal '1234', crate.payload['fish/info.txt'].source.read.chomp
|
93
|
+
assert crate.payload['fish/root.txt']
|
94
|
+
assert crate.payload['fish/data/info.txt']
|
95
|
+
assert crate.payload['fish/data/nested.txt']
|
96
|
+
assert crate.payload['fish/data/binary.jpg']
|
97
97
|
assert_equal ['./', 'fish/', 'ro-crate-metadata.jsonld', 'ro-crate-preview.html'], crate.entities.map(&:id).sort
|
98
98
|
end
|
99
99
|
|
@@ -101,22 +101,22 @@ class ReaderTest < Test::Unit::TestCase
|
|
101
101
|
Dir.mktmpdir('test-1234-banana') do |dir|
|
102
102
|
crate = ROCrate::Reader.read_zip(fixture_file('directory.zip'), target_dir: dir)
|
103
103
|
|
104
|
-
assert crate.
|
105
|
-
assert crate.
|
104
|
+
assert crate.payload['fish/info.txt']
|
105
|
+
assert crate.payload['fish/info.txt'].source.to_s.include?('/test-1234-banana')
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
109
|
test 'reading from directory with directories' do
|
110
110
|
crate = ROCrate::Reader.read_directory(fixture_file('directory_crate').path)
|
111
111
|
|
112
|
-
assert crate.
|
113
|
-
assert crate.
|
114
|
-
assert_equal '1234', crate.
|
115
|
-
refute crate.
|
116
|
-
assert crate.
|
117
|
-
assert crate.
|
118
|
-
refute crate.
|
119
|
-
assert crate.
|
112
|
+
assert crate.payload.values.all? { |e| e.is_a?(ROCrate::Entry) }
|
113
|
+
assert crate.payload['fish/info.txt']
|
114
|
+
assert_equal '1234', crate.payload['fish/info.txt'].source.read.chomp
|
115
|
+
refute crate.payload['fish/root.txt'].directory?
|
116
|
+
assert crate.payload['fish/data'].directory?
|
117
|
+
assert crate.payload['fish/data/info.txt']
|
118
|
+
refute crate.payload['fish/data/nested.txt'].remote?
|
119
|
+
assert crate.payload['fish/data/binary.jpg']
|
120
120
|
assert_equal ['./', 'fish/', 'ro-crate-metadata.jsonld', 'ro-crate-preview.html'], crate.entities.map(&:id).sort
|
121
121
|
end
|
122
122
|
|
@@ -162,37 +162,38 @@ class ReaderTest < Test::Unit::TestCase
|
|
162
162
|
assert ext_file.source.is_a?(ROCrate::RemoteEntry)
|
163
163
|
assert_equal 'http://example.com/external_ref.txt', ext_file.id
|
164
164
|
assert_equal 'file contents', ext_file.source.read
|
165
|
+
assert crate.preview.source.source.is_a?(ROCrate::PreviewGenerator)
|
165
166
|
end
|
166
167
|
|
167
168
|
test 'reading from directory with unlisted files' do
|
168
169
|
crate = ROCrate::Reader.read_directory(fixture_file('sparse_directory_crate').path)
|
169
170
|
|
170
|
-
assert_equal 11, crate.
|
171
|
-
assert crate.
|
172
|
-
assert crate.
|
173
|
-
assert crate.
|
174
|
-
assert_equal '1234', crate.
|
175
|
-
refute crate.
|
176
|
-
assert crate.
|
177
|
-
assert crate.
|
178
|
-
refute crate.
|
179
|
-
assert crate.
|
171
|
+
assert_equal 11, crate.payload.count
|
172
|
+
assert crate.payload['listed_file.txt']
|
173
|
+
assert crate.payload['unlisted_file.txt']
|
174
|
+
assert crate.payload['fish']
|
175
|
+
assert_equal '1234', crate.payload['fish/info.txt'].source.read.chomp
|
176
|
+
refute crate.payload['fish/root.txt'].directory?
|
177
|
+
assert crate.payload['fish/data'].directory?
|
178
|
+
assert crate.payload['fish/data/info.txt']
|
179
|
+
refute crate.payload['fish/data/nested.txt'].remote?
|
180
|
+
assert crate.payload['fish/data/binary.jpg']
|
180
181
|
assert_equal ['./', 'listed_file.txt', 'ro-crate-metadata.jsonld', 'ro-crate-preview.html'], crate.entities.map(&:id).sort
|
181
182
|
end
|
182
183
|
|
183
184
|
test 'reading from a zip with unlisted files' do
|
184
185
|
crate = ROCrate::Reader.read_zip(fixture_file('sparse_directory_crate.zip').path)
|
185
186
|
|
186
|
-
assert_equal 11, crate.
|
187
|
-
assert crate.
|
188
|
-
assert crate.
|
189
|
-
assert crate.
|
190
|
-
assert_equal '1234', crate.
|
191
|
-
refute crate.
|
192
|
-
assert crate.
|
193
|
-
assert crate.
|
194
|
-
refute crate.
|
195
|
-
assert crate.
|
187
|
+
assert_equal 11, crate.payload.count
|
188
|
+
assert crate.payload['listed_file.txt']
|
189
|
+
assert crate.payload['unlisted_file.txt']
|
190
|
+
assert crate.payload['fish']
|
191
|
+
assert_equal '1234', crate.payload['fish/info.txt'].source.read.chomp
|
192
|
+
refute crate.payload['fish/root.txt'].directory?
|
193
|
+
assert crate.payload['fish/data'].directory?
|
194
|
+
assert crate.payload['fish/data/info.txt']
|
195
|
+
refute crate.payload['fish/data/nested.txt'].remote?
|
196
|
+
assert crate.payload['fish/data/binary.jpg']
|
196
197
|
assert_equal ['./', 'listed_file.txt', 'ro-crate-metadata.jsonld', 'ro-crate-preview.html'], crate.entities.map(&:id).sort
|
197
198
|
end
|
198
199
|
|
@@ -201,18 +202,60 @@ class ReaderTest < Test::Unit::TestCase
|
|
201
202
|
string_io.write(::File.read(fixture_file('sparse_directory_crate.zip').path))
|
202
203
|
string_io.rewind
|
203
204
|
assert string_io.is_a?(StringIO)
|
204
|
-
assert_equal 11, ROCrate::Reader.read_zip(string_io).
|
205
|
+
assert_equal 11, ROCrate::Reader.read_zip(string_io).payload.count
|
205
206
|
|
206
207
|
path = Pathname.new(fixture_file('sparse_directory_crate.zip').path)
|
207
208
|
assert path.is_a?(Pathname)
|
208
|
-
assert_equal 11, ROCrate::Reader.read_zip(path).
|
209
|
+
assert_equal 11, ROCrate::Reader.read_zip(path).payload.count
|
209
210
|
|
210
211
|
file = ::File.open(fixture_file('sparse_directory_crate.zip').path)
|
211
212
|
assert file.is_a?(::File)
|
212
|
-
assert_equal 11, ROCrate::Reader.read_zip(file).
|
213
|
+
assert_equal 11, ROCrate::Reader.read_zip(file).payload.count
|
213
214
|
|
214
215
|
string = fixture_file('sparse_directory_crate.zip').path
|
215
216
|
assert string.is_a?(String)
|
216
|
-
assert_equal 11, ROCrate::Reader.read_zip(string).
|
217
|
+
assert_equal 11, ROCrate::Reader.read_zip(string).payload.count
|
218
|
+
end
|
219
|
+
|
220
|
+
test 'reading from zip where the crate root is nested somewhere within' do
|
221
|
+
crate = ROCrate::Reader.read_zip(fixture_file('nested_directory.zip'))
|
222
|
+
|
223
|
+
assert crate.payload['fish/info.txt']
|
224
|
+
assert_equal '1234', crate.payload['fish/info.txt'].source.read.chomp
|
225
|
+
assert crate.payload['fish/root.txt']
|
226
|
+
assert crate.payload['fish/data/info.txt']
|
227
|
+
assert crate.payload['fish/data/nested.txt']
|
228
|
+
assert crate.payload['fish/data/binary.jpg']
|
229
|
+
assert_equal ['./', 'fish/', 'ro-crate-metadata.json', 'ro-crate-preview.html'], crate.entities.map(&:id).sort
|
230
|
+
end
|
231
|
+
|
232
|
+
test 'reading preserves any additions to @context' do
|
233
|
+
crate = ROCrate::Reader.read_directory(fixture_file('ro-crate-galaxy-sortchangecase').path)
|
234
|
+
|
235
|
+
context = crate.metadata.context
|
236
|
+
assert_equal [
|
237
|
+
'https://w3id.org/ro/crate/1.1/context',
|
238
|
+
{
|
239
|
+
'TestSuite' => 'https://w3id.org/ro/terms/test#TestSuite',
|
240
|
+
'TestInstance' => 'https://w3id.org/ro/terms/test#TestInstance',
|
241
|
+
'TestService' => 'https://w3id.org/ro/terms/test#TestService',
|
242
|
+
'TestDefinition' => 'https://w3id.org/ro/terms/test#TestDefinition',
|
243
|
+
'PlanemoEngine' => 'https://w3id.org/ro/terms/test#PlanemoEngine',
|
244
|
+
'JenkinsService' => 'https://w3id.org/ro/terms/test#JenkinsService',
|
245
|
+
'TravisService' => 'https://w3id.org/ro/terms/test#TravisService',
|
246
|
+
'GithubService' => 'https://w3id.org/ro/terms/test#GithubService',
|
247
|
+
'instance' => 'https://w3id.org/ro/terms/test#instance',
|
248
|
+
'runsOn' => 'https://w3id.org/ro/terms/test#runsOn',
|
249
|
+
'resource' => 'https://w3id.org/ro/terms/test#resource',
|
250
|
+
'definition' => 'https://w3id.org/ro/terms/test#definition',
|
251
|
+
'engineVersion' => 'https://w3id.org/ro/terms/test#engineVersion'
|
252
|
+
}
|
253
|
+
], context
|
254
|
+
end
|
255
|
+
|
256
|
+
test 'existing preview is used even if not mentioned in metadata' do
|
257
|
+
crate = ROCrate::Reader.read_zip(fixture_file('biobb_hpc_workflows-condapack.zip').path)
|
258
|
+
assert crate.preview.source.source.is_a?(Pathname)
|
259
|
+
assert_equal 80526, crate.preview.source.read.length
|
217
260
|
end
|
218
261
|
end
|
data/test/test_helper.rb
CHANGED
@@ -6,5 +6,9 @@ require 'ro_crate'
|
|
6
6
|
require 'webmock/test_unit'
|
7
7
|
|
8
8
|
def fixture_file(name, *args)
|
9
|
-
::File.open(::File.join(
|
9
|
+
::File.open(::File.join(fixture_dir, name), *args)
|
10
|
+
end
|
11
|
+
|
12
|
+
def fixture_dir
|
13
|
+
::File.join(::File.dirname(__FILE__), 'fixtures')
|
10
14
|
end
|