swissparser 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  *~
2
2
  *#
3
+ *.rbc
3
4
 
4
5
  *.gemspec
5
6
  announcement.txt
@@ -1,3 +1,13 @@
1
+ == 1.0.1 / 2011-01-23
2
+
3
+ * 1 bug fix:
4
+ - Handles line with a key but no content
5
+
6
+ * 1 new minor feature
7
+ - The parser hash option can be passed to the parse method block:
8
+
9
+ Parser = Rules.make_parser do |entries, options|
10
+
1
11
  == 1.0.0 / 2010-01-11
2
12
 
3
13
  * New release, the syntax for defining rules and parsers was simplified.
@@ -42,7 +42,7 @@ Thanks to rvm it was successfuly tested with
42
42
  versions:
43
43
 
44
44
  * ruby-1.8.7-p302
45
- * ruby-1.9.2-p0
45
+ * ruby-1.9.2-p136
46
46
  * jruby-1.5.2
47
47
 
48
48
 
data/Rakefile CHANGED
@@ -1,3 +1,7 @@
1
+ require 'rake/testtask'
2
+ require 'rake/rdoctask'
3
+ require 'cucumber/rake/task'
4
+
1
5
  begin
2
6
  require 'bones'
3
7
  rescue LoadError
@@ -7,8 +11,6 @@ end
7
11
  ensure_in_path 'lib'
8
12
  require 'swissparser'
9
13
 
10
- require 'cucumber/rake/task'
11
-
12
14
  task :default => :features
13
15
 
14
16
  Cucumber::Rake::Task.new(:features) do |t|
@@ -18,7 +20,9 @@ end
18
20
 
19
21
  CLOBBER << "coverage/"
20
22
 
21
- Bones {
23
+
24
+ Bones do
25
+ require 'rake/rdoctask'
22
26
  name 'swissparser'
23
27
  authors 'paradigmatic'
24
28
  email 'paradigmatic@streum.org'
@@ -29,6 +33,6 @@ Bones {
29
33
  history_file 'CHANGELOG.rdoc'
30
34
  ignore_file '.gitignore'
31
35
  rdoc.exclude ["examples/","features/"]
32
- }
36
+ end
33
37
 
34
38
  # EOF
@@ -78,8 +78,6 @@ if $0 == __FILE__
78
78
 
79
79
  proteins = Uniprot::Parser.parse_file( filename )
80
80
 
81
- proteins.each do |e|
82
- puts e.to_yaml
83
- end
84
-
81
+ puts proteins.size
82
+
85
83
  end
@@ -7,17 +7,17 @@ Background:
7
7
  AA x1
8
8
  BB y1
9
9
  CC z1
10
- abcd
10
+ abcd
11
11
  //
12
12
  AA x2
13
13
  BB y2
14
14
  CC z2
15
- efgh
15
+ efgh
16
16
  //
17
17
  AA x3
18
18
  BB y3
19
19
  CC z3
20
- ijkl
20
+ ijkl
21
21
  //
22
22
  """
23
23
 
@@ -76,4 +76,19 @@ Scenario: I can redefine rules
76
76
  And I run the parser on sample data
77
77
  Then the result evals to "%w{foo foo foo}"
78
78
 
79
+ Scenario: I can parse a lone key
80
+ Given sample data:
81
+ """
82
+ AA Foo
83
+ BB
84
+ CC Bar
85
+ //
86
+ """
87
+ And the default rules
88
+ And I define a rule which adds the key to an array with "AA"
89
+ And I define a rule which adds the key to an array with "BB"
90
+ And I define a rule which adds the key to an array with "CC"
91
+ And I define a simple parser which returns an array
92
+ And I run the parser on sample data
93
+ Then the result evals to "[%W{AA BB CC}]"
79
94
 
@@ -65,6 +65,17 @@ Given /^I define a simple parser which returns an array$/ do
65
65
  end
66
66
  end
67
67
 
68
+ Given /^I define a rule which adds the key to an array with "([^\"]*)"$/ do |key|
69
+ @rules = @rules.refine do
70
+ with( key ) do |content|
71
+ @text = [] if @text.nil?
72
+ @text << key
73
+ end
74
+ end
75
+
76
+ end
77
+
78
+
68
79
  Given /^I run the parser on sample data$/ do
69
80
  @result = if @opt.nil?
70
81
  @parser.parse( @data )
@@ -23,7 +23,7 @@ require 'swissparser/rules'
23
23
 
24
24
  module Swiss
25
25
 
26
- VERSION = "1.0.0"
26
+ VERSION = "1.0.1"
27
27
 
28
28
  # Parser for a typical bioinformatic flat file, like
29
29
  # SwissProt/Uniprot, KEGG, etc.
@@ -45,7 +45,11 @@ module Swiss
45
45
  # result.
46
46
  def parse( input, opt={} )
47
47
  entries = Entries.new( @rules, input, opt )
48
- @body.call( entries )
48
+ if @body.arity == 2
49
+ @body.call( entries, opt )
50
+ else
51
+ @body.call( entries )
52
+ end
49
53
  end
50
54
 
51
55
  # Parses a file specified by +filename+. An optional hash of
@@ -56,6 +56,12 @@ module Swiss
56
56
  if @rules.rules[key]
57
57
  entry.instance_exec( content, &@rules.rules[key] )
58
58
  end
59
+ elsif line =~ /^(\S+)\s*$/
60
+ key = $1
61
+ last_key = key
62
+ if @rules.rules[key]
63
+ entry.instance_exec( "", &@rules.rules[key] )
64
+ end
59
65
  else
60
66
  if @rules.rules[:text][last_key]
61
67
  entry.instance_exec(
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 0
9
- version: 1.0.0
8
+ - 1
9
+ version: 1.0.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - paradigmatic
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-18 00:00:00 +01:00
17
+ date: 2011-01-23 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -62,16 +62,12 @@ extensions: []
62
62
  extra_rdoc_files:
63
63
  - CHANGELOG.rdoc
64
64
  - README.rdoc
65
- - lib/swissparser.rbc
66
- - lib/swissparser/entries.rbc
67
- - lib/swissparser/rules.rbc
68
65
  files:
69
66
  - .gitignore
70
67
  - CHANGELOG.rdoc
71
68
  - LICENSE
72
69
  - README.rdoc
73
70
  - Rakefile
74
- - Rakefile.compiled.rbc
75
71
  - examples/data/EColPositives_noTAT.bas
76
72
  - examples/data/kegg_enzyme_short.txt
77
73
  - examples/data/uniprot.txt
@@ -82,11 +78,8 @@ files:
82
78
  - features/step_definitions/basic_steps.rb
83
79
  - features/step_definitions/sugar_steps.rb
84
80
  - lib/swissparser.rb
85
- - lib/swissparser.rbc
86
81
  - lib/swissparser/entries.rb
87
- - lib/swissparser/entries.rbc
88
82
  - lib/swissparser/rules.rb
89
- - lib/swissparser/rules.rbc
90
83
  has_rdoc: true
91
84
  homepage: http://github.com/paradigmatic/SwissParser
92
85
  licenses: []
@@ -1,622 +0,0 @@
1
- !RBIX
2
- 0
3
- x
4
- M
5
- 1
6
- n
7
- n
8
- x
9
- 10
10
- __script__
11
- i
12
- 140
13
- 26
14
- 93
15
- 0
16
- 15
17
- 29
18
- 18
19
- 0
20
- 5
21
- 7
22
- 0
23
- 64
24
- 47
25
- 49
26
- 1
27
- 1
28
- 30
29
- 8
30
- 52
31
- 26
32
- 93
33
- 1
34
- 15
35
- 24
36
- 13
37
- 45
38
- 2
39
- 3
40
- 12
41
- 49
42
- 4
43
- 1
44
- 10
45
- 35
46
- 8
47
- 47
48
- 15
49
- 5
50
- 7
51
- 5
52
- 64
53
- 47
54
- 49
55
- 6
56
- 1
57
- 25
58
- 8
59
- 52
60
- 15
61
- 92
62
- 1
63
- 27
64
- 34
65
- 92
66
- 0
67
- 27
68
- 15
69
- 5
70
- 7
71
- 7
72
- 64
73
- 47
74
- 49
75
- 8
76
- 1
77
- 15
78
- 5
79
- 7
80
- 9
81
- 64
82
- 47
83
- 49
84
- 1
85
- 1
86
- 15
87
- 5
88
- 7
89
- 10
90
- 64
91
- 47
92
- 49
93
- 1
94
- 1
95
- 15
96
- 5
97
- 44
98
- 43
99
- 11
100
- 79
101
- 49
102
- 12
103
- 1
104
- 13
105
- 7
106
- 13
107
- 7
108
- 14
109
- 49
110
- 15
111
- 2
112
- 15
113
- 47
114
- 49
115
- 16
116
- 1
117
- 15
118
- 45
119
- 17
120
- 18
121
- 43
122
- 19
123
- 43
124
- 20
125
- 7
126
- 14
127
- 56
128
- 21
129
- 50
130
- 22
131
- 1
132
- 15
133
- 45
134
- 23
135
- 24
136
- 7
137
- 25
138
- 64
139
- 49
140
- 26
141
- 1
142
- 15
143
- 5
144
- 56
145
- 27
146
- 47
147
- 50
148
- 28
149
- 0
150
- 15
151
- 2
152
- 11
153
- I
154
- 7
155
- I
156
- 0
157
- I
158
- 0
159
- I
160
- 0
161
- n
162
- p
163
- 29
164
- s
165
- 5
166
- bones
167
- x
168
- 7
169
- require
170
- x
171
- 9
172
- LoadError
173
- n
174
- x
175
- 3
176
- ===
177
- s
178
- 38
179
- ### Please install the "bones" gem ###
180
- x
181
- 5
182
- abort
183
- s
184
- 3
185
- lib
186
- x
187
- 14
188
- ensure_in_path
189
- s
190
- 11
191
- swissparser
192
- s
193
- 18
194
- cucumber/rake/task
195
- x
196
- 4
197
- Hash
198
- x
199
- 16
200
- new_from_literal
201
- x
202
- 7
203
- default
204
- x
205
- 8
206
- features
207
- x
208
- 3
209
- []=
210
- x
211
- 4
212
- task
213
- x
214
- 8
215
- Cucumber
216
- n
217
- x
218
- 4
219
- Rake
220
- x
221
- 4
222
- Task
223
- M
224
- 1
225
- p
226
- 2
227
- x
228
- 9
229
- for_block
230
- t
231
- n
232
- x
233
- 9
234
- __block__
235
- i
236
- 17
237
- 57
238
- 19
239
- 0
240
- 15
241
- 20
242
- 0
243
- 7
244
- 0
245
- 64
246
- 13
247
- 18
248
- 2
249
- 49
250
- 1
251
- 1
252
- 15
253
- 11
254
- I
255
- 5
256
- I
257
- 1
258
- I
259
- 1
260
- I
261
- 1
262
- n
263
- p
264
- 2
265
- s
266
- 29
267
- --format pretty --tags ~@skip
268
- x
269
- 14
270
- cucumber_opts=
271
- p
272
- 5
273
- I
274
- 0
275
- I
276
- e
277
- I
278
- 4
279
- I
280
- f
281
- I
282
- 11
283
- x
284
- 38
285
- /home/falcone/prg/SwissParser/Rakefile
286
- p
287
- 1
288
- x
289
- 1
290
- t
291
- x
292
- 3
293
- new
294
- x
295
- 7
296
- CLOBBER
297
- n
298
- s
299
- 9
300
- coverage/
301
- x
302
- 2
303
- <<
304
- M
305
- 1
306
- p
307
- 2
308
- x
309
- 9
310
- for_block
311
- t
312
- n
313
- x
314
- 9
315
- __block__
316
- i
317
- 112
318
- 5
319
- 7
320
- 0
321
- 64
322
- 47
323
- 49
324
- 1
325
- 1
326
- 15
327
- 5
328
- 7
329
- 2
330
- 64
331
- 47
332
- 49
333
- 3
334
- 1
335
- 15
336
- 5
337
- 7
338
- 4
339
- 64
340
- 47
341
- 49
342
- 5
343
- 1
344
- 15
345
- 5
346
- 7
347
- 6
348
- 64
349
- 47
350
- 49
351
- 7
352
- 1
353
- 15
354
- 5
355
- 45
356
- 8
357
- 9
358
- 43
359
- 10
360
- 47
361
- 49
362
- 11
363
- 1
364
- 15
365
- 5
366
- 47
367
- 48
368
- 12
369
- 7
370
- 13
371
- 64
372
- 7
373
- 14
374
- 64
375
- 35
376
- 2
377
- 35
378
- 1
379
- 13
380
- 18
381
- 2
382
- 49
383
- 15
384
- 1
385
- 15
386
- 15
387
- 5
388
- 7
389
- 16
390
- 64
391
- 47
392
- 49
393
- 17
394
- 1
395
- 15
396
- 5
397
- 7
398
- 18
399
- 64
400
- 47
401
- 49
402
- 19
403
- 1
404
- 15
405
- 5
406
- 7
407
- 20
408
- 64
409
- 47
410
- 49
411
- 21
412
- 1
413
- 15
414
- 5
415
- 47
416
- 48
417
- 22
418
- 7
419
- 23
420
- 64
421
- 7
422
- 24
423
- 64
424
- 35
425
- 2
426
- 49
427
- 25
428
- 1
429
- 11
430
- I
431
- 4
432
- I
433
- 0
434
- I
435
- 0
436
- I
437
- 0
438
- I
439
- -2
440
- p
441
- 26
442
- s
443
- 11
444
- swissparser
445
- x
446
- 4
447
- name
448
- s
449
- 12
450
- paradigmatic
451
- x
452
- 7
453
- authors
454
- s
455
- 23
456
- paradigmatic@streum.org
457
- x
458
- 5
459
- email
460
- s
461
- 42
462
- http://github.com/paradigmatic/SwissParser
463
- x
464
- 3
465
- url
466
- x
467
- 5
468
- Swiss
469
- n
470
- x
471
- 7
472
- VERSION
473
- x
474
- 7
475
- version
476
- x
477
- 3
478
- gem
479
- s
480
- 8
481
- cucumber
482
- s
483
- 6
484
- >= 0.4
485
- x
486
- 25
487
- development_dependencies=
488
- s
489
- 11
490
- README.rdoc
491
- x
492
- 11
493
- readme_file
494
- s
495
- 14
496
- CHANGELOG.rdoc
497
- x
498
- 12
499
- history_file
500
- s
501
- 10
502
- .gitignore
503
- x
504
- 11
505
- ignore_file
506
- x
507
- 4
508
- rdoc
509
- s
510
- 9
511
- examples/
512
- s
513
- 9
514
- features/
515
- x
516
- 7
517
- exclude
518
- p
519
- 23
520
- I
521
- 0
522
- I
523
- 15
524
- I
525
- 0
526
- I
527
- 16
528
- I
529
- 9
530
- I
531
- 17
532
- I
533
- 12
534
- I
535
- 18
536
- I
537
- 1b
538
- I
539
- 19
540
- I
541
- 24
542
- I
543
- 1a
544
- I
545
- 2f
546
- I
547
- 1b
548
- I
549
- 45
550
- I
551
- 1c
552
- I
553
- 4e
554
- I
555
- 1d
556
- I
557
- 57
558
- I
559
- 1e
560
- I
561
- 60
562
- I
563
- 1f
564
- I
565
- 70
566
- x
567
- 38
568
- /home/falcone/prg/SwissParser/Rakefile
569
- p
570
- 0
571
- x
572
- 5
573
- Bones
574
- p
575
- 21
576
- I
577
- 0
578
- I
579
- 2
580
- I
581
- 17
582
- I
583
- 3
584
- I
585
- 24
586
- I
587
- 4
588
- I
589
- 38
590
- I
591
- 7
592
- I
593
- 41
594
- I
595
- 8
596
- I
597
- 4a
598
- I
599
- a
600
- I
601
- 53
602
- I
603
- c
604
- I
605
- 69
606
- I
607
- e
608
- I
609
- 78
610
- I
611
- 13
612
- I
613
- 82
614
- I
615
- 15
616
- I
617
- 8c
618
- x
619
- 38
620
- /home/falcone/prg/SwissParser/Rakefile
621
- p
622
- 0