ro-crate 0.4.9 → 0.4.13
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 +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
data/test/writer_test.rb
CHANGED
@@ -47,8 +47,12 @@ class WriterTest < Test::Unit::TestCase
|
|
47
47
|
end
|
48
48
|
|
49
49
|
test 'writing to zip' do
|
50
|
+
# Remote entries should not be written, so this 500 error should not affect anything.
|
51
|
+
stub_request(:get, 'http://example.com/external_ref.txt').to_return(status: 500)
|
52
|
+
|
50
53
|
crate = ROCrate::Crate.new
|
51
54
|
crate.add_file(fixture_file('info.txt'))
|
55
|
+
crate.add_file('http://example.com/external_ref.txt')
|
52
56
|
crate.add_file(fixture_file('data.csv'), 'directory/data.csv')
|
53
57
|
|
54
58
|
Tempfile.create do |file|
|
@@ -57,6 +61,7 @@ class WriterTest < Test::Unit::TestCase
|
|
57
61
|
Zip::File.open(file) do |zipfile|
|
58
62
|
assert zipfile.file.exist?(ROCrate::Metadata::IDENTIFIER)
|
59
63
|
assert zipfile.file.exist?(ROCrate::Preview::IDENTIFIER)
|
64
|
+
refute zipfile.file.exist?('external_ref.txt')
|
60
65
|
assert_equal 6, zipfile.file.size('info.txt')
|
61
66
|
assert_equal 20, zipfile.file.size('directory/data.csv')
|
62
67
|
end
|
@@ -124,12 +129,64 @@ class WriterTest < Test::Unit::TestCase
|
|
124
129
|
actual_files = Dir.chdir(dir) { Dir.glob('**/*') }
|
125
130
|
assert_equal expected_files, actual_files
|
126
131
|
expected_files.each do |file|
|
127
|
-
next if file == 'ro-crate-metadata.jsonld' # Expected context gets updated.
|
128
|
-
next if file == 'ro-crate-preview.html' # RO-Crate preview format changed
|
129
132
|
abs_file_path = ::File.join(fixture, file)
|
130
133
|
next if ::File.directory?(abs_file_path)
|
131
134
|
assert_equal ::File.read(abs_file_path), ::File.read(::File.join(dir, file)), "#{file} didn't match"
|
132
135
|
end
|
133
136
|
end
|
134
137
|
end
|
138
|
+
|
139
|
+
test 'reading/writing multiple times does not change the crate' do
|
140
|
+
input_dir = fixture_file('sparse_directory_crate').path
|
141
|
+
Dir.mktmpdir do |dir|
|
142
|
+
3.times do |i|
|
143
|
+
output_dir = ::File.join(dir, "new_directory_#{i}")
|
144
|
+
crate = ROCrate::Reader.read(input_dir)
|
145
|
+
|
146
|
+
ROCrate::Writer.new(crate).write(output_dir)
|
147
|
+
expected_files = Dir.chdir(input_dir) { Dir.glob('**/*') }
|
148
|
+
actual_files = Dir.chdir(output_dir) { Dir.glob('**/*') }
|
149
|
+
assert_equal expected_files, actual_files
|
150
|
+
expected_files.each do |file|
|
151
|
+
abs_file_path = ::File.join(input_dir, file)
|
152
|
+
next if ::File.directory?(abs_file_path)
|
153
|
+
assert_equal ::File.read(abs_file_path), ::File.read(::File.join(output_dir, file)), "#{file} didn't match"
|
154
|
+
end
|
155
|
+
|
156
|
+
input_dir = output_dir
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
test 'writing with conflicting paths in payload obeys specificity rules' do
|
162
|
+
crate = ROCrate::Crate.new
|
163
|
+
|
164
|
+
# Payload from crate
|
165
|
+
crate.add_all(fixture_file('directory').path, false)
|
166
|
+
Dir.mktmpdir do |dir|
|
167
|
+
ROCrate::Writer.new(crate).write(dir)
|
168
|
+
|
169
|
+
assert_equal "5678\n", ::File.read(::File.join(dir, 'data', 'info.txt'))
|
170
|
+
end
|
171
|
+
|
172
|
+
# Payload from crate + directory
|
173
|
+
crate.add_directory(fixture_file('conflicting_data_directory').path.to_s, 'data')
|
174
|
+
Dir.mktmpdir do |dir|
|
175
|
+
ROCrate::Writer.new(crate).write(dir)
|
176
|
+
|
177
|
+
assert_equal 'abcd', ::File.read(::File.join(dir, 'data', 'info.txt')), 'Directory payload should take priority over Crate.'
|
178
|
+
assert_equal "No, I am nested!\n", ::File.read(::File.join(dir, 'data', 'nested.txt')), 'Directory payload should take priority over Crate.'
|
179
|
+
assert ::File.exist?(::File.join(dir, 'data', 'binary.jpg'))
|
180
|
+
end
|
181
|
+
|
182
|
+
# Payload from crate + directory + file
|
183
|
+
crate.add_file(StringIO.new('xyz'), 'data/info.txt')
|
184
|
+
Dir.mktmpdir do |dir|
|
185
|
+
ROCrate::Writer.new(crate).write(dir)
|
186
|
+
|
187
|
+
assert_equal 'xyz', ::File.read(::File.join(dir, 'data', 'info.txt')), 'File payload should take priority over Crate and Directory.'
|
188
|
+
assert_equal "No, I am nested!\n", ::File.read(::File.join(dir, 'data', 'nested.txt')), 'Directory payload should take priority over Crate.'
|
189
|
+
assert ::File.exist?(::File.join(dir, 'data', 'binary.jpg'))
|
190
|
+
end
|
191
|
+
end
|
135
192
|
end
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ro-crate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Finn Bacall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.7'
|
20
|
+
- - "<"
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
22
|
+
version: '2.9'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.7'
|
30
|
+
- - "<"
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
32
|
+
version: '2.9'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: rubyzip
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +78,14 @@ dependencies:
|
|
72
78
|
requirements:
|
73
79
|
- - "~>"
|
74
80
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
81
|
+
version: 0.21.2
|
76
82
|
type: :development
|
77
83
|
prerelease: false
|
78
84
|
version_requirements: !ruby/object:Gem::Requirement
|
79
85
|
requirements:
|
80
86
|
- - "~>"
|
81
87
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
88
|
+
version: 0.21.2
|
83
89
|
- !ruby/object:Gem::Dependency
|
84
90
|
name: yard
|
85
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -137,6 +143,7 @@ files:
|
|
137
143
|
- lib/ro_crate/model/organization.rb
|
138
144
|
- lib/ro_crate/model/person.rb
|
139
145
|
- lib/ro_crate/model/preview.rb
|
146
|
+
- lib/ro_crate/model/preview_generator.rb
|
140
147
|
- lib/ro_crate/model/remote_entry.rb
|
141
148
|
- lib/ro_crate/reader.rb
|
142
149
|
- lib/ro_crate/ro-crate-preview.html.erb
|
@@ -145,6 +152,9 @@ files:
|
|
145
152
|
- test/crate_test.rb
|
146
153
|
- test/directory_test.rb
|
147
154
|
- test/entity_test.rb
|
155
|
+
- test/fixtures/biobb_hpc_workflows-condapack.zip
|
156
|
+
- test/fixtures/conflicting_data_directory/info.txt
|
157
|
+
- test/fixtures/conflicting_data_directory/nested.txt
|
148
158
|
- test/fixtures/crate-spec1.1/file with spaces.txt
|
149
159
|
- test/fixtures/crate-spec1.1/ro-crate-metadata.json
|
150
160
|
- test/fixtures/data.csv
|
@@ -165,6 +175,14 @@ files:
|
|
165
175
|
- test/fixtures/directory_crate/ro-crate-preview.html
|
166
176
|
- test/fixtures/file with spaces.txt
|
167
177
|
- test/fixtures/info.txt
|
178
|
+
- test/fixtures/nested_directory.zip
|
179
|
+
- test/fixtures/ro-crate-galaxy-sortchangecase/LICENSE
|
180
|
+
- test/fixtures/ro-crate-galaxy-sortchangecase/README.md
|
181
|
+
- test/fixtures/ro-crate-galaxy-sortchangecase/ro-crate-metadata.json
|
182
|
+
- test/fixtures/ro-crate-galaxy-sortchangecase/sort-and-change-case.ga
|
183
|
+
- test/fixtures/ro-crate-galaxy-sortchangecase/test/test1/input.bed
|
184
|
+
- test/fixtures/ro-crate-galaxy-sortchangecase/test/test1/output_exp.bed
|
185
|
+
- test/fixtures/ro-crate-galaxy-sortchangecase/test/test1/sort-and-change-case-test.yml
|
168
186
|
- test/fixtures/spaces/file with spaces.txt
|
169
187
|
- test/fixtures/spaces/ro-crate-metadata.jsonld
|
170
188
|
- test/fixtures/sparse_directory_crate.zip
|