swissparser 0.11.0 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +5 -0
- data/benchmarks/whole_uniprot.txt +7 -0
- data/features/parsing_context.feature +3 -3
- data/features/step_definitions/extra.rb +14 -5
- data/lib/swissparser.rb +3 -3
- data/lib/swissparser/parsing_context.rb +7 -7
- metadata +3 -2
- data/.gitignore +0 -9
data/CHANGELOG.rdoc
CHANGED
@@ -8,7 +8,7 @@ Feature: Sharing context
|
|
8
8
|
YY b1
|
9
9
|
c1
|
10
10
|
//
|
11
|
-
XX
|
11
|
+
XX a2
|
12
12
|
YY b2
|
13
13
|
c2
|
14
14
|
//
|
@@ -40,9 +40,9 @@ Feature: Sharing context
|
|
40
40
|
Scenario: Skipping entries
|
41
41
|
Given a simple parser
|
42
42
|
When I extend it
|
43
|
-
And set with("XX")
|
43
|
+
And I set it to skip entries with("XX") containing "a1"
|
44
44
|
And I run the extended parser on data
|
45
|
-
Then the result should contain '
|
45
|
+
Then the result should contain '1' entries
|
46
46
|
|
47
47
|
|
48
48
|
|
@@ -37,11 +37,20 @@ When /^the after action returns @foo$/ do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
When /^set with\("([^\"]*)"\) to skip the entry$/ do |key|
|
40
|
-
|
41
|
-
rules do
|
42
|
-
with(key) { skip_entry! }
|
43
|
-
end
|
44
|
-
end
|
40
|
+
|
45
41
|
end
|
46
42
|
|
47
43
|
|
44
|
+
|
45
|
+
|
46
|
+
When /^I set it to skip entries with\("([^\"]*)"\) containing "([^\"]*)"$/ do |key, val|
|
47
|
+
@ext_parser = @ext_parser.extend do
|
48
|
+
rules do
|
49
|
+
with(key) do |c,e|
|
50
|
+
if c.include?(val)
|
51
|
+
skip_entry!
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/swissparser.rb
CHANGED
@@ -23,7 +23,7 @@ require 'swissparser/parsing_rules'
|
|
23
23
|
|
24
24
|
module Swiss
|
25
25
|
|
26
|
-
VERSION = "0.11.
|
26
|
+
VERSION = "0.11.1"
|
27
27
|
|
28
28
|
|
29
29
|
# Parser for a typical bioinformatic flat file.
|
@@ -164,7 +164,7 @@ module Swiss
|
|
164
164
|
entry = @ctx.instance_exec( &@begin )
|
165
165
|
data.each_line do |line|
|
166
166
|
if @ctx.should_skip?
|
167
|
-
if line
|
167
|
+
if line.include? @separator
|
168
168
|
state = :end
|
169
169
|
entry = init_entry
|
170
170
|
end
|
@@ -211,7 +211,7 @@ module Swiss
|
|
211
211
|
|
212
212
|
def parse_line( line, holder )
|
213
213
|
line.chomp!
|
214
|
-
if line
|
214
|
+
if line.include? @separator
|
215
215
|
:end
|
216
216
|
elsif line =~ /^(\S+)\s+(.*)$/
|
217
217
|
key,value = $1,$2
|
@@ -5,26 +5,26 @@ module Swiss
|
|
5
5
|
class ParsingContext
|
6
6
|
|
7
7
|
def initialize(parameters)
|
8
|
-
@
|
9
|
-
@
|
8
|
+
@params__ = parameters
|
9
|
+
@skip__ = false
|
10
10
|
end
|
11
11
|
|
12
12
|
# Retrieves a parsing parameter by key. Returns nil if
|
13
13
|
# there is no parameter with the provided key.
|
14
14
|
def param( key )
|
15
|
-
@
|
15
|
+
@params__[key]
|
16
16
|
end
|
17
17
|
|
18
18
|
def skip_entry!()
|
19
|
-
@
|
19
|
+
@skip__ = true
|
20
20
|
end
|
21
21
|
|
22
22
|
def should_skip?()
|
23
|
-
@
|
23
|
+
@skip__
|
24
24
|
end
|
25
25
|
|
26
26
|
def reset_skip()
|
27
|
-
@
|
27
|
+
@skip__ = false
|
28
28
|
end
|
29
29
|
|
30
30
|
|
@@ -35,7 +35,7 @@ module Swiss
|
|
35
35
|
|
36
36
|
#Method instance_exec exists since version 1.9
|
37
37
|
if RUBY_VERSION < "1.9"
|
38
|
-
#Used to
|
38
|
+
#Used to execuxte rules and action using the ParsingContext as context
|
39
39
|
#Stolen from http://eigenclass.org/hiki/bounded+space+instance_exec
|
40
40
|
def instance_exec(*args, &block)
|
41
41
|
begin
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swissparser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- paradigmatic
|
@@ -41,12 +41,13 @@ extensions: []
|
|
41
41
|
extra_rdoc_files:
|
42
42
|
- CHANGELOG.rdoc
|
43
43
|
- README.rdoc
|
44
|
+
- benchmarks/whole_uniprot.txt
|
44
45
|
files:
|
45
|
-
- .gitignore
|
46
46
|
- CHANGELOG.rdoc
|
47
47
|
- LICENSE
|
48
48
|
- README.rdoc
|
49
49
|
- Rakefile
|
50
|
+
- benchmarks/whole_uniprot.txt
|
50
51
|
- examples/data/EColPositives_noTAT.bas
|
51
52
|
- examples/data/kegg_enzyme_short.txt
|
52
53
|
- examples/data/uniprot.txt
|