lazibi 0.1.7 → 0.1.8
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 +2 -0
- data/History.txt +7 -0
- data/Manifest.txt +20 -0
- data/README.txt +5 -16
- data/lib/helper/app_helper.rb +0 -0
- data/lib/helper/parser_helper.rb +41 -10
- data/lib/helper/task_helper.rb +1 -1
- data/lib/lazibi/version.rb +1 -1
- data/lib/parser.rb +56 -3
- data/lib/task.rb +8 -2
- data/lib/vendor/beautifier.rb +96 -8
- data/test/fixtures/clean/end_concat.txt +7 -0
- data/test/fixtures/clean/long_indent.txt +4 -0
- data/test/fixtures/clean/only_if.txt +12 -0
- data/test/fixtures/clean/re.txt +4 -0
- data/test/fixtures/clean/sep_line.txt +1 -0
- data/test/fixtures/meta/eval_code.txt +8 -0
- data/test/fixtures/meta/here_doc.txt +3 -0
- data/test/fixtures/meta/optional_do.txt +2 -0
- data/test/fixtures/meta/optional_do_with_nasty_chars.txt +3 -0
- data/test/fixtures/real/end_concat.txt +6 -0
- data/test/fixtures/real/eval_code.txt +7 -0
- data/test/fixtures/real/here_doc.txt +2 -0
- data/test/fixtures/real/long_indent.txt +4 -0
- data/test/fixtures/real/only_if.txt +12 -0
- data/test/fixtures/real/optional_do.txt +3 -0
- data/test/fixtures/real/optional_do_with_nasty_chars.txt +3 -0
- data/test/fixtures/real/re.txt +4 -0
- data/test/fixtures/real/sep_line.txt +2 -0
- data/test/test_unit.rb +15 -4
- data/website/index.html +8 -23
- data/website/index.txt +5 -16
- metadata +40 -2
data/.autotest
ADDED
data/History.txt
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 0.1.8 2007-06-19
|
2
|
+
|
3
|
+
* Support Here doc by not processing it :/
|
4
|
+
* Support ruby eval by not processing it :|
|
5
|
+
* Numeric fix of code
|
6
|
+
* Passed rake test for actionmailer :p
|
7
|
+
|
1
8
|
== 0.1.7 2007-06-18
|
2
9
|
|
3
10
|
* Bug fix: when .backup exists, code generation stops to work
|
data/Manifest.txt
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
.autotest
|
1
2
|
History.txt
|
2
3
|
License.txt
|
3
4
|
Manifest.txt
|
4
5
|
README.txt
|
5
6
|
Rakefile
|
6
7
|
bin/lazibi
|
8
|
+
lib/helper/app_helper.rb
|
7
9
|
lib/helper/parser_helper.rb
|
8
10
|
lib/helper/task_helper.rb
|
9
11
|
lib/lazibi.rb
|
@@ -13,23 +15,41 @@ lib/task.rb
|
|
13
15
|
lib/vendor/beautifier.rb
|
14
16
|
scripts/rdoc2html
|
15
17
|
scripts/txt2html
|
18
|
+
test/fixtures/clean/end_concat.txt
|
19
|
+
test/fixtures/clean/long_indent.txt
|
20
|
+
test/fixtures/clean/only_if.txt
|
21
|
+
test/fixtures/clean/re.txt
|
22
|
+
test/fixtures/clean/sep_line.txt
|
16
23
|
test/fixtures/meta/basic_class.txt
|
17
24
|
test/fixtures/meta/case.txt
|
18
25
|
test/fixtures/meta/class_with_def.txt
|
19
26
|
test/fixtures/meta/comment.txt
|
27
|
+
test/fixtures/meta/eval_code.txt
|
28
|
+
test/fixtures/meta/here_doc.txt
|
20
29
|
test/fixtures/meta/inline_end.txt
|
21
30
|
test/fixtures/meta/middle.txt
|
22
31
|
test/fixtures/meta/nested_comment.txt
|
32
|
+
test/fixtures/meta/optional_do.txt
|
33
|
+
test/fixtures/meta/optional_do_with_nasty_chars.txt
|
23
34
|
test/fixtures/meta/partial_method.txt
|
24
35
|
test/fixtures/meta/two_methods.txt
|
25
36
|
test/fixtures/real/basic_class.txt
|
26
37
|
test/fixtures/real/case.txt
|
27
38
|
test/fixtures/real/class_with_def.txt
|
28
39
|
test/fixtures/real/comment.txt
|
40
|
+
test/fixtures/real/end_concat.txt
|
41
|
+
test/fixtures/real/eval_code.txt
|
42
|
+
test/fixtures/real/here_doc.txt
|
29
43
|
test/fixtures/real/inline_end.txt
|
44
|
+
test/fixtures/real/long_indent.txt
|
30
45
|
test/fixtures/real/middle.txt
|
31
46
|
test/fixtures/real/nested_comment.txt
|
47
|
+
test/fixtures/real/only_if.txt
|
48
|
+
test/fixtures/real/optional_do.txt
|
49
|
+
test/fixtures/real/optional_do_with_nasty_chars.txt
|
32
50
|
test/fixtures/real/partial_method.txt
|
51
|
+
test/fixtures/real/re.txt
|
52
|
+
test/fixtures/real/sep_line.txt
|
33
53
|
test/fixtures/real/two_methods.txt
|
34
54
|
test/test_helper.rb
|
35
55
|
test/test_unit.rb
|
data/README.txt
CHANGED
@@ -1,22 +1,12 @@
|
|
1
1
|
== Welcome to Lazibi
|
2
2
|
|
3
|
-
Lazibi is a preprocessor that allows you to use Python style
|
4
|
-
It tries to be backward compatible with plain Ruby if you like to indent your blocks properly.
|
3
|
+
Lazibi is a preprocessor that allows you to use Python style indentation in Ruby.
|
5
4
|
|
6
5
|
The idea is to edit .py.rb files in a meta directory and let the engine generates .rb files in
|
7
|
-
the real directory for you in
|
6
|
+
the real directory for you in real time.
|
8
7
|
|
9
8
|
== Examples
|
10
9
|
|
11
|
-
Is this Ruby or Python?
|
12
|
-
|
13
|
-
class MyClass
|
14
|
-
|
15
|
-
def hello
|
16
|
-
puts 'hello world'
|
17
|
-
|
18
|
-
MyClass.new.hello
|
19
|
-
|
20
10
|
More DIY Rails controller
|
21
11
|
|
22
12
|
class AuctionsController < ApplicationController
|
@@ -63,7 +53,7 @@ Make sure everything still works
|
|
63
53
|
cd shiny_project/real
|
64
54
|
rake test / autotest
|
65
55
|
|
66
|
-
Start hacking
|
56
|
+
Start hacking in meta :/
|
67
57
|
|
68
58
|
cd shiny_project
|
69
59
|
$your_editor meta
|
@@ -94,7 +84,7 @@ Start hacking ruby/python in meta :/
|
|
94
84
|
|
95
85
|
== In Practice
|
96
86
|
|
97
|
-
Lazibi is written using Lazibi itself ( incrementally ). Personally I think autotest from
|
87
|
+
Lazibi is written using Lazibi itself ( incrementally ). Personally I think autotest from http://www.zenspider.com/ZSS/Products/ZenTest/ is a must have, and Lazibi works pretty well using TDD.
|
98
88
|
|
99
89
|
== Known issues
|
100
90
|
|
@@ -102,9 +92,8 @@ Here docs are likely to screw up code generation. Give them enough indent so the
|
|
102
92
|
|
103
93
|
== To Do
|
104
94
|
|
105
|
-
*
|
95
|
+
* Targeting Rspec
|
106
96
|
* Two way sync between real and meta
|
107
|
-
* Erb for rhtml
|
108
97
|
|
109
98
|
== Author
|
110
99
|
* Jinjing (mailto:nfjinjing@gmail.com)
|
File without changes
|
data/lib/helper/parser_helper.rb
CHANGED
@@ -4,6 +4,7 @@ require 'beautifier'
|
|
4
4
|
|
5
5
|
module Lazibi
|
6
6
|
module ParserHelper
|
7
|
+
SKIP = "#skip_parse"
|
7
8
|
|
8
9
|
def get_indent( line )
|
9
10
|
line =~ /( *)/
|
@@ -16,19 +17,34 @@ module Lazibi
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def begin_keys
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
[
|
21
|
+
/^module\b/,
|
22
|
+
/(=\s*|^)if\b/,
|
23
|
+
/(=\s*|^)until\b/,
|
24
|
+
/(=\s*|^)for\b/,
|
25
|
+
/(=\s*|^)unless\b/,
|
26
|
+
/(=\s*|^)while\b/,
|
27
|
+
/(=\s*|^)begin\b/,
|
28
|
+
/\bcase\b/,
|
29
|
+
/(=\s*|^)loop\b/,
|
30
|
+
/^class\b/,
|
31
|
+
/^def\b/,
|
32
|
+
/\bdo\b/,
|
33
|
+
]
|
24
34
|
end
|
25
35
|
|
26
36
|
def middle_keys
|
27
|
-
|
28
|
-
|
29
|
-
|
37
|
+
[
|
38
|
+
/\bthen\b/,
|
39
|
+
/^else\b/,
|
40
|
+
/^elsif\b/,
|
41
|
+
/^ensure\b/,
|
42
|
+
/^rescue\b/,
|
43
|
+
/\bwhen\b/
|
44
|
+
]
|
30
45
|
end
|
31
46
|
|
47
|
+
|
32
48
|
def end_keys
|
33
49
|
/^end\b/
|
34
50
|
end
|
@@ -36,11 +52,20 @@ module Lazibi
|
|
36
52
|
def start_anchor?( str )
|
37
53
|
return false if str =~ /^#/
|
38
54
|
str = clean_line str
|
39
|
-
|
55
|
+
group_match str, begin_keys
|
40
56
|
end
|
41
57
|
|
42
58
|
def middle_anchor?( str )
|
43
|
-
str
|
59
|
+
str = clean_line str
|
60
|
+
group_match str, middle_keys
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
def group_match(str, patterns)
|
65
|
+
for pattern in patterns
|
66
|
+
return true if str =~ pattern
|
67
|
+
end
|
68
|
+
false
|
44
69
|
end
|
45
70
|
|
46
71
|
def end_anchor?(str)
|
@@ -50,5 +75,11 @@ module Lazibi
|
|
50
75
|
def clean_line(line)
|
51
76
|
Beautifier::clean_line line
|
52
77
|
end
|
78
|
+
|
79
|
+
def nasty_line?(line)
|
80
|
+
s = %w! \/ ' " \( \{ \[ !
|
81
|
+
p = Regexp.new(s.join('|'))
|
82
|
+
return line =~ p
|
83
|
+
end
|
53
84
|
end
|
54
85
|
end
|
data/lib/helper/task_helper.rb
CHANGED
data/lib/lazibi/version.rb
CHANGED
data/lib/parser.rb
CHANGED
@@ -8,7 +8,9 @@ module Lazibi
|
|
8
8
|
|
9
9
|
def to_py( rb )
|
10
10
|
py = []
|
11
|
-
rb.split("\n")
|
11
|
+
lines = rb.split("\n")
|
12
|
+
lines.each_index do |index|
|
13
|
+
l = filter_for_to_py(lines, index)
|
12
14
|
if l.strip =~ /^end$/
|
13
15
|
next
|
14
16
|
end
|
@@ -23,7 +25,12 @@ module Lazibi
|
|
23
25
|
py.join("\n")
|
24
26
|
end
|
25
27
|
|
28
|
+
|
26
29
|
def to_rb( content )
|
30
|
+
return '' if content.strip == ''
|
31
|
+
lines = content.split("\n")
|
32
|
+
first_line = lines.first.strip
|
33
|
+
return lines[1..-1].join("\n") if first_line == '#skip_parse'
|
27
34
|
insert_end content
|
28
35
|
end
|
29
36
|
|
@@ -36,7 +43,9 @@ module Lazibi
|
|
36
43
|
while progress < @lines.size
|
37
44
|
lines = @lines[progress..-1]
|
38
45
|
lines.each_index do |index|
|
39
|
-
|
46
|
+
# run through filters
|
47
|
+
l = filter_for_to_rb(lines, index)
|
48
|
+
|
40
49
|
if start_anchor?(get_rest(l))
|
41
50
|
relative_index_for_end = find_end( lines[index..-1], get_indent(l))
|
42
51
|
unless relative_index_for_end
|
@@ -58,7 +67,7 @@ module Lazibi
|
|
58
67
|
result = @lines.join("\n")
|
59
68
|
end
|
60
69
|
|
61
|
-
def find_end( lines, indent
|
70
|
+
def find_end( lines, indent )
|
62
71
|
return 0 if lines.size == 1
|
63
72
|
|
64
73
|
anchor = 0
|
@@ -89,5 +98,49 @@ module Lazibi
|
|
89
98
|
end
|
90
99
|
return anchor
|
91
100
|
end
|
101
|
+
|
102
|
+
def filter_for_to_rb(lines, index)
|
103
|
+
l = lines[index]
|
104
|
+
|
105
|
+
# maybe do is a good thing .....
|
106
|
+
return l
|
107
|
+
|
108
|
+
return l if l.strip == ''
|
109
|
+
rest = get_rest l
|
110
|
+
return l if start_anchor?(rest) || middle_anchor?(rest) || end_anchor?(rest)
|
111
|
+
l = add_do(l, lines, index)
|
112
|
+
|
113
|
+
# also change the original array
|
114
|
+
lines[index] = l
|
115
|
+
end
|
116
|
+
|
117
|
+
def add_do(l, lines, index)
|
118
|
+
l_check = clean_line l
|
119
|
+
return l if nasty_line?(l_check)
|
120
|
+
next_line = index + 1 < lines.size ? lines[index+1] : nil
|
121
|
+
return l unless next_line
|
122
|
+
if get_indent(next_line) > get_indent(l)
|
123
|
+
return l.rstrip + ' do'
|
124
|
+
else
|
125
|
+
return l
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
def filter_for_to_py(lines, index)
|
131
|
+
l = lines[index]
|
132
|
+
|
133
|
+
# same
|
134
|
+
return l
|
135
|
+
l = remove_do(l, lines, index)
|
136
|
+
end
|
137
|
+
|
138
|
+
def remove_do(l, lines, index)
|
139
|
+
l_check = clean_line(l).strip
|
140
|
+
if l_check.size > 3 && l.strip[-3..-1] == ' do' && !nasty_line?(l_check)
|
141
|
+
return l.rstrip[0...-3].rstrip
|
142
|
+
end
|
143
|
+
return l
|
144
|
+
end
|
92
145
|
end
|
93
146
|
end
|
data/lib/task.rb
CHANGED
@@ -77,8 +77,14 @@ module Lazibi
|
|
77
77
|
rb = open(rb_path).read
|
78
78
|
|
79
79
|
py_file = open(py_path, 'w')
|
80
|
-
|
81
|
-
|
80
|
+
new_rb = Beautifier::ruby rb if beautify
|
81
|
+
if new_rb
|
82
|
+
py = to_py(new_rb)
|
83
|
+
else
|
84
|
+
py = SKIP + "\n" + rb
|
85
|
+
end
|
86
|
+
|
87
|
+
py_file.write(py)
|
82
88
|
py_file.close
|
83
89
|
end
|
84
90
|
|
data/lib/vendor/beautifier.rb
CHANGED
@@ -19,8 +19,9 @@ module Beautifier
|
|
19
19
|
/(=\s*|^)unless\b/,
|
20
20
|
/(=\s*|^)while\b/,
|
21
21
|
/(=\s*|^)begin\b/,
|
22
|
-
|
23
|
-
|
22
|
+
/\bcase\b/,
|
23
|
+
/(=\s*|^)loop\b/,
|
24
|
+
# /\bthen\b/,
|
24
25
|
/^class\b/,
|
25
26
|
/^rescue\b/,
|
26
27
|
/^def\b/,
|
@@ -39,6 +40,7 @@ module Beautifier
|
|
39
40
|
/^rescue\b/,
|
40
41
|
/^ensure\b/,
|
41
42
|
/^elsif\b/,
|
43
|
+
# /\bthen\b/,
|
42
44
|
/^end\b/,
|
43
45
|
/^else\b/,
|
44
46
|
/\bwhen\b/,
|
@@ -56,10 +58,12 @@ module Beautifier
|
|
56
58
|
return line + "\n"
|
57
59
|
end
|
58
60
|
|
59
|
-
def self.clean_line(
|
61
|
+
def self.clean_line( line )
|
60
62
|
|
61
63
|
# throw out sequences that will
|
62
64
|
# only sow confusion
|
65
|
+
|
66
|
+
tline = line.dup
|
63
67
|
tline.gsub!(/\/.*?[^\\]\//,"")
|
64
68
|
tline.gsub!(/%r\{.*?\}/,"")
|
65
69
|
tline.gsub!(/%r(.).*?\1/,"")
|
@@ -69,13 +73,93 @@ module Beautifier
|
|
69
73
|
tline.gsub!(/#\{.*?\}/,"")
|
70
74
|
|
71
75
|
# more ..
|
72
|
-
tline.gsub!(/%w\{
|
73
|
-
tline.gsub!(/%w\(
|
76
|
+
tline.gsub!(/%w\{.*?\}/, '')
|
77
|
+
tline.gsub!(/%w\(.*?\)/, '')
|
78
|
+
tline.gsub!(/%w\[.*?\]/, '')
|
79
|
+
|
80
|
+
tline.gsub!(/%w(.).*?\1/, '')
|
74
81
|
|
75
82
|
tline
|
76
83
|
end
|
77
84
|
|
85
|
+
def self.split_end( source )
|
86
|
+
lines = source.split("\n")
|
87
|
+
new_lines = []
|
88
|
+
for line in lines
|
89
|
+
if line =~ /^\s*#/
|
90
|
+
new_lines << line
|
91
|
+
else
|
92
|
+
new_lines << line.gsub( /\send\./, "\nend." )
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
new_lines.join("\n")
|
97
|
+
end
|
98
|
+
|
99
|
+
def self.join_sep_line( source )
|
100
|
+
lines = source.split("\n")
|
101
|
+
continue = false
|
102
|
+
buffer = ''
|
103
|
+
new_lines = []
|
104
|
+
for line in lines
|
105
|
+
if line =~ /^\s*#/
|
106
|
+
if continue
|
107
|
+
new_lines << buffer
|
108
|
+
new_lines << line
|
109
|
+
buffer = ''
|
110
|
+
else
|
111
|
+
new_lines << line
|
112
|
+
end
|
113
|
+
next
|
114
|
+
end
|
115
|
+
|
116
|
+
if continue
|
117
|
+
if line.strip == ''
|
118
|
+
continue = false
|
119
|
+
new_lines << buffer
|
120
|
+
new_lines << line
|
121
|
+
buffer = ''
|
122
|
+
elsif line.strip[-1..-1] == "\\"
|
123
|
+
continue = true
|
124
|
+
buffer += ' ' + line.strip[0...-1].strip
|
125
|
+
else
|
126
|
+
continue = false
|
127
|
+
buffer += ' ' + line.lstrip
|
128
|
+
new_lines << buffer
|
129
|
+
buffer = ''
|
130
|
+
end
|
131
|
+
else
|
132
|
+
if line.strip == ''
|
133
|
+
new_lines << line
|
134
|
+
elsif line.strip[-1..-1] == "\\"
|
135
|
+
continue = true
|
136
|
+
buffer += line.rstrip[0...-1].strip
|
137
|
+
else
|
138
|
+
new_lines << line
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
new_lines.join("\n")
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
def self.valid?( line )
|
148
|
+
not_supported = using_eval?(line) || here_doc?(line)
|
149
|
+
return !not_supported
|
150
|
+
end
|
151
|
+
|
152
|
+
def self.using_eval?( line )
|
153
|
+
line =~ /\b(class|module|instance)_eval\b/
|
154
|
+
end
|
155
|
+
|
156
|
+
def self.here_doc?( line )
|
157
|
+
line =~ /(=\s*<<)|(<<-)/
|
158
|
+
end
|
159
|
+
|
78
160
|
def self.ruby( source )
|
161
|
+
invalid = false
|
162
|
+
source = join_sep_line(split_end(source))
|
79
163
|
commentBlock = false
|
80
164
|
multiLineArray = Array.new
|
81
165
|
multiLineStr = ""
|
@@ -108,7 +192,11 @@ module Beautifier
|
|
108
192
|
# throw out sequences that will
|
109
193
|
# only sow confusion
|
110
194
|
tline = clean_line(tline)
|
111
|
-
|
195
|
+
unless valid?(tline)
|
196
|
+
puts 'Skipped since: ' + tline
|
197
|
+
invalid = true
|
198
|
+
break
|
199
|
+
end
|
112
200
|
$outdentExp.each do |re|
|
113
201
|
if(tline =~ re)
|
114
202
|
tab -= 1
|
@@ -127,7 +215,7 @@ module Beautifier
|
|
127
215
|
end
|
128
216
|
if(!commentLine)
|
129
217
|
$indentExp.each do |re|
|
130
|
-
if(tline =~ re && !(tline =~ /\s+end\s*$/)
|
218
|
+
if(tline =~ re) && !(tline =~ /\s+end\s*$/)
|
131
219
|
tab += 1
|
132
220
|
break
|
133
221
|
end
|
@@ -143,7 +231,7 @@ module Beautifier
|
|
143
231
|
# if(tab != 0)
|
144
232
|
# STDERR.puts "Indentation error: #{tab}"
|
145
233
|
#
|
146
|
-
|
234
|
+
return false if invalid
|
147
235
|
dest
|
148
236
|
end
|
149
237
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
before + case quoting_method
|
2
|
+
when "q", "Q" then
|
3
|
+
unquote_quoted_printable_and_convert_to(text, to_charset, from_charset, preserve_underscores)
|
4
|
+
when "b", "B" then
|
5
|
+
unquote_base64_and_convert_to(text, to_charset, from_charset)
|
6
|
+
when nil then
|
7
|
+
# will be nil at the end of the string, due to the nature of
|
8
|
+
# the regex used.
|
9
|
+
""
|
10
|
+
else
|
11
|
+
raise "unknown quoting method #{quoting_method.inspect}"
|
12
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
abc def
|
@@ -0,0 +1,12 @@
|
|
1
|
+
before + case quoting_method
|
2
|
+
when "q", "Q" then
|
3
|
+
unquote_quoted_printable_and_convert_to(text, to_charset, from_charset, preserve_underscores)
|
4
|
+
when "b", "B" then
|
5
|
+
unquote_base64_and_convert_to(text, to_charset, from_charset)
|
6
|
+
when nil then
|
7
|
+
# will be nil at the end of the string, due to the nature of
|
8
|
+
# the regex used.
|
9
|
+
""
|
10
|
+
else
|
11
|
+
raise "unknown quoting method #{quoting_method.inspect}"
|
12
|
+
end
|
data/test/test_unit.rb
CHANGED
@@ -22,7 +22,7 @@ class TestLazibi < Test::Unit::TestCase
|
|
22
22
|
next unless fn =~ /[.]txt$/
|
23
23
|
@real[fn.scan(/(.*)[.]/).to_s.to_sym] = File.read(expected_dir + "/#{fn}")
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
clean_dir = File.dirname(__FILE__) + '/fixtures/clean'
|
27
27
|
Dir.open(clean_dir).each do |fn|
|
28
28
|
next unless fn =~ /[.]txt$/
|
@@ -64,19 +64,26 @@ class TestLazibi < Test::Unit::TestCase
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def test_convert_content
|
67
|
-
@meta.keys.reject{|k| ['partial_method', 'inline_end'].include? k.to_s }.each do |k|
|
67
|
+
@meta.keys.reject{|k| ['partial_method', 'inline_end', 'optional_do', 'eval_code', 'here_doc'].include? k.to_s }.each do |k|
|
68
68
|
assert_convert k
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
72
|
def test_to_rb
|
73
73
|
assert_to_rb :partial_method
|
74
|
+
# assert_to_rb :optional_do
|
75
|
+
assert_to_rb :eval_code
|
74
76
|
end
|
75
77
|
|
76
78
|
def test_to_py
|
77
79
|
assert_to_py :inline_end
|
78
80
|
end
|
79
|
-
|
81
|
+
|
82
|
+
def test_skip
|
83
|
+
assert_skip :eval_code
|
84
|
+
assert_skip :here_doc
|
85
|
+
end
|
86
|
+
|
80
87
|
def test_beauty
|
81
88
|
@clean.keys.each do |k|
|
82
89
|
assert_beauty k
|
@@ -105,8 +112,12 @@ class TestLazibi < Test::Unit::TestCase
|
|
105
112
|
def assert_identity( s )
|
106
113
|
assert_equal @r.to_rb( @r.to_py( s ) ), s
|
107
114
|
end
|
108
|
-
|
115
|
+
|
109
116
|
def assert_beauty( name )
|
110
117
|
assert_equal Beautifier::ruby(@real[name]), @clean[name], name
|
111
118
|
end
|
119
|
+
|
120
|
+
def assert_skip( name )
|
121
|
+
assert_equal Beautifier::ruby(@real[name]), false, name
|
122
|
+
end
|
112
123
|
end
|
data/website/index.html
CHANGED
@@ -33,30 +33,18 @@
|
|
33
33
|
<h1>Welcome to Lazibi</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/lazibi"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/lazibi" class="numbers">0.1.
|
36
|
+
<a href="http://rubyforge.org/projects/lazibi" class="numbers">0.1.8</a>
|
37
37
|
</div>
|
38
38
|
<p>
|
39
|
-
Lazibi is a preprocessor that allows you to use Python style
|
40
|
-
Ruby.
|
41
|
-
indent your blocks properly.
|
39
|
+
Lazibi is a preprocessor that allows you to use Python style indentation in
|
40
|
+
Ruby.
|
42
41
|
</p>
|
43
42
|
<p>
|
44
43
|
The idea is to edit .py.rb files in a meta directory and let the engine
|
45
|
-
generates .rb files in the real directory for you in
|
44
|
+
generates .rb files in the real directory for you in real time.
|
46
45
|
</p>
|
47
46
|
<h2>Examples</h2>
|
48
47
|
<p>
|
49
|
-
Is this Ruby or Python?
|
50
|
-
</p>
|
51
|
-
<pre>
|
52
|
-
class MyClass
|
53
|
-
|
54
|
-
def hello
|
55
|
-
puts 'hello world'
|
56
|
-
|
57
|
-
MyClass.new.hello
|
58
|
-
</pre>
|
59
|
-
<p>
|
60
48
|
More DIY Rails controller
|
61
49
|
</p>
|
62
50
|
<pre>
|
@@ -109,7 +97,7 @@ Make sure everything still works
|
|
109
97
|
rake test / autotest
|
110
98
|
</pre>
|
111
99
|
<p>
|
112
|
-
Start hacking
|
100
|
+
Start hacking in meta :/
|
113
101
|
</p>
|
114
102
|
<pre>
|
115
103
|
cd shiny_project
|
@@ -152,7 +140,7 @@ Start hacking ruby/python in meta :/
|
|
152
140
|
<p>
|
153
141
|
Lazibi is written using Lazibi itself ( incrementally ). Personally I think
|
154
142
|
autotest from http://www.zenspider.com/ZSS/Products/ZenTest/ is a must
|
155
|
-
have, and Lazibi works
|
143
|
+
have, and Lazibi works pretty well using TDD.
|
156
144
|
</p>
|
157
145
|
<h2>Known issues</h2>
|
158
146
|
<p>
|
@@ -161,14 +149,11 @@ so they are treated like normal code inside current code block ;|
|
|
161
149
|
</p>
|
162
150
|
<h2>To Do</h2>
|
163
151
|
<ul>
|
164
|
-
<li>
|
152
|
+
<li>Targeting Rspec
|
165
153
|
|
166
154
|
</li>
|
167
155
|
<li>Two way sync between real and meta
|
168
156
|
|
169
|
-
</li>
|
170
|
-
<li>Erb for rhtml
|
171
|
-
|
172
157
|
</li>
|
173
158
|
</ul>
|
174
159
|
<h2>Author</h2>
|
@@ -182,7 +167,7 @@ Released under the MIT license (included)
|
|
182
167
|
</p>
|
183
168
|
|
184
169
|
<p class="coda">
|
185
|
-
<a href="mailto:nfjinjing@gmail.com">Jinjing</a>,
|
170
|
+
<a href="mailto:nfjinjing@gmail.com">Jinjing</a>, 19th June 2007<br>
|
186
171
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
187
172
|
</p>
|
188
173
|
</div>
|
data/website/index.txt
CHANGED
@@ -1,22 +1,12 @@
|
|
1
1
|
== Welcome to Lazibi
|
2
2
|
|
3
|
-
Lazibi is a preprocessor that allows you to use Python style
|
4
|
-
It tries to be backward compatible with plain Ruby if you like to indent your blocks properly.
|
3
|
+
Lazibi is a preprocessor that allows you to use Python style indentation in Ruby.
|
5
4
|
|
6
5
|
The idea is to edit .py.rb files in a meta directory and let the engine generates .rb files in
|
7
|
-
the real directory for you in
|
6
|
+
the real directory for you in real time.
|
8
7
|
|
9
8
|
== Examples
|
10
9
|
|
11
|
-
Is this Ruby or Python?
|
12
|
-
|
13
|
-
class MyClass
|
14
|
-
|
15
|
-
def hello
|
16
|
-
puts 'hello world'
|
17
|
-
|
18
|
-
MyClass.new.hello
|
19
|
-
|
20
10
|
More DIY Rails controller
|
21
11
|
|
22
12
|
class AuctionsController < ApplicationController
|
@@ -63,7 +53,7 @@ Make sure everything still works
|
|
63
53
|
cd shiny_project/real
|
64
54
|
rake test / autotest
|
65
55
|
|
66
|
-
Start hacking
|
56
|
+
Start hacking in meta :/
|
67
57
|
|
68
58
|
cd shiny_project
|
69
59
|
$your_editor meta
|
@@ -94,7 +84,7 @@ Start hacking ruby/python in meta :/
|
|
94
84
|
|
95
85
|
== In Practice
|
96
86
|
|
97
|
-
Lazibi is written using Lazibi itself ( incrementally ). Personally I think autotest from
|
87
|
+
Lazibi is written using Lazibi itself ( incrementally ). Personally I think autotest from http://www.zenspider.com/ZSS/Products/ZenTest/ is a must have, and Lazibi works pretty well using TDD.
|
98
88
|
|
99
89
|
== Known issues
|
100
90
|
|
@@ -102,9 +92,8 @@ Here docs are likely to screw up code generation. Give them enough indent so the
|
|
102
92
|
|
103
93
|
== To Do
|
104
94
|
|
105
|
-
*
|
95
|
+
* Targeting Rspec
|
106
96
|
* Two way sync between real and meta
|
107
|
-
* Erb for rhtml
|
108
97
|
|
109
98
|
== Author
|
110
99
|
* Jinjing (mailto:nfjinjing@gmail.com)
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.3
|
|
3
3
|
specification_version: 1
|
4
4
|
name: lazibi
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date: 2007-06-
|
6
|
+
version: 0.1.8
|
7
|
+
date: 2007-06-19 00:00:00 +08:00
|
8
8
|
summary: Python like syntax for Ruby
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -29,12 +29,14 @@ post_install_message:
|
|
29
29
|
authors:
|
30
30
|
- Jinjing
|
31
31
|
files:
|
32
|
+
- .autotest
|
32
33
|
- History.txt
|
33
34
|
- License.txt
|
34
35
|
- Manifest.txt
|
35
36
|
- README.txt
|
36
37
|
- Rakefile
|
37
38
|
- bin/lazibi
|
39
|
+
- lib/helper/app_helper.rb
|
38
40
|
- lib/helper/parser_helper.rb
|
39
41
|
- lib/helper/task_helper.rb
|
40
42
|
- lib/lazibi.rb
|
@@ -44,23 +46,41 @@ files:
|
|
44
46
|
- lib/vendor/beautifier.rb
|
45
47
|
- scripts/rdoc2html
|
46
48
|
- scripts/txt2html
|
49
|
+
- test/fixtures/clean/end_concat.txt
|
50
|
+
- test/fixtures/clean/long_indent.txt
|
51
|
+
- test/fixtures/clean/only_if.txt
|
52
|
+
- test/fixtures/clean/re.txt
|
53
|
+
- test/fixtures/clean/sep_line.txt
|
47
54
|
- test/fixtures/meta/basic_class.txt
|
48
55
|
- test/fixtures/meta/case.txt
|
49
56
|
- test/fixtures/meta/class_with_def.txt
|
50
57
|
- test/fixtures/meta/comment.txt
|
58
|
+
- test/fixtures/meta/eval_code.txt
|
59
|
+
- test/fixtures/meta/here_doc.txt
|
51
60
|
- test/fixtures/meta/inline_end.txt
|
52
61
|
- test/fixtures/meta/middle.txt
|
53
62
|
- test/fixtures/meta/nested_comment.txt
|
63
|
+
- test/fixtures/meta/optional_do.txt
|
64
|
+
- test/fixtures/meta/optional_do_with_nasty_chars.txt
|
54
65
|
- test/fixtures/meta/partial_method.txt
|
55
66
|
- test/fixtures/meta/two_methods.txt
|
56
67
|
- test/fixtures/real/basic_class.txt
|
57
68
|
- test/fixtures/real/case.txt
|
58
69
|
- test/fixtures/real/class_with_def.txt
|
59
70
|
- test/fixtures/real/comment.txt
|
71
|
+
- test/fixtures/real/end_concat.txt
|
72
|
+
- test/fixtures/real/eval_code.txt
|
73
|
+
- test/fixtures/real/here_doc.txt
|
60
74
|
- test/fixtures/real/inline_end.txt
|
75
|
+
- test/fixtures/real/long_indent.txt
|
61
76
|
- test/fixtures/real/middle.txt
|
62
77
|
- test/fixtures/real/nested_comment.txt
|
78
|
+
- test/fixtures/real/only_if.txt
|
79
|
+
- test/fixtures/real/optional_do.txt
|
80
|
+
- test/fixtures/real/optional_do_with_nasty_chars.txt
|
63
81
|
- test/fixtures/real/partial_method.txt
|
82
|
+
- test/fixtures/real/re.txt
|
83
|
+
- test/fixtures/real/sep_line.txt
|
64
84
|
- test/fixtures/real/two_methods.txt
|
65
85
|
- test/test_helper.rb
|
66
86
|
- test/test_unit.rb
|
@@ -80,23 +100,41 @@ extra_rdoc_files:
|
|
80
100
|
- License.txt
|
81
101
|
- Manifest.txt
|
82
102
|
- README.txt
|
103
|
+
- test/fixtures/clean/end_concat.txt
|
104
|
+
- test/fixtures/clean/long_indent.txt
|
105
|
+
- test/fixtures/clean/only_if.txt
|
106
|
+
- test/fixtures/clean/re.txt
|
107
|
+
- test/fixtures/clean/sep_line.txt
|
83
108
|
- test/fixtures/meta/basic_class.txt
|
84
109
|
- test/fixtures/meta/case.txt
|
85
110
|
- test/fixtures/meta/class_with_def.txt
|
86
111
|
- test/fixtures/meta/comment.txt
|
112
|
+
- test/fixtures/meta/eval_code.txt
|
113
|
+
- test/fixtures/meta/here_doc.txt
|
87
114
|
- test/fixtures/meta/inline_end.txt
|
88
115
|
- test/fixtures/meta/middle.txt
|
89
116
|
- test/fixtures/meta/nested_comment.txt
|
117
|
+
- test/fixtures/meta/optional_do.txt
|
118
|
+
- test/fixtures/meta/optional_do_with_nasty_chars.txt
|
90
119
|
- test/fixtures/meta/partial_method.txt
|
91
120
|
- test/fixtures/meta/two_methods.txt
|
92
121
|
- test/fixtures/real/basic_class.txt
|
93
122
|
- test/fixtures/real/case.txt
|
94
123
|
- test/fixtures/real/class_with_def.txt
|
95
124
|
- test/fixtures/real/comment.txt
|
125
|
+
- test/fixtures/real/end_concat.txt
|
126
|
+
- test/fixtures/real/eval_code.txt
|
127
|
+
- test/fixtures/real/here_doc.txt
|
96
128
|
- test/fixtures/real/inline_end.txt
|
129
|
+
- test/fixtures/real/long_indent.txt
|
97
130
|
- test/fixtures/real/middle.txt
|
98
131
|
- test/fixtures/real/nested_comment.txt
|
132
|
+
- test/fixtures/real/only_if.txt
|
133
|
+
- test/fixtures/real/optional_do.txt
|
134
|
+
- test/fixtures/real/optional_do_with_nasty_chars.txt
|
99
135
|
- test/fixtures/real/partial_method.txt
|
136
|
+
- test/fixtures/real/re.txt
|
137
|
+
- test/fixtures/real/sep_line.txt
|
100
138
|
- test/fixtures/real/two_methods.txt
|
101
139
|
- website/index.txt
|
102
140
|
executables:
|