ro-crate 0.4.16 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b489bc85ce753f46035d1f5843ac9539de35e1403b92a9139c19061901d6b2d6
4
- data.tar.gz: 6aab0b3d9f9323d7470554d82a887376fc00db95f68d0fae011416c66eb38937
3
+ metadata.gz: ad52a377a6affc48a0923460f3db8ebc5209f520f918a57097d74863114d7e42
4
+ data.tar.gz: bef654ae3d00ebd302c62fda5b53789c63ecda1295964667133eef47692731dd
5
5
  SHA512:
6
- metadata.gz: 55769c5b1a9b22ec5ad19e762ce9651e47407dbd01673c790c59753c6ac617cfa2ea81ecdcc6004313775069344845147c765e6396303491c94091e006c98b5b
7
- data.tar.gz: 1798256fa994b7851da4b0adf0d78514aeaadc2e48935820d3c1f5dc546a8a633d5da11db19adeec7bd8763093a133744551e37f702d943a376c1b082e12d388
6
+ metadata.gz: 907b74cff05114843bac2710a54fe141587f55b577785075bdaca49c88aa4051b26dc66785c80a1cb9c4cdcfa66030509b0bf02cc1ff82b452f18e37d755ad2a
7
+ data.tar.gz: f2843ab1c44d290cee58f92ff302bf1a1cfb9f4f0a5275c400ff4fcca3b45d5a0470deb613730309eae6a9dead572433ebfc7d874749ab3311585077968d8b46
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ro-crate (0.4.16)
4
+ ro-crate (0.4.17)
5
5
  addressable (>= 2.7, < 2.9)
6
6
  rubyzip (~> 2.0.0)
7
7
 
@@ -293,7 +293,7 @@ module ROCrate
293
293
  # Optionally takes a block to decide whether the given entity should be removed or not, otherwise removes all
294
294
  # unlinked entities.
295
295
  # @yieldparam [ContextualEntity] entity An unlinked contextual entity.
296
- # @yieldparam [Boolean] remove Should this entity be removed?
296
+ # @yieldreturn [Boolean] remove Should this entity be removed?
297
297
  #
298
298
  # @return [Array<ContextualEntity>] The entities that were removed.
299
299
  def gc(&block)
@@ -38,6 +38,12 @@ module ROCrate
38
38
  ::File.directory?(source) rescue false
39
39
  end
40
40
 
41
+ ##
42
+ # Does this Entry point to a symlink on the disk?
43
+ def symlink?
44
+ ::File.symlink?(source) rescue false
45
+ end
46
+
41
47
  ##
42
48
  # Does this Entry point to a remote resource?
43
49
  def remote?
@@ -21,11 +21,17 @@ module ROCrate
21
21
  end
22
22
 
23
23
  ##
24
- # Does this RemoteEntry point to a directory on the disk?
24
+ # Does this RemoteEntry point to a directory
25
25
  def directory?
26
26
  false
27
27
  end
28
28
 
29
+ ##
30
+ # Does this RemoteEntry point to a symlink
31
+ def symlink?
32
+ false
33
+ end
34
+
29
35
  ##
30
36
  # Does this RemoteEntry point to a remote resource?
31
37
  def remote?
@@ -21,13 +21,17 @@ module ROCrate
21
21
  next if !overwrite && ::File.exist?(fullpath)
22
22
  next if entry.directory?
23
23
  FileUtils.mkdir_p(::File.dirname(fullpath))
24
- temp = Tempfile.new('ro-crate-temp')
25
- begin
26
- entry.write_to(temp)
27
- temp.close
28
- FileUtils.mv(temp, fullpath)
29
- ensure
30
- temp.unlink
24
+ if entry.symlink?
25
+ ::File.symlink(entry.source.readlink, fullpath)
26
+ else
27
+ temp = Tempfile.new('ro-crate-temp')
28
+ begin
29
+ entry.write_to(temp)
30
+ temp.close
31
+ FileUtils.mv(temp, fullpath)
32
+ ensure
33
+ temp.unlink
34
+ end
31
35
  end
32
36
  end
33
37
  end
@@ -40,7 +44,11 @@ module ROCrate
40
44
  Zip::File.open(destination, Zip::File::CREATE) do |zip|
41
45
  @crate.payload.each do |path, entry|
42
46
  next if entry.directory?
43
- zip.get_output_stream(path) { |s| entry.write_to(s) }
47
+ if entry.symlink?
48
+ zip.add(path, entry.path) if entry.path
49
+ else
50
+ zip.get_output_stream(path) { |s| entry.write_to(s) }
51
+ end
44
52
  end
45
53
  end
46
54
  end
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.4.16'
3
+ s.version = '0.4.17'
4
4
  s.summary = 'Create, manipulate, read RO-Crates.'
5
5
  s.authors = ['Finn Bacall']
6
6
  s.email = 'finn.bacall@manchester.ac.uk'
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Finn Bacall
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ # workflow-test-fixture
2
+ A workflow and associated files for use in SEEK's tests :)
@@ -0,0 +1,151 @@
1
+ {
2
+ "a_galaxy_workflow": "true",
3
+ "annotation": "",
4
+ "creator": [
5
+ {
6
+ "class": "Person",
7
+ "identifier": "",
8
+ "name": "Finn Bacall"
9
+ }
10
+ ],
11
+ "format-version": "0.1",
12
+ "license": "MIT",
13
+ "name": "Concat two files",
14
+ "steps": {
15
+ "0": {
16
+ "annotation": "",
17
+ "content_id": null,
18
+ "errors": null,
19
+ "id": 0,
20
+ "input_connections": {},
21
+ "inputs": [
22
+ {
23
+ "description": "",
24
+ "name": "input1"
25
+ }
26
+ ],
27
+ "label": "input1",
28
+ "name": "Input dataset",
29
+ "outputs": [],
30
+ "position": {
31
+ "bottom": 254.1999969482422,
32
+ "height": 61.19999694824219,
33
+ "left": 393,
34
+ "right": 593,
35
+ "top": 193,
36
+ "width": 200,
37
+ "x": 393,
38
+ "y": 193
39
+ },
40
+ "tool_id": null,
41
+ "tool_state": "{\"optional\": false}",
42
+ "tool_version": null,
43
+ "type": "data_input",
44
+ "uuid": "7a90b91e-b143-4aa3-923d-fbcca5994d60",
45
+ "workflow_outputs": [
46
+ {
47
+ "label": null,
48
+ "output_name": "output",
49
+ "uuid": "1a510a60-afcc-4491-911b-3519da79f22d"
50
+ }
51
+ ]
52
+ },
53
+ "1": {
54
+ "annotation": "",
55
+ "content_id": null,
56
+ "errors": null,
57
+ "id": 1,
58
+ "input_connections": {},
59
+ "inputs": [
60
+ {
61
+ "description": "",
62
+ "name": "input2"
63
+ }
64
+ ],
65
+ "label": "input2",
66
+ "name": "Input dataset",
67
+ "outputs": [],
68
+ "position": {
69
+ "bottom": 374.1999969482422,
70
+ "height": 61.19999694824219,
71
+ "left": 393,
72
+ "right": 593,
73
+ "top": 313,
74
+ "width": 200,
75
+ "x": 393,
76
+ "y": 313
77
+ },
78
+ "tool_id": null,
79
+ "tool_state": "{\"optional\": false}",
80
+ "tool_version": null,
81
+ "type": "data_input",
82
+ "uuid": "baa13f22-7e0c-4533-b12c-7d31caf0c9b3",
83
+ "workflow_outputs": [
84
+ {
85
+ "label": null,
86
+ "output_name": "output",
87
+ "uuid": "1ded3ee7-d176-4385-8d1e-09b74af213fe"
88
+ }
89
+ ]
90
+ },
91
+ "2": {
92
+ "annotation": "",
93
+ "content_id": "toolshed.g2.bx.psu.edu/repos/bgruening/text_processing/tp_cat/0.1.0",
94
+ "errors": null,
95
+ "id": 2,
96
+ "input_connections": {
97
+ "inputs": {
98
+ "id": 0,
99
+ "output_name": "output"
100
+ },
101
+ "queries_0|inputs2": {
102
+ "id": 1,
103
+ "output_name": "output"
104
+ }
105
+ },
106
+ "inputs": [],
107
+ "label": null,
108
+ "name": "Concatenate datasets",
109
+ "outputs": [
110
+ {
111
+ "name": "out_file1",
112
+ "type": "input"
113
+ }
114
+ ],
115
+ "position": {
116
+ "bottom": 336.1999969482422,
117
+ "height": 143.1999969482422,
118
+ "left": 613,
119
+ "right": 813,
120
+ "top": 193,
121
+ "width": 200,
122
+ "x": 613,
123
+ "y": 193
124
+ },
125
+ "post_job_actions": {},
126
+ "tool_id": "toolshed.g2.bx.psu.edu/repos/bgruening/text_processing/tp_cat/0.1.0",
127
+ "tool_shed_repository": {
128
+ "changeset_revision": "ddf54b12c295",
129
+ "name": "text_processing",
130
+ "owner": "bgruening",
131
+ "tool_shed": "toolshed.g2.bx.psu.edu"
132
+ },
133
+ "tool_state": "{\"__input_ext\": \"txt\", \"chromInfo\": \"/opt/galaxy/tool-data/shared/ucsc/chrom/?.len\", \"inputs\": {\"__class__\": \"ConnectedValue\"}, \"queries\": [{\"__index__\": 0, \"inputs2\": {\"__class__\": \"ConnectedValue\"}}], \"__page__\": null, \"__rerun_remap_job_id__\": null}",
134
+ "tool_version": "0.1.0",
135
+ "type": "tool",
136
+ "uuid": "b2de7621-8ea3-4384-8f79-766ef38ebcfe",
137
+ "workflow_outputs": [
138
+ {
139
+ "label": null,
140
+ "output_name": "out_file1",
141
+ "uuid": "cba40c62-d9bd-49e0-b636-48cfab67c107"
142
+ }
143
+ ]
144
+ }
145
+ },
146
+ "tags": [
147
+ "cat"
148
+ ],
149
+ "uuid": "94a9a580-75d1-434f-b2af-02017de43e23",
150
+ "version": 1
151
+ }
data/test/writer_test.rb CHANGED
@@ -195,9 +195,36 @@ class WriterTest < Test::Unit::TestCase
195
195
  Dir.mktmpdir do |dir|
196
196
  ROCrate::Writer.new(crate).write(dir)
197
197
  Dir.chdir(dir) do
198
- file_list = Dir.glob('*').sort
199
- assert_equal ["ro-crate-metadata.json", "ro-crate-preview.html"], file_list
198
+ file_list = Dir.glob('*').sort
199
+ assert_equal ["ro-crate-metadata.json", "ro-crate-preview.html"], file_list
200
+ end
201
+ end
202
+ end
203
+
204
+ test 'write crate with data entity refers to a symlink as directory' do
205
+ crate = ROCrate::Crate.new
206
+ crate.add_all(fixture_file('workflow-test-fixture-symlink').path)
207
+ assert crate.payload['images/workflow-diagram.png'].source.symlink?
208
+
209
+ Dir.mktmpdir do |dir|
210
+ ROCrate::Writer.new(crate).write(dir)
211
+ Dir.chdir(dir) do
212
+ assert File.symlink?('images/workflow-diagram.png')
213
+ end
200
214
  end
215
+ end
216
+
217
+ test 'write crate with data entity refers to a symlink as zip' do
218
+ crate = ROCrate::Crate.new
219
+ crate.add_all(fixture_file('workflow-test-fixture-symlink').path)
220
+ assert crate.payload['images/workflow-diagram.png'].source.symlink?
221
+
222
+ Tempfile.create do |file|
223
+ ROCrate::Writer.new(crate).write_zip(file)
224
+
225
+ Zip::File.open(file) do |zipfile|
226
+ assert zipfile.find_entry('images/workflow-diagram.png').symlink?
227
+ end
201
228
  end
202
229
  end
203
230
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ro-crate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.16
4
+ version: 0.4.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Finn Bacall
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-09 00:00:00.000000000 Z
11
+ date: 2022-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -2428,6 +2428,11 @@ files:
2428
2428
  - test/fixtures/workflow-0.2.0/workflow/workflow.knime
2429
2429
  - test/fixtures/workflow-0.2.0/workflow/workflow.svg
2430
2430
  - test/fixtures/workflow-0.2.0/workflow/workflowset.meta
2431
+ - test/fixtures/workflow-test-fixture-symlink/LICENSE
2432
+ - test/fixtures/workflow-test-fixture-symlink/README.md
2433
+ - test/fixtures/workflow-test-fixture-symlink/concat_two_files.ga
2434
+ - test/fixtures/workflow-test-fixture-symlink/diagram.png
2435
+ - test/fixtures/workflow-test-fixture-symlink/images/workflow-diagram.png
2431
2436
  - test/reader_test.rb
2432
2437
  - test/test_helper.rb
2433
2438
  - test/writer_test.rb