arvados 0.1.20150407214339 → 0.1.20150413172135

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/arvados/collection.rb +44 -11
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ddce2313bdd7705ea2f920e375829dd4dbc8a4c1
4
- data.tar.gz: 1a64729b3c2fd824e91362c5035fc23aeb49f4ed
3
+ metadata.gz: 96584f94e463e7f2b86c1205f0097fe9aa8a840f
4
+ data.tar.gz: 432ae039f8a6b7eabeace88d57a60c0a85f078fa
5
5
  SHA512:
6
- metadata.gz: b37a1d8bb49b4eee935ba2945bb972a66aa463beb12b781114ce29a4576da0968234f44aefe9a0c3e1c81496bd30082301d0cc15eac7c689fa15206467a6bc4a
7
- data.tar.gz: 2d5c9b2ae9f2c169fe57cdf9652d4ec34d45d32bceffad9578a454395c16a0848c4cd3a049242f19d6bfa4ab84e10df371ca68dfc7016bcbd8c550e6ef344fa2
6
+ metadata.gz: 72bcb43b91f6f0b0e5929ed2baa23c526535ea79417beb89bc034e4141bd0dbae12d734cdd5cec0d05978dbb0738070df9fa556ce8658d1396ba3f223a320f27
7
+ data.tar.gz: 77256e96f0a6af3c3e613584a3fec6143588472cb9f9ff45d6726ec287f9fa05670d039c0a2a5ae393185af2336e2f6d0814c2a757305474861762bed1ccebce
@@ -14,8 +14,13 @@ module Arv
14
14
  loc_list = LocatorList.new(locators)
15
15
  file_specs.map { |s| manifest.split_file_token(s) }.
16
16
  each do |file_start, file_len, file_path|
17
- @root.file_at(normalize_path(stream_root, file_path)).
18
- add_segment(loc_list.segment(file_start, file_len))
17
+ begin
18
+ @root.file_at(normalize_path(stream_root, file_path)).
19
+ add_segment(loc_list.segment(file_start, file_len))
20
+ rescue Errno::ENOTDIR, Errno::EISDIR => error
21
+ raise ArgumentError.new("%p is both a stream and file" %
22
+ error.to_s.partition(" - ").last)
23
+ end
19
24
  end
20
25
  end
21
26
  end
@@ -43,6 +48,19 @@ module Arv
43
48
  copy(:merge, source.chomp("/"), target, source_collection, opts)
44
49
  end
45
50
 
51
+ def each_file_path(&block)
52
+ @root.each_file_path(&block)
53
+ end
54
+
55
+ def exist?(path)
56
+ begin
57
+ substream, item = find(path)
58
+ not (substream.leaf? or substream[item].nil?)
59
+ rescue Errno::ENOENT, Errno::ENOTDIR
60
+ false
61
+ end
62
+ end
63
+
46
64
  def rename(source, target)
47
65
  copy(:add_copy, source, target) { rm_r(source) }
48
66
  end
@@ -88,13 +106,19 @@ module Arv
88
106
  # is found and can be copied.
89
107
  source_collection = self if source_collection.nil?
90
108
  src_stream, src_tail = source_collection.find(source)
91
- dst_stream, dst_tail = find(target)
109
+ dst_stream_path, _, dst_tail = normalize_path(target).rpartition("/")
110
+ if dst_stream_path.empty?
111
+ dst_stream, dst_tail = @root.find(dst_tail)
112
+ dst_tail ||= src_tail
113
+ else
114
+ dst_stream = @root.stream_at(dst_stream_path)
115
+ dst_tail = src_tail if dst_tail.empty?
116
+ end
92
117
  if (source_collection.equal?(self) and
93
118
  (src_stream.path == dst_stream.path) and (src_tail == dst_tail))
94
119
  return self
95
120
  end
96
121
  src_item = src_stream[src_tail]
97
- dst_tail ||= src_tail
98
122
  check_method = "check_can_#{copy_method}".to_sym
99
123
  target_name = nil
100
124
  if opts.fetch(:descend_target, true)
@@ -272,6 +296,17 @@ module Arv
272
296
  end
273
297
  end
274
298
 
299
+ def each_file_path
300
+ return to_enum(__method__) unless block_given?
301
+ items.each_value do |item|
302
+ if item.file?
303
+ yield item.path
304
+ else
305
+ item.each_file_path { |path| yield path }
306
+ end
307
+ end
308
+ end
309
+
275
310
  def find(find_path)
276
311
  # Given a POSIX-style path, return the CollectionStream that
277
312
  # contains the object at that path, and the name of the object
@@ -283,7 +318,7 @@ module Arv
283
318
 
284
319
  def stream_at(find_path)
285
320
  key, rest = find_path.split("/", 2)
286
- next_stream = get_or_new(key, CollectionStream)
321
+ next_stream = get_or_new(key, CollectionStream, Errno::ENOTDIR)
287
322
  if rest.nil?
288
323
  next_stream
289
324
  else
@@ -294,7 +329,7 @@ module Arv
294
329
  def file_at(find_path)
295
330
  stream_path, _, file_name = find_path.rpartition("/")
296
331
  if stream_path.empty?
297
- get_or_new(file_name, CollectionFile)
332
+ get_or_new(file_name, CollectionFile, Errno::EISDIR)
298
333
  else
299
334
  stream_at(stream_path).file_at(file_name)
300
335
  end
@@ -377,17 +412,15 @@ module Arv
377
412
  items[key] = item
378
413
  end
379
414
 
380
- def get_or_new(key, klass)
415
+ def get_or_new(key, klass, err_class)
381
416
  # Return the collection item at `key` and ensure that it's a `klass`.
382
417
  # If `key` does not exist, create a new `klass` there.
383
- # If the value for `key` is not a `klass`, raise an ArgumentError.
418
+ # If the value for `key` is not a `klass`, raise an `err_class`.
384
419
  item = items[key]
385
420
  if item.nil?
386
421
  self[key] = klass.new("#{path}/#{key}")
387
422
  elsif not item.is_a?(klass)
388
- raise ArgumentError.
389
- new("in stream %p, %p is a %s, not a %s" %
390
- [path, key, items[key].class.human_name, klass.human_name])
423
+ raise err_class.new(item.path)
391
424
  else
392
425
  item
393
426
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arvados
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20150407214339
4
+ version: 0.1.20150413172135
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arvados Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-07 00:00:00.000000000 Z
11
+ date: 2015-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-api-client
@@ -104,7 +104,7 @@ dependencies:
104
104
  - - "<"
105
105
  - !ruby/object:Gem::Version
106
106
  version: 1.0.0
107
- description: Arvados client library, git commit 83759d40b868f7583cffcfa986bb78ff9c9f6c42
107
+ description: Arvados client library, git commit 43aa02f5af636f874bac5ffe96cff0061bcd6a44
108
108
  email: gem-dev@curoverse.com
109
109
  executables: []
110
110
  extensions: []