rb-ruby_parser 2.0.4.1
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/.autotest +43 -0
- data/.gitignore +2 -0
- data/History.txt +176 -0
- data/Manifest.txt +13 -0
- data/README.txt +86 -0
- data/Rakefile +144 -0
- data/VERSION +1 -0
- data/bin/ruby_parse +88 -0
- data/lib/gauntlet_rubyparser.rb +120 -0
- data/lib/ruby_lexer.rb +1329 -0
- data/lib/ruby_parser.y +1790 -0
- data/lib/ruby_parser_extras.rb +1030 -0
- data/rb-ruby_parser/.document +5 -0
- data/rb-ruby_parser/.gitignore +21 -0
- data/rb-ruby_parser/LICENSE +20 -0
- data/rb-ruby_parser/README.rdoc +18 -0
- data/rb-ruby_parser/Rakefile +53 -0
- data/rb-ruby_parser/lib/rb-ruby_parser.rb +0 -0
- data/rb-ruby_parser/test/helper.rb +11 -0
- data/rb-ruby_parser/test/test_rb-ruby_parser.rb +7 -0
- data/test/test_ruby_lexer.rb +1829 -0
- data/test/test_ruby_parser.rb +480 -0
- data/test/test_ruby_parser_extras.rb +178 -0
- metadata +88 -0
data/.autotest
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'autotest/restart'
|
4
|
+
require 'autotest/rcov' if ENV['RCOV']
|
5
|
+
|
6
|
+
Autotest.add_hook :initialize do |at|
|
7
|
+
at.extra_files << "../../ParseTree/dev/test/pt_testcase.rb"
|
8
|
+
at.libs << ":../../ParseTree/dev/test:../../sexp_processor/dev/lib"
|
9
|
+
at.add_exception 'unit'
|
10
|
+
at.add_exception 'coverage'
|
11
|
+
at.add_exception 'coverage.info'
|
12
|
+
at.add_exception '.diff'
|
13
|
+
|
14
|
+
at.libs << ':../../minitest/dev/lib'
|
15
|
+
at.testlib = "minitest/autorun"
|
16
|
+
at.unit_diff = "unit_diff -u -b"
|
17
|
+
|
18
|
+
at.add_mapping(/^lib\/.*\.y$/) do |f, _|
|
19
|
+
at.files_matching %r%^test/.*#{File.basename(f, '.y').gsub '_', '_?'}.rb$%
|
20
|
+
end
|
21
|
+
|
22
|
+
at.add_mapping(/pt_testcase.rb/) do |f, _|
|
23
|
+
at.files_matching(/test_.*rb$/)
|
24
|
+
end
|
25
|
+
|
26
|
+
%w(TestEnvironment TestStackState).each do |klass|
|
27
|
+
at.extra_class_map[klass] = "test/test_ruby_parser_extras.rb"
|
28
|
+
end
|
29
|
+
|
30
|
+
%w(TestRubyParser TestParseTree).each do |klass| # HACK
|
31
|
+
at.extra_class_map[klass] = "test/test_ruby_parser.rb"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
Autotest.add_hook :run_command do |at|
|
36
|
+
system "rake parser"
|
37
|
+
end
|
38
|
+
|
39
|
+
class Autotest
|
40
|
+
def ruby
|
41
|
+
File.expand_path "~/.multiruby/install/1.9.0-0/bin/ruby"
|
42
|
+
end
|
43
|
+
end if ENV['ONENINE']
|
data/.gitignore
ADDED
data/History.txt
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
=== 2.0.4 / 2009-10-31
|
2
|
+
|
3
|
+
* Forked from seattlerb/ruby_parser
|
4
|
+
|
5
|
+
* 2 minor enhancement
|
6
|
+
|
7
|
+
* gemspec, name of gem changed pending gemcutter namespacing
|
8
|
+
* Jeweler config in git
|
9
|
+
|
10
|
+
* 1 bug fix:
|
11
|
+
|
12
|
+
* Allow text after =end of block comment
|
13
|
+
|
14
|
+
=== 2.0.4 / 2009-08-18
|
15
|
+
|
16
|
+
* 1 minor enhancement:
|
17
|
+
|
18
|
+
* Changed requires around to be more accurate.
|
19
|
+
|
20
|
+
* 4 bug fixes:
|
21
|
+
|
22
|
+
* Fixed .autotest for minitest
|
23
|
+
* Fixed emacs escape lexing bug: "\C-\\" (maglev/gemstone)
|
24
|
+
* Fixed octal lexing edgecases. (maglev/gemstone)
|
25
|
+
* Fixed regexp lexing edgecases. (maglev/gemstone)
|
26
|
+
|
27
|
+
=== 2.0.3 / 2009-06-23
|
28
|
+
|
29
|
+
* 4 minor enhancements:
|
30
|
+
|
31
|
+
* Removed dead code handling d/regex match node cruft.
|
32
|
+
* Switched to minitest
|
33
|
+
* Updated .autotest and rakefile wrt rcov for new hoe capabilities
|
34
|
+
* Updated hoe for new capabilities
|
35
|
+
|
36
|
+
* 4 bug fixes:
|
37
|
+
|
38
|
+
* Environment#all now deals with strange edge cases in RAD.
|
39
|
+
* Fixed packaging/compilation issue.
|
40
|
+
* Minor 1.9 fixes
|
41
|
+
* hoe -> flay -> rubyparser rakefile circularity fixed
|
42
|
+
|
43
|
+
=== 2.0.2 / 2009-01-20
|
44
|
+
|
45
|
+
* 2 minor enhancements:
|
46
|
+
|
47
|
+
* Added gauntlet_rubyparser plugin. YAY for easy massive bug-hunting.
|
48
|
+
* Promoted Sexp's file/line/comments to sexp_processor.
|
49
|
+
|
50
|
+
* 4 bug fixes:
|
51
|
+
|
52
|
+
* Fixed and improved the readme
|
53
|
+
* Fixed lexing heredoc newlines.
|
54
|
+
* Fixed line numbers on defns.
|
55
|
+
* Fixed rdoc generation bug pointed out by hugh sasse (who rocks)
|
56
|
+
|
57
|
+
=== 2.0.1 / 2008-11-04
|
58
|
+
|
59
|
+
* 2 minor enhancements:
|
60
|
+
|
61
|
+
* Updated for changes to splat node in many contexts.
|
62
|
+
* Made PT a developer dep
|
63
|
+
|
64
|
+
=== 2.0.0 / 2008-10-22
|
65
|
+
|
66
|
+
* 1 major enhancement
|
67
|
+
|
68
|
+
* Brought on the AWESOME! 4x faster! no known lexing/parsing bugs!
|
69
|
+
|
70
|
+
* 71 minor enhancements
|
71
|
+
|
72
|
+
* 1.9: Added Fixnum#ord.
|
73
|
+
* 1.9: Added missing Regexp constants and did it so it'd work on 1.9.
|
74
|
+
* Added #store_comment and #comments
|
75
|
+
* Added StringScanner #begin_of_line?
|
76
|
+
* Added a bunch of tests for regexp escape chars, #parse_string, #read_escape, ? numbers, ? whitespace.
|
77
|
+
* Added a hack for rubinius' r2l eval bug.
|
78
|
+
* Added a new token type tSTRING that bypasses tSTRING_BEG/END entirely. Only does non-interpolated strings and then falls back to the old way. MUCH cleaner tho.
|
79
|
+
* Added bin/ruby_parse
|
80
|
+
* Added compare rule to Rakefile.
|
81
|
+
* Added coverage files/dirs to clean rule.
|
82
|
+
* Added file and line numbers to all sexp nodes. Column/ranges to come.
|
83
|
+
* Added lex_state change for lvars at the end of yylex.
|
84
|
+
* Added lexed comments to defn/defs/class/module nodes.
|
85
|
+
* Added stats gathering for yylex. Reordered yylex for avg data
|
86
|
+
* Added tSYMBOL token type and parser rule to speed up symbol lexing.
|
87
|
+
* Added tally output for getch, unread, and unread_many.
|
88
|
+
* Added tests for ambigous uminus/uplus, backtick in cmdarg, square and curly brackets, numeric gvars, eos edge cases, string quoting %<> and %%%.
|
89
|
+
* All cases throughout yylex now return directly if they match, no passthroughs.
|
90
|
+
* All lexer cases now slurp entire token in one swoop.
|
91
|
+
* All zarrays are now just empty arrays.
|
92
|
+
* Changed s(:block_arg, :blah) to :"&blah" in args sexp.
|
93
|
+
* Cleaned up lexer error handling. Now just raises all over.
|
94
|
+
* Cleaned up read_escape and regx_options
|
95
|
+
* Cleaned up tokadd_string (for some definition of cleaned).
|
96
|
+
* Converted single quoted strings to new tSTRING token type.
|
97
|
+
* Coverage is currently 94.4% on lexer.
|
98
|
+
* Done what I can to clean up heredoc lexing... still sucks.
|
99
|
+
* Flattened resbodies in rescue node. Fixed .autotest file.
|
100
|
+
* Folded lex_keywords back in now that it screams.
|
101
|
+
* Found very last instanceof ILiteralNode in the code. haha!
|
102
|
+
* Got the tests subclassing PTTC and cleaned up a lot. YAY
|
103
|
+
* Handle yield(*ary) properly
|
104
|
+
* MASSIVELY cleaned out =begin/=end comment processor.
|
105
|
+
* Massive overhaul on Keyword class. All hail the mighty Hash!
|
106
|
+
* Massively cleaned up ident= edge cases and fixed a stupid bug from jruby.
|
107
|
+
* Merged @/@@ scanner together, going to try to do the same everywhere.
|
108
|
+
* Refactored fix_arg_lex_state, common across the lexer.
|
109
|
+
* Refactored new_fcall into new_call.
|
110
|
+
* Refactored some code to get better profile numbers.
|
111
|
+
* Refactored some more #fix_arg_lex_state.
|
112
|
+
* Refactored tail of yylex into its own method.
|
113
|
+
* Removed Module#kill
|
114
|
+
* Removed Token, replaced with Sexp.
|
115
|
+
* Removed all parse_number and parse_quote tests.
|
116
|
+
* Removed argspush, argscat. YAY!
|
117
|
+
* Removed as many token_buffer.split(//)'s as possible. 1 to go.
|
118
|
+
* Removed begins from compstmts
|
119
|
+
* Removed buffer arg for tokadd_string.
|
120
|
+
* Removed crufty (?) solo '@' token... wtf was that anyhow?
|
121
|
+
* Removed most jruby/stringio cruft from StringScanner.
|
122
|
+
* Removed one unread_many... 2 to go. They're harder.
|
123
|
+
* Removed store_comment, now done directly.
|
124
|
+
* Removed token_buffer. Now I just use token ivar.
|
125
|
+
* Removed use of s() from lexer. Changed the way line numbers are gathered.
|
126
|
+
* Renamed *qwords to *awords.
|
127
|
+
* Renamed StringScanner to RPStringScanner (a subclass) to fix namespace trashing.
|
128
|
+
* Renamed parse to process and aliased to parse.
|
129
|
+
* Renamed token_buffer to string_buffer since that arcane shit still needs it.
|
130
|
+
* Resolved the rest of the lexing issues I brought up w/ ruby-core.
|
131
|
+
* Revamped tokadd_escape.
|
132
|
+
* Rewrote Keyword and KWtable.
|
133
|
+
* Rewrote RubyLexer using StringScanner.
|
134
|
+
* Rewrote tokadd_escape. 79 lines down to 21.
|
135
|
+
* Split out lib/ruby_parser_extras.rb so lexer is standalone.
|
136
|
+
* Started to clean up the parser and make it as skinny as possible
|
137
|
+
* Stripped out as much code as possible.
|
138
|
+
* Stripped yylex of some dead code.
|
139
|
+
* Switched from StringIO to StringScanner.
|
140
|
+
* Updated rakefile for new hoe.
|
141
|
+
* Uses pure ruby racc if ENV['PURE_RUBY'], otherwise use c.
|
142
|
+
* Wrote a ton of lexer tests. Coverage is as close to 100% as possible.
|
143
|
+
* Wrote args to clean up the big nasty args processing grammar section.
|
144
|
+
* lex_strterm is now a plain array, removed RubyLexer#s(...).
|
145
|
+
* yield and super now flatten args.
|
146
|
+
|
147
|
+
* 21+ bug fixes:
|
148
|
+
|
149
|
+
* I'm sure this list is missing a lot:
|
150
|
+
* Fixed 2 bugs both involving attrasgn (and ilk) esp when lhs is an array.
|
151
|
+
* Fixed a bug in the lexer for strings with single digit hex escapes.
|
152
|
+
* Fixed a bug parsing: a (args) { expr }... the space caused a different route to be followed and all hell broke loose.
|
153
|
+
* Fixed a bug with x\n=beginvar not putting begin back.
|
154
|
+
* Fixed attrasgn to have arglists, not arrays.
|
155
|
+
* Fixed bug in defn/defs with block fixing.
|
156
|
+
* Fixed class/module's name slot if colon2/3.
|
157
|
+
* Fixed dstr with empty interpolation body.
|
158
|
+
* Fixed for 1.9 string/char changes.
|
159
|
+
* Fixed lexer BS wrt determining token type of words.
|
160
|
+
* Fixed lexer BS wrt pass through values and lexing words. SO STUPID.
|
161
|
+
* Fixed lexing of floats.
|
162
|
+
* Fixed lexing of identifiers followed by equals. I hope.
|
163
|
+
* Fixed masgn with splat on lhs
|
164
|
+
* Fixed new_super to deal with block_pass correctly.
|
165
|
+
* Fixed parser's treatment of :colon2 and :colon3.
|
166
|
+
* Fixed regexp scanning of escaped numbers, ANY number is valid, not just octs.
|
167
|
+
* Fixed string scanning of escaped octs, allowing 1-3 chars.
|
168
|
+
* Fixed unescape for \n
|
169
|
+
* Fixed: omg this is stupid. '()' was returning bare nil
|
170
|
+
* Fixed: remove_begin now goes to the end, not sure why it didn't before.
|
171
|
+
|
172
|
+
=== 1.0.0 / 2007-12-20
|
173
|
+
|
174
|
+
* 1 major enhancement
|
175
|
+
* Birthday!
|
176
|
+
|
data/Manifest.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
.autotest
|
2
|
+
History.txt
|
3
|
+
Manifest.txt
|
4
|
+
README.txt
|
5
|
+
Rakefile
|
6
|
+
bin/ruby_parse
|
7
|
+
lib/gauntlet_rubyparser.rb
|
8
|
+
lib/ruby_lexer.rb
|
9
|
+
lib/ruby_parser.y
|
10
|
+
lib/ruby_parser_extras.rb
|
11
|
+
test/test_ruby_lexer.rb
|
12
|
+
test/test_ruby_parser.rb
|
13
|
+
test/test_ruby_parser_extras.rb
|
data/README.txt
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
= ruby_parser
|
2
|
+
|
3
|
+
* http://parsetree.rubyforge.org/
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
ruby_parser (RP) is a ruby parser written in pure ruby (utilizing
|
8
|
+
racc--which does by default use a C extension). RP's output is
|
9
|
+
the same as ParseTree's output: s-expressions using ruby's arrays and
|
10
|
+
base types.
|
11
|
+
|
12
|
+
As an example:
|
13
|
+
|
14
|
+
def conditional1(arg1)
|
15
|
+
if arg1 == 0 then
|
16
|
+
return 1
|
17
|
+
end
|
18
|
+
return 0
|
19
|
+
end
|
20
|
+
|
21
|
+
becomes:
|
22
|
+
|
23
|
+
s(:defn, :conditional1,
|
24
|
+
s(:args, :arg1),
|
25
|
+
s(:scope,
|
26
|
+
s(:block,
|
27
|
+
s(:if,
|
28
|
+
s(:call, s(:lvar, :arg1), :==, s(:arglist, s(:lit, 0))),
|
29
|
+
s(:return, s(:lit, 1)),
|
30
|
+
nil),
|
31
|
+
s(:return, s(:lit, 0)))))
|
32
|
+
|
33
|
+
== FEATURES/PROBLEMS:
|
34
|
+
|
35
|
+
* Pure ruby, no compiles.
|
36
|
+
* Includes preceding comment data for defn/defs/class/module nodes!
|
37
|
+
* Incredibly simple interface.
|
38
|
+
* Output is 100% equivalent to ParseTree.
|
39
|
+
* Can utilize PT's SexpProcessor and UnifiedRuby for language processing.
|
40
|
+
* Known Issue: Speed is now pretty good, but can always improve:
|
41
|
+
* RP parses a corpus of 3702 files in 125s (avg 108 Kb/s)
|
42
|
+
* MRI+PT parsed the same in 67.38s (avg 200.89 Kb/s)
|
43
|
+
* Known Issue: Code is much better, but still has a long way to go.
|
44
|
+
* Known Issue: Totally awesome.
|
45
|
+
* Known Issue: line number values can be slightly off. Parsing LR sucks.
|
46
|
+
|
47
|
+
== SYNOPSIS:
|
48
|
+
|
49
|
+
RubyParser.new.parse "1+1"
|
50
|
+
# => s(:call, s(:lit, 1), :+, s(:array, s(:lit, 1)))
|
51
|
+
|
52
|
+
== REQUIREMENTS:
|
53
|
+
|
54
|
+
* ruby. woot.
|
55
|
+
* sexp_processor for Sexp and SexpProcessor classes.
|
56
|
+
* ParseTree for testing.
|
57
|
+
* racc full package for parser development (compiling .y to .rb).
|
58
|
+
|
59
|
+
== INSTALL:
|
60
|
+
|
61
|
+
* sudo gem install ruby_parser
|
62
|
+
|
63
|
+
== LICENSE:
|
64
|
+
|
65
|
+
(The MIT License)
|
66
|
+
|
67
|
+
Copyright (c) 2007-2008 Ryan Davis
|
68
|
+
|
69
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
70
|
+
a copy of this software and associated documentation files (the
|
71
|
+
'Software'), to deal in the Software without restriction, including
|
72
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
73
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
74
|
+
permit persons to whom the Software is furnished to do so, subject to
|
75
|
+
the following conditions:
|
76
|
+
|
77
|
+
The above copyright notice and this permission notice shall be
|
78
|
+
included in all copies or substantial portions of the Software.
|
79
|
+
|
80
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
81
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
82
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
83
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
84
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
85
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
86
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
|
6
|
+
Hoe.plugin :seattlerb
|
7
|
+
|
8
|
+
Hoe.add_include_dirs("../../ParseTree/dev/test",
|
9
|
+
"../../RubyInline/dev/lib",
|
10
|
+
"../../sexp_processor/dev/lib")
|
11
|
+
|
12
|
+
hoe = Hoe.spec 'ruby_parser' do
|
13
|
+
developer 'Ryan Davis', 'ryand-ruby@zenspider.com'
|
14
|
+
|
15
|
+
self.rubyforge_name = 'parsetree'
|
16
|
+
|
17
|
+
extra_dev_deps << ['ParseTree', '~> 3.0']
|
18
|
+
extra_deps << ['sexp_processor', '~> 3.0']
|
19
|
+
end
|
20
|
+
|
21
|
+
hoe.spec.files += ['lib/ruby_parser.rb'] # jim.... cmon man
|
22
|
+
|
23
|
+
[:default, :multi, :test].each do |t|
|
24
|
+
task t => :parser
|
25
|
+
end
|
26
|
+
|
27
|
+
path = "pkg/ruby_parser-#{hoe.version}"
|
28
|
+
task path => :parser do
|
29
|
+
Dir.chdir path do
|
30
|
+
sh "rake parser"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "build the parser"
|
35
|
+
task :parser => ["lib/ruby_parser.rb"]
|
36
|
+
|
37
|
+
rule '.rb' => '.y' do |t|
|
38
|
+
# -v = verbose
|
39
|
+
# -t = debugging parser ~4% reduction in speed -- keep for now
|
40
|
+
# -l = no-line-convert
|
41
|
+
sh "racc -v -t -l -o #{t.name} #{t.source}"
|
42
|
+
end
|
43
|
+
|
44
|
+
task :clean do
|
45
|
+
rm_rf(Dir["**/*~"] +
|
46
|
+
Dir["**/*.diff"] +
|
47
|
+
Dir["coverage.info"] +
|
48
|
+
Dir["coverage"] +
|
49
|
+
Dir["lib/ruby_parser.rb"] +
|
50
|
+
Dir["lib/*.output"])
|
51
|
+
end
|
52
|
+
|
53
|
+
def next_num(glob)
|
54
|
+
num = Dir[glob].max[/\d+/].to_i + 1
|
55
|
+
end
|
56
|
+
|
57
|
+
desc "Compares PT to RP and deletes all files that match"
|
58
|
+
task :compare do
|
59
|
+
files = Dir["unit/**/*.rb"]
|
60
|
+
puts "Parsing #{files.size} files"
|
61
|
+
files.each do |file|
|
62
|
+
puts file
|
63
|
+
system "./cmp.rb -q #{file} && rm #{file}"
|
64
|
+
end
|
65
|
+
system 'find -d unit -type d -empty -exec rmdir {} \;'
|
66
|
+
end
|
67
|
+
|
68
|
+
desc "Compares PT to RP and stops on first failure"
|
69
|
+
task :find_bug do
|
70
|
+
files = Dir["unit/**/*.rb"]
|
71
|
+
puts "Parsing #{files.size} files"
|
72
|
+
files.each do |file|
|
73
|
+
puts file
|
74
|
+
sh "./cmp.rb -q #{file}"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
task :sort do
|
79
|
+
sh 'grepsort "^ +def" lib/ruby_lexer.rb'
|
80
|
+
sh 'grepsort "^ +def (test|util)" test/test_ruby_lexer.rb'
|
81
|
+
end
|
82
|
+
|
83
|
+
task :loc do
|
84
|
+
loc1 = `wc -l ../1.0.0/lib/ruby_lexer.rb`[/\d+/]
|
85
|
+
flog1 = `flog -s ../1.0.0/lib/ruby_lexer.rb`[/\d+\.\d+/]
|
86
|
+
loc2 = `cat lib/ruby_lexer.rb lib/ruby_parser_extras.rb | wc -l`[/\d+/]
|
87
|
+
flog2 = `flog -s lib/ruby_lexer.rb lib/ruby_parser_extras.rb`[/\d+\.\d+/]
|
88
|
+
|
89
|
+
loc1, loc2, flog1, flog2 = loc1.to_i, loc2.to_i, flog1.to_f, flog2.to_f
|
90
|
+
|
91
|
+
puts "1.0.0: loc = #{loc1} flog = #{flog1}"
|
92
|
+
puts "dev : loc = #{loc2} flog = #{flog2}"
|
93
|
+
puts "delta: loc = #{loc2-loc1} flog = #{flog2-flog1}"
|
94
|
+
end
|
95
|
+
|
96
|
+
desc "Validate against all normal files in unit dir"
|
97
|
+
task :validate do
|
98
|
+
sh "./cmp.rb unit/*.rb"
|
99
|
+
end
|
100
|
+
|
101
|
+
def run_and_log cmd, prefix
|
102
|
+
files = ENV['FILES'] || 'unit/*.rb'
|
103
|
+
p, x = prefix, "txt"
|
104
|
+
n = Dir["#{p}.*.#{x}"].map { |s| s[/\d+/].to_i }.max + 1 rescue 1
|
105
|
+
f = "#{p}.#{n}.#{x}"
|
106
|
+
|
107
|
+
sh "#{cmd} #{Hoe::RUBY_FLAGS} bin/ruby_parse -q -g #{files} &> #{f}"
|
108
|
+
|
109
|
+
puts File.read(f)
|
110
|
+
end
|
111
|
+
|
112
|
+
desc "Benchmark against all normal files in unit dir"
|
113
|
+
task :benchmark do
|
114
|
+
run_and_log "ruby", "benchmark"
|
115
|
+
end
|
116
|
+
|
117
|
+
desc "Profile against all normal files in unit dir"
|
118
|
+
task :profile do
|
119
|
+
run_and_log "zenprofile", "profile"
|
120
|
+
end
|
121
|
+
|
122
|
+
desc "what was that command again?"
|
123
|
+
task :huh? do
|
124
|
+
puts "ruby #{Hoe::RUBY_FLAGS} bin/ruby_parse -q -g ..."
|
125
|
+
end
|
126
|
+
|
127
|
+
begin
|
128
|
+
require 'jeweler'
|
129
|
+
Jeweler::Tasks.new do |gem|
|
130
|
+
gem.name = "rb-ruby_parser"
|
131
|
+
gem.summary = %Q{Fork of ParseTree/ruby_parser}
|
132
|
+
gem.description = %Q{This version respects text after block comment =end}
|
133
|
+
gem.email = "ray.baxter@gmail.com"
|
134
|
+
gem.homepage = "http://github.com/raybaxter/rb-ruby_parser"
|
135
|
+
gem.authors = ["Ray Baxter"]
|
136
|
+
gem.add_development_dependency "minitest", ">= 0"
|
137
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
138
|
+
end
|
139
|
+
Jeweler::GemcutterTasks.new
|
140
|
+
rescue LoadError
|
141
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
142
|
+
end
|
143
|
+
|
144
|
+
# vim: syntax=Ruby
|