ro-crate 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 00f8d84d1776b3f8c51e68477fe665c5c703fb56a584e72f748cf10b1a80de14
4
- data.tar.gz: 6beefca605f5a5ab5da783510f3a8fe8cbcc795f595431a50eb2e6c47edf7999
3
+ metadata.gz: 8e3f58e7b54e7d04913b3ab7ed778fe0c2fbfa01c9571ec7d5c62d9fb7ec9555
4
+ data.tar.gz: 5b544b0a343c185571a2fccc1438bfd53426b7f6a02d4605b4d7a7f517058560
5
5
  SHA512:
6
- metadata.gz: ba029b48b018565b89d5df2d6d4dd8e22a96d5d1949922985ebf564f6133a1b71495a41540a7e265cd3bc5871dda41940d400dea077c439ab23389ebc7e1c44b
7
- data.tar.gz: ba169bd9cf38fade168fada4a57ba3e29e0b70e1b181a753c09a2f39a21d13a17370376c6561b549041fc2e811c689f6db3a1fad616856f6b956c8528314004a
6
+ metadata.gz: e12c059af0471d6423fc0af754713d66f0d654d3196d331fc2d3a8a7d9f6642e8e7fada4749ad7fa2b7478cc64be4652b09aba2d1851d2d7f44100d1d52a6b14
7
+ data.tar.gz: c0c2654d4261aad3f2e9db64b64338af9425e7aea73a92848a98561bf27ea3f0489a926857efc5e80990475b17b42a499657cad292e8b0e8d7593be647ab6d80
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ro-crate (0.4.3)
4
+ ro-crate (0.4.4)
5
5
  addressable (~> 2.7.0)
6
6
  rubyzip (~> 2.0.0)
7
7
 
@@ -73,7 +73,7 @@ module ROCrate
73
73
  def add_all(source_directory, create_entities = true)
74
74
  added = []
75
75
 
76
- Dir.chdir(source_directory) { Dir.glob('**/*') }.each do |rel_path|
76
+ list_all_files(source_directory).each do |rel_path|
77
77
  source_path = Pathname.new(::File.join(source_directory, rel_path)).expand_path
78
78
  if create_entities
79
79
  if source_path.directory?
@@ -57,7 +57,7 @@ module ROCrate
57
57
  def populate_entries(source_directory)
58
58
  raise 'Not a directory' unless ::File.directory?(source_directory)
59
59
  @directory_entries = {}
60
- Dir.chdir(source_directory) { Dir.glob('**/*') }.each do |rel_path|
60
+ list_all_files(source_directory).each do |rel_path|
61
61
  source_path = Pathname.new(::File.join(source_directory, rel_path)).expand_path
62
62
  @directory_entries[rel_path] = Entry.new(source_path)
63
63
  end
@@ -69,6 +69,12 @@ module ROCrate
69
69
  ::File.join(filepath, relative_path)
70
70
  end
71
71
 
72
+ def list_all_files(source_directory)
73
+ Dir.chdir(source_directory) { Dir.glob('**/*', ::File::FNM_DOTMATCH) }.reject do |path|
74
+ path == '.' || path == '..' || path.end_with?('/.')
75
+ end
76
+ end
77
+
72
78
  def default_properties
73
79
  super.merge(
74
80
  '@id' => "#{SecureRandom.uuid}/",
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.3'
3
+ s.version = '0.4.4'
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
@@ -204,25 +204,32 @@ class CrateTest < Test::Unit::TestCase
204
204
  entities = crate.add_all(fixture_file('directory').path)
205
205
 
206
206
  paths = crate.entries.keys
207
- assert_equal 8, paths.length
207
+ assert_equal 11, paths.length
208
208
  assert_includes paths, 'data'
209
209
  assert_includes paths, 'root.txt'
210
210
  assert_includes paths, 'info.txt'
211
211
  assert_includes paths, 'data/binary.jpg'
212
212
  assert_includes paths, 'data/info.txt'
213
213
  assert_includes paths, 'data/nested.txt'
214
+ assert_includes paths, '.dotfile'
215
+ assert_includes paths, '.dir'
216
+ assert_includes paths, '.dir/test.txt'
214
217
  assert_includes paths, 'ro-crate-metadata.json'
215
218
  assert_includes paths, 'ro-crate-preview.html'
216
219
 
217
- assert_equal 6, entities.length
220
+ assert_equal 9, entities.length
218
221
  assert_equal 'ROCrate::Directory', crate.dereference('data/').class.name
219
222
  assert_equal 'ROCrate::File', crate.dereference('root.txt').class.name
220
223
  assert_equal 'ROCrate::File', crate.dereference('info.txt').class.name
221
224
  assert_equal 'ROCrate::File', crate.dereference('data/binary.jpg').class.name
222
225
  assert_equal 'ROCrate::File', crate.dereference('data/info.txt').class.name
223
226
  assert_equal 'ROCrate::File', crate.dereference('data/nested.txt').class.name
227
+ assert_equal 'ROCrate::File', crate.dereference('.dotfile').class.name
228
+ assert_equal 'ROCrate::Directory', crate.dereference('.dir/').class.name
229
+ assert_equal 'ROCrate::File', crate.dereference('.dir/test.txt').class.name
224
230
 
225
231
  assert_equal "5678\n", crate.dereference('data/info.txt').source.read
232
+ assert_equal "Am I included?\n", crate.dereference('.dotfile').source.read
226
233
  end
227
234
 
228
235
  test 'can create an RO-Crate using content from a given directory' do
@@ -232,13 +239,16 @@ class CrateTest < Test::Unit::TestCase
232
239
  assert_empty entities
233
240
 
234
241
  paths = crate.entries.keys
235
- assert_equal 8, paths.length
242
+ assert_equal 11, paths.length
236
243
  assert_includes paths, 'data'
237
244
  assert_includes paths, 'root.txt'
238
245
  assert_includes paths, 'info.txt'
239
246
  assert_includes paths, 'data/binary.jpg'
240
247
  assert_includes paths, 'data/info.txt'
241
248
  assert_includes paths, 'data/nested.txt'
249
+ assert_includes paths, '.dotfile'
250
+ assert_includes paths, '.dir'
251
+ assert_includes paths, '.dir/test.txt'
242
252
  assert_includes paths, 'ro-crate-metadata.json'
243
253
  assert_includes paths, 'ro-crate-preview.html'
244
254
 
@@ -249,5 +259,6 @@ class CrateTest < Test::Unit::TestCase
249
259
  assert_nil crate.dereference('data/binary.jpg')
250
260
  assert_nil crate.dereference('data/info.txt')
251
261
  assert_nil crate.dereference('data/nested.txt')
262
+ assert_nil crate.dereference('.dotfile')
252
263
  end
253
264
  end
@@ -0,0 +1 @@
1
+ 123
@@ -0,0 +1 @@
1
+ Am I included?
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.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Finn Bacall
@@ -149,6 +149,8 @@ files:
149
149
  - test/fixtures/crate-spec1.1/ro-crate-metadata.json
150
150
  - test/fixtures/data.csv
151
151
  - test/fixtures/directory.zip
152
+ - test/fixtures/directory/.dir/test.txt
153
+ - test/fixtures/directory/.dotfile
152
154
  - test/fixtures/directory/data/binary.jpg
153
155
  - test/fixtures/directory/data/info.txt
154
156
  - test/fixtures/directory/data/nested.txt