swissparser 0.11.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +9 -0
- data/CHANGELOG.rdoc +9 -0
- data/README.rdoc +28 -17
- data/Rakefile +2 -2
- data/Rakefile.compiled.rbc +622 -0
- data/examples/kegg_demo.rb +39 -63
- data/examples/uniprot.rb +85 -0
- data/features/basic_parsing.feature +79 -30
- data/features/extra.feature +52 -0
- data/features/step_definitions/basic_steps.rb +84 -0
- data/features/step_definitions/sugar_steps.rb +71 -0
- data/lib/swissparser.rb +39 -194
- data/lib/swissparser.rbc +928 -0
- data/lib/swissparser/entries.rb +137 -0
- data/lib/swissparser/entries.rbc +2360 -0
- data/lib/swissparser/rules.rb +112 -0
- data/lib/swissparser/rules.rbc +1699 -0
- metadata +55 -32
- data/benchmarks/whole_uniprot.txt +0 -7
- data/examples/parse_from_uri.rb +0 -88
- data/examples/signal_demo.rb +0 -100
- data/examples/tutorial_1.rb +0 -88
- data/examples/tutorial_2.rb +0 -65
- data/examples/uniprot_param_demo.rb +0 -85
- data/features/parser_extension.feature +0 -83
- data/features/parsing_context.feature +0 -48
- data/features/polite.feature +0 -16
- data/features/step_definitions/core.rb +0 -71
- data/features/step_definitions/definitions.rb +0 -68
- data/features/step_definitions/extra.rb +0 -56
- data/lib/swiss_parser.rb +0 -13
- data/lib/swissparser/parsing_context.rb +0 -60
- data/lib/swissparser/parsing_rules.rb +0 -39
@@ -1,60 +0,0 @@
|
|
1
|
-
module Swiss
|
2
|
-
|
3
|
-
# Methods of this class are accessible to rules and actions.
|
4
|
-
# Methods defined in +helpers+ block are added to this class.
|
5
|
-
class ParsingContext
|
6
|
-
|
7
|
-
def initialize(parameters)
|
8
|
-
@params__ = parameters
|
9
|
-
@skip__ = false
|
10
|
-
end
|
11
|
-
|
12
|
-
# Retrieves a parsing parameter by key. Returns nil if
|
13
|
-
# there is no parameter with the provided key.
|
14
|
-
def param( key )
|
15
|
-
@params__[key]
|
16
|
-
end
|
17
|
-
|
18
|
-
def skip_entry!()
|
19
|
-
@skip__ = true
|
20
|
-
end
|
21
|
-
|
22
|
-
def should_skip?()
|
23
|
-
@skip__
|
24
|
-
end
|
25
|
-
|
26
|
-
def reset_skip()
|
27
|
-
@skip__ = false
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
module InstanceExecHelper #:nodoc:
|
32
|
-
end
|
33
|
-
|
34
|
-
include InstanceExecHelper
|
35
|
-
|
36
|
-
#Method instance_exec exists since version 1.9
|
37
|
-
if RUBY_VERSION < "1.9"
|
38
|
-
#Used to execuxte rules and action using the ParsingContext as context
|
39
|
-
#Stolen from http://eigenclass.org/hiki/bounded+space+instance_exec
|
40
|
-
def instance_exec(*args, &block)
|
41
|
-
begin
|
42
|
-
old_critical, Thread.critical = Thread.critical, true
|
43
|
-
n = 0
|
44
|
-
n += 1 while respond_to?(mname="__instance_exec#{n}")
|
45
|
-
InstanceExecHelper.module_eval{ define_method(mname, &block) }
|
46
|
-
ensure
|
47
|
-
Thread.critical = old_critical
|
48
|
-
end
|
49
|
-
begin
|
50
|
-
ret = send(mname, *args)
|
51
|
-
ensure
|
52
|
-
InstanceExecHelper.module_eval{ remove_method(mname) } rescue nil
|
53
|
-
end
|
54
|
-
ret
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module Swiss
|
2
|
-
|
3
|
-
# This class defines parsing rules. Its methods
|
4
|
-
# are accessible within the +rules+ section of
|
5
|
-
# a parser definition.
|
6
|
-
class ParsingRules
|
7
|
-
|
8
|
-
attr_reader :separator, :actions
|
9
|
-
|
10
|
-
# *Do* *not* create directly this class but access it
|
11
|
-
# through a +rules+ section in a parser definition.
|
12
|
-
def initialize
|
13
|
-
@actions = { :text => {} }
|
14
|
-
end
|
15
|
-
|
16
|
-
# Sets the entry separator line. Default: "//"
|
17
|
-
def set_separator(string)
|
18
|
-
@separator = string
|
19
|
-
end
|
20
|
-
|
21
|
-
# Defines how to parse a line starting with +key+. The +proc+
|
22
|
-
# takes two arguments:
|
23
|
-
# * the rest of the line
|
24
|
-
# * the entry object
|
25
|
-
def with( key, &proc )
|
26
|
-
@actions[key] = proc
|
27
|
-
end
|
28
|
-
|
29
|
-
# Defines how to parse a line without key coming *after*
|
30
|
-
# a specified key. The +proc+ takes two arguments:
|
31
|
-
# * the rest of the line
|
32
|
-
# * the entry object
|
33
|
-
def with_text_after( key, &proc )
|
34
|
-
@actions[:text][key] = proc
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|