ro-crate 0.4.2 → 0.4.3
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 +1 -1
- data/lib/ro_crate/model/crate.rb +6 -0
- data/lib/ro_crate/model/directory.rb +7 -1
- data/ro_crate.gemspec +1 -1
- data/test/crate_test.rb +22 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00f8d84d1776b3f8c51e68477fe665c5c703fb56a584e72f748cf10b1a80de14
|
4
|
+
data.tar.gz: 6beefca605f5a5ab5da783510f3a8fe8cbcc795f595431a50eb2e6c47edf7999
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba029b48b018565b89d5df2d6d4dd8e22a96d5d1949922985ebf564f6133a1b71495a41540a7e265cd3bc5871dda41940d400dea077c439ab23389ebc7e1c44b
|
7
|
+
data.tar.gz: ba169bd9cf38fade168fada4a57ba3e29e0b70e1b181a753c09a2f39a21d13a17370376c6561b549041fc2e811c689f6db3a1fad616856f6b956c8528314004a
|
data/Gemfile.lock
CHANGED
data/lib/ro_crate/model/crate.rb
CHANGED
@@ -21,6 +21,7 @@ module ROCrate
|
|
21
21
|
|
22
22
|
if source_directory
|
23
23
|
source_directory = Pathname.new(::File.expand_path(source_directory))
|
24
|
+
@entry = source_directory
|
24
25
|
populate_entries(source_directory)
|
25
26
|
crate_path = source_directory.basename.to_s if crate_path.nil?
|
26
27
|
end
|
@@ -35,9 +36,10 @@ module ROCrate
|
|
35
36
|
# @return [Hash{String => Entry}>]
|
36
37
|
def entries
|
37
38
|
entries = {}
|
39
|
+
entries[filepath.chomp('/')] = @entry if @entry
|
38
40
|
|
39
41
|
@directory_entries.each do |rel_path, entry|
|
40
|
-
entries[
|
42
|
+
entries[full_entry_path(rel_path)] = entry
|
41
43
|
end
|
42
44
|
|
43
45
|
entries
|
@@ -63,6 +65,10 @@ module ROCrate
|
|
63
65
|
@directory_entries
|
64
66
|
end
|
65
67
|
|
68
|
+
def full_entry_path(relative_path)
|
69
|
+
::File.join(filepath, relative_path)
|
70
|
+
end
|
71
|
+
|
66
72
|
def default_properties
|
67
73
|
super.merge(
|
68
74
|
'@id' => "#{SecureRandom.uuid}/",
|
data/ro_crate.gemspec
CHANGED
data/test/crate_test.rb
CHANGED
@@ -203,6 +203,17 @@ class CrateTest < Test::Unit::TestCase
|
|
203
203
|
crate = ROCrate::Crate.new
|
204
204
|
entities = crate.add_all(fixture_file('directory').path)
|
205
205
|
|
206
|
+
paths = crate.entries.keys
|
207
|
+
assert_equal 8, paths.length
|
208
|
+
assert_includes paths, 'data'
|
209
|
+
assert_includes paths, 'root.txt'
|
210
|
+
assert_includes paths, 'info.txt'
|
211
|
+
assert_includes paths, 'data/binary.jpg'
|
212
|
+
assert_includes paths, 'data/info.txt'
|
213
|
+
assert_includes paths, 'data/nested.txt'
|
214
|
+
assert_includes paths, 'ro-crate-metadata.json'
|
215
|
+
assert_includes paths, 'ro-crate-preview.html'
|
216
|
+
|
206
217
|
assert_equal 6, entities.length
|
207
218
|
assert_equal 'ROCrate::Directory', crate.dereference('data/').class.name
|
208
219
|
assert_equal 'ROCrate::File', crate.dereference('root.txt').class.name
|
@@ -220,6 +231,17 @@ class CrateTest < Test::Unit::TestCase
|
|
220
231
|
|
221
232
|
assert_empty entities
|
222
233
|
|
234
|
+
paths = crate.entries.keys
|
235
|
+
assert_equal 8, paths.length
|
236
|
+
assert_includes paths, 'data'
|
237
|
+
assert_includes paths, 'root.txt'
|
238
|
+
assert_includes paths, 'info.txt'
|
239
|
+
assert_includes paths, 'data/binary.jpg'
|
240
|
+
assert_includes paths, 'data/info.txt'
|
241
|
+
assert_includes paths, 'data/nested.txt'
|
242
|
+
assert_includes paths, 'ro-crate-metadata.json'
|
243
|
+
assert_includes paths, 'ro-crate-preview.html'
|
244
|
+
|
223
245
|
# Should not create any data entities
|
224
246
|
assert_nil crate.dereference('data/')
|
225
247
|
assert_nil crate.dereference('root.txt')
|
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.
|
4
|
+
version: 0.4.3
|
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-02-
|
11
|
+
date: 2021-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|