swissparser 0.7.0 → 0.8.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 ADDED
@@ -0,0 +1,8 @@
1
+ *~
2
+ *#
3
+
4
+ *.gemspec
5
+ announcement.txt
6
+
7
+ doc/
8
+ pkg/
@@ -1,3 +1,9 @@
1
+ == 0.8.0 / 2009-11-14
2
+
3
+ * 1 new feature:
4
+ - helper methods are now defined with the helper method. When the
5
+ parser is extended they can be overriden in a one per one basis.
6
+
1
7
  == 0.7.0 / 2009-11-14
2
8
 
3
9
  * *Important* *change*: SwissParser is now required with:
data/README.rdoc ADDED
@@ -0,0 +1,57 @@
1
+ = SwissParser
2
+ by Paradigmatic
3
+ http://github.com/paradigmatic/SwissParser
4
+
5
+ == DESCRIPTION:
6
+
7
+ Simple DSL to define parser for flat files formats common in biofinformatics.
8
+
9
+ == FEATURES:
10
+
11
+ SwissParser is currently under fast development. However, the code base should
12
+ be stable enough to be used for bioinformatics research.
13
+
14
+ * Defines parsers with a clear and compact declarative syntax.
15
+ * The whole parsing workflow is configurable.
16
+ * The user can create new parsers by extending existing parsers.
17
+ * Parser have access to global parameters and user defined helper methods.
18
+
19
+ == USAGE:
20
+
21
+ See tutorials: http://wiki.github.com/paradigmatic/SwissParser
22
+
23
+
24
+ == REQUIREMENTS:
25
+
26
+ Only pure standard ruby. Tested with version 1.8.7 only but should work with JRuby and others.
27
+
28
+ If you want to participate in SwissParser developpement, you will need the gem *bones*.
29
+
30
+ == INSTALL:
31
+
32
+ SwissParser is available as a gem through gemcutter. If you still use
33
+ rubyforge, you will need to change the sources as explained here:
34
+ http://gemcutter.org/pages/gem_docs
35
+
36
+ Then you can simply install SwissParser with:
37
+
38
+ gem install swissparser
39
+
40
+ and start defining parsers by requiring it:
41
+
42
+ require 'swissparser'
43
+
44
+ Alternatively, you can download the whole source tree or just the
45
+ swissparser.rb file using the github site:
46
+
47
+ http://github.com/paradigmatic/SwissParser
48
+
49
+ Finally, if you want to participate in the development or use the edge
50
+ version you can clone the project with git:
51
+
52
+ $ git clone git://github.com/paradigmatic/SwissParser
53
+
54
+ == LICENSE:
55
+
56
+ Distributed under GPLv3. See the included LICENSE file for details.
57
+
data/Rakefile CHANGED
@@ -16,6 +16,8 @@ Bones {
16
16
  email 'paradigmatic@streum.org'
17
17
  url 'http://github.com/paradigmatic/SwissParser'
18
18
  version Swiss::VERSION
19
+ readme_file 'README.rdoc'
20
+ history_file 'CHANGELOG.rdoc'
19
21
  ignore_file '.gitignore'
20
22
  rdoc.exclude ["examples/data"]
21
23
  }
@@ -35,17 +35,13 @@ enzyme_parser = Swiss::Parser.define do
35
35
  end
36
36
 
37
37
 
38
- helpers do
39
-
40
- def parse_gene_ids( string, entry )
41
- string.split(" ").each do |item|
42
- if item =~ /(\d+)\(\w+\)/
43
- entry[:genes] << $1
44
- end
38
+ helper :parse_gene_ids do |string, entry|
39
+ string.split(" ").each do |item|
40
+ if item =~ /(\d+)\(\w+\)/
41
+ entry[:genes] << $1
45
42
  end
46
43
  end
47
44
  end
48
-
49
45
 
50
46
  rules do
51
47
 
data/lib/swissparser.rb CHANGED
@@ -19,7 +19,7 @@ along with SwissParser. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  module Swiss
21
21
 
22
- VERSION = "0.7.0"
22
+ VERSION = "0.8.0"
23
23
 
24
24
  # This class defines parsing rules. Its methods
25
25
  # are accessible within the +rules+ section of
@@ -112,7 +112,7 @@ module Swiss
112
112
  @separator = DEFAULT_SEPARATOR
113
113
  @actions = {}
114
114
  @actions[:text] = {}
115
- @helpers = lambda {}
115
+ @helpers = {}
116
116
  elsif args.size == 7
117
117
  actions,separator,before,the_begin,the_end,after,helpers = *args
118
118
  @actions = actions.clone
@@ -162,10 +162,13 @@ module Swiss
162
162
  @after = proc
163
163
  end
164
164
 
165
- # Helpers methods accessible to rules and actions can be
166
- # defined using this method.
167
- def helpers(&proc)
168
- @helpers = proc
165
+ # Define an helper method accessible to rules and actions.
166
+ # This method tales two argument:
167
+ # * A symbol which will be the method name
168
+ # * A block which is the method implementation. The block can take parameters.
169
+ # The helper method can then be called as a regular method.
170
+ def helper(name, &proc)
171
+ @helpers[name] = proc
169
172
  end
170
173
 
171
174
  # Defines parsing rules inside a parser definition. The ParsingRules
@@ -211,7 +214,11 @@ module Swiss
211
214
  # it returns an array containing _entry_ objects.
212
215
  def parse_file( filename, params={} )
213
216
  @ctx = ParsingContext.new( params )
214
- @ctx.instance_exec( &@helpers )
217
+ helperModule = Module.new
218
+ @helpers.each do |name, proc|
219
+ helperModule.send( :define_method, name, proc )
220
+ end
221
+ @ctx.extend( helperModule )
215
222
  container = @ctx.instance_exec( &@before )
216
223
  File.open( filename, 'r' ) do |file|
217
224
  entry = @ctx.instance_exec( &@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.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - paradigmatic
@@ -29,12 +29,13 @@ executables: []
29
29
  extensions: []
30
30
 
31
31
  extra_rdoc_files:
32
- - History.txt
33
- - README.txt
32
+ - CHANGELOG.rdoc
33
+ - README.rdoc
34
34
  files:
35
- - History.txt
35
+ - .gitignore
36
+ - CHANGELOG.rdoc
36
37
  - LICENSE
37
- - README.txt
38
+ - README.rdoc
38
39
  - Rakefile
39
40
  - examples/data/EColPositives_noTAT.bas
40
41
  - examples/data/kegg_enzyme_short.txt
@@ -52,7 +53,7 @@ licenses: []
52
53
  post_install_message:
53
54
  rdoc_options:
54
55
  - --main
55
- - README.txt
56
+ - README.rdoc
56
57
  require_paths:
57
58
  - lib
58
59
  required_ruby_version: !ruby/object:Gem::Requirement
data/README.txt DELETED
@@ -1,32 +0,0 @@
1
- = SwissParser
2
- by Paradigmatic
3
- http://github.com/paradigmatic/SwissParser
4
-
5
- == DESCRIPTION:
6
-
7
- Simple DSL to define parser for flat files formats common in biofinformatics.
8
-
9
- == FEATURES:
10
-
11
- * Defines parsers with a declarative syntax.
12
- * The whole parsing workflow is configurable.
13
- * The user can create new parsers by extending existing parsers.
14
-
15
- == SYNOPSIS:
16
-
17
- See examples
18
-
19
- == REQUIREMENTS:
20
-
21
- Only prue standard ruby. Tested with version 1.8.7 only but should work with JRuby and others.
22
-
23
- If you want to participate in SwissParser developpement, you will need the gem *bones*.
24
-
25
- == INSTALL:
26
-
27
- Soon available as a gem...
28
-
29
- == LICENSE:
30
-
31
- Distributed under GPLv3. See included LICENSE file.
32
-