arvados 0.1.20150609141135 → 0.1.20150614013129

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/keep.rb +57 -0
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b54fda44375a23270192e441289a7bbb8ed1514
4
- data.tar.gz: b177aec846d07c5780a90f6b8bb69a25314baac7
3
+ metadata.gz: 4e88a98ecf81a0992ac43e751b78eb89abf1e78f
4
+ data.tar.gz: 64d1b0e574cbcb44c6722d9f2ccde1a4f88b1d8a
5
5
  SHA512:
6
- metadata.gz: 0ed6d5fc6c1cdc4f0b7ad77a94052b6eddced3343454bbac40ffcc5b47ea4db4fcaa70605358c79d51bc1cdb0cef9bed3f10c4c60e90489f946f609bb7f3272b
7
- data.tar.gz: 54ef0f24ed623edb0a01cfe428c3c2f1888235102745420e634720b7478eeecaa70c72e03fa303ed0215e127417e66776808fbb124f9964dab98d824009759fc
6
+ metadata.gz: a546031d80c6c08133e7a2987fe5abdc61644c88dbc7515d8d6d50a47fabd4382a4cceedd69418f0a27707621614a3d985e38819d13b184a83c3b726f3496172
7
+ data.tar.gz: 0c7a3631101f1ec8f5b3607b0c076094a8eb2be9ff6bb4f2b7c391137feb8df92c32cb89a470ad23010a1a7275ae896df7e50dd431bd97fe2c739fecefb599fc
data/lib/arvados/keep.rb CHANGED
@@ -97,6 +97,9 @@ module Keep
97
97
  end
98
98
 
99
99
  class Manifest
100
+ STRICT_STREAM_TOKEN_REGEXP = /^(\.)(\/[^\/\s]+)*$/
101
+ STRICT_FILE_TOKEN_REGEXP = /^[[:digit:]]+:[[:digit:]]+:([^\s\/]+(\/[^\s\/]+)*)$/
102
+
100
103
  # Class to parse a manifest text and provide common views of that data.
101
104
  def initialize(manifest_text)
102
105
  @text = manifest_text
@@ -224,5 +227,59 @@ module Keep
224
227
  end
225
228
  false
226
229
  end
230
+
231
+ # Verify that a given manifest is valid according to
232
+ # https://arvados.org/projects/arvados/wiki/Keep_manifest_format
233
+ def self.validate! manifest
234
+ raise ArgumentError.new "Invalid manifest: does not end with newline" if !manifest.end_with?("\n")
235
+ line_count = 0
236
+ manifest.each_line do |line|
237
+ line_count += 1
238
+
239
+ words = line[0..-2].split(/ /)
240
+ raise ArgumentError.new "Manifest invalid for stream #{line_count}: missing stream name" if words.empty?
241
+
242
+ count = 0
243
+
244
+ word = words.shift
245
+ count += 1 if word =~ STRICT_STREAM_TOKEN_REGEXP and word !~ /\/\.\.?(\/|$)/
246
+ raise ArgumentError.new "Manifest invalid for stream #{line_count}: missing or invalid stream name #{word.inspect if word}" if count != 1
247
+
248
+ count = 0
249
+ word = words.shift
250
+ while word =~ Locator::LOCATOR_REGEXP
251
+ word = words.shift
252
+ count += 1
253
+ end
254
+ raise ArgumentError.new "Manifest invalid for stream #{line_count}: missing or invalid locator #{word.inspect if word}" if count == 0
255
+
256
+ count = 0
257
+ while word =~ STRICT_FILE_TOKEN_REGEXP and ($~[1].split('/') & ['..','.']).empty?
258
+ word = words.shift
259
+ count += 1
260
+ end
261
+
262
+ if word
263
+ raise ArgumentError.new "Manifest invalid for stream #{line_count}: invalid file token #{word.inspect}"
264
+ elsif count == 0
265
+ raise ArgumentError.new "Manifest invalid for stream #{line_count}: no file tokens"
266
+ end
267
+
268
+ # Ruby's split() method silently drops trailing empty tokens
269
+ # (which are not allowed by the manifest format) so we have to
270
+ # check trailing spaces manually.
271
+ raise ArgumentError.new "Manifest invalid for stream #{line_count}: trailing space" if line.end_with? " \n"
272
+ end
273
+ true
274
+ end
275
+
276
+ def self.valid? manifest
277
+ begin
278
+ validate! manifest
279
+ true
280
+ rescue ArgumentError
281
+ false
282
+ end
283
+ end
227
284
  end
228
285
  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.20150609141135
4
+ version: 0.1.20150614013129
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-06-09 00:00:00.000000000 Z
11
+ date: 2015-06-14 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 bed1ec60de09b319fccd37e7452280736a7c5a8a
107
+ description: Arvados client library, git commit 4617a33da4f02639db5a63d925abdf1eaa01145c
108
108
  email: gem-dev@curoverse.com
109
109
  executables: []
110
110
  extensions: []