lazibi 0.1.6 → 0.1.7
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/History.txt +4 -0
- data/README.txt +8 -5
- data/lib/helper/parser_helper.rb +9 -1
- data/lib/helper/task_helper.rb +0 -10
- data/lib/lazibi/version.rb +1 -1
- data/lib/lazibi.rb +2 -1
- data/lib/task.rb +15 -0
- data/lib/vendor/beautifier.rb +20 -11
- data/test/test_helper.rb +3 -1
- data/test/test_unit.rb +17 -1
- data/website/index.html +13 -7
- data/website/index.txt +8 -5
- metadata +1 -1
data/History.txt
CHANGED
data/README.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
== Welcome to Lazibi
|
2
2
|
|
3
|
-
Lazibi is a
|
4
|
-
|
3
|
+
Lazibi is a preprocessor that allows you to use Python style indenting in Ruby.
|
4
|
+
It tries to be backward compatible with plain Ruby if you like to indent your blocks properly.
|
5
5
|
|
6
6
|
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.
|
7
|
+
the real directory for you in _real time_.
|
8
8
|
|
9
9
|
== Examples
|
10
10
|
|
@@ -92,10 +92,13 @@ Start hacking ruby/python in meta :/
|
|
92
92
|
- pattern_2
|
93
93
|
- for_example_^vendor
|
94
94
|
|
95
|
+
== In Practice
|
96
|
+
|
97
|
+
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 best using TDD.
|
98
|
+
|
95
99
|
== Known issues
|
96
100
|
|
97
|
-
Here
|
98
|
-
to indent long strings like the fix for rails
|
101
|
+
Here docs are likely to screw up code generation. Give them enough indent so they are treated like normal code inside current code block ;|
|
99
102
|
|
100
103
|
== To Do
|
101
104
|
|
data/lib/helper/parser_helper.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__) + '/../vendor')
|
2
|
+
|
3
|
+
require 'beautifier'
|
4
|
+
|
1
5
|
module Lazibi
|
2
6
|
module ParserHelper
|
3
7
|
|
@@ -30,8 +34,8 @@ module Lazibi
|
|
30
34
|
end
|
31
35
|
|
32
36
|
def start_anchor?( str )
|
33
|
-
str.gsub! /"[^"]+"|'[^']+'/, ''
|
34
37
|
return false if str =~ /^#/
|
38
|
+
str = clean_line str
|
35
39
|
return true if str =~ begin_keys
|
36
40
|
end
|
37
41
|
|
@@ -42,5 +46,9 @@ module Lazibi
|
|
42
46
|
def end_anchor?(str)
|
43
47
|
str =~ end_keys
|
44
48
|
end
|
49
|
+
|
50
|
+
def clean_line(line)
|
51
|
+
Beautifier::clean_line line
|
52
|
+
end
|
45
53
|
end
|
46
54
|
end
|
data/lib/helper/task_helper.rb
CHANGED
@@ -29,15 +29,5 @@ module Lazibi
|
|
29
29
|
new_dir_name = to + dir_name[from.size..-1]
|
30
30
|
new_path = File.join new_dir_name, base_name + new_ext
|
31
31
|
end
|
32
|
-
|
33
|
-
|
34
|
-
def get_metas
|
35
|
-
meta_files = File.join('meta', "**", "*.py.rb")
|
36
|
-
metas = {}
|
37
|
-
Dir.glob(meta_files).each do |t|
|
38
|
-
metas[t] = File.mtime t
|
39
|
-
end
|
40
|
-
metas
|
41
|
-
end
|
42
32
|
end
|
43
33
|
end
|
data/lib/lazibi/version.rb
CHANGED
data/lib/lazibi.rb
CHANGED
data/lib/task.rb
CHANGED
@@ -32,6 +32,8 @@ module Lazibi
|
|
32
32
|
if File.directory? real_dir
|
33
33
|
backup_dir = '.backup'
|
34
34
|
unless File.exists? backup_dir
|
35
|
+
puts "backup #{real_dir} to #{backup_dir}"
|
36
|
+
puts "-" * 40
|
35
37
|
FileUtils.cp_r real_dir, backup_dir
|
36
38
|
end
|
37
39
|
else
|
@@ -40,6 +42,7 @@ module Lazibi
|
|
40
42
|
|
41
43
|
# generate meta
|
42
44
|
meta_dir = 'meta'
|
45
|
+
FileUtils.mkdir_p meta_dir
|
43
46
|
if File.exists? meta_dir
|
44
47
|
if File.directory? meta_dir
|
45
48
|
FileUtils.rm_rf meta_dir
|
@@ -84,6 +87,8 @@ module Lazibi
|
|
84
87
|
meta = open(meta_name)
|
85
88
|
real_name = convert_path meta_name
|
86
89
|
begin
|
90
|
+
real_path = File.dirname real_name
|
91
|
+
FileUtils.mkdir_p real_path
|
87
92
|
real_rb = open( real_name, 'w' )
|
88
93
|
real_rb.write(to_rb(meta.read))
|
89
94
|
rescue Exception => e
|
@@ -93,5 +98,15 @@ module Lazibi
|
|
93
98
|
end
|
94
99
|
meta.close
|
95
100
|
end
|
101
|
+
|
102
|
+
|
103
|
+
def get_metas
|
104
|
+
meta_files = File.join('meta', "**", "*.py.rb")
|
105
|
+
metas = {}
|
106
|
+
Dir.glob(meta_files).each do |t|
|
107
|
+
metas[t] = File.mtime t
|
108
|
+
end
|
109
|
+
metas
|
110
|
+
end
|
96
111
|
end
|
97
112
|
end
|
data/lib/vendor/beautifier.rb
CHANGED
@@ -56,6 +56,25 @@ module Beautifier
|
|
56
56
|
return line + "\n"
|
57
57
|
end
|
58
58
|
|
59
|
+
def self.clean_line( tline )
|
60
|
+
|
61
|
+
# throw out sequences that will
|
62
|
+
# only sow confusion
|
63
|
+
tline.gsub!(/\/.*?[^\\]\//,"")
|
64
|
+
tline.gsub!(/%r\{.*?\}/,"")
|
65
|
+
tline.gsub!(/%r(.).*?\1/,"")
|
66
|
+
tline.gsub!(/\\\"/,"'")
|
67
|
+
tline.gsub!(/".*?"/,"\"\"")
|
68
|
+
tline.gsub!(/'.*?'/,"''")
|
69
|
+
tline.gsub!(/#\{.*?\}/,"")
|
70
|
+
|
71
|
+
# more ..
|
72
|
+
tline.gsub!(/%w\{[^\{]*?\}/, '')
|
73
|
+
tline.gsub!(/%w\([^(]*?\)/, '')
|
74
|
+
|
75
|
+
tline
|
76
|
+
end
|
77
|
+
|
59
78
|
def self.ruby( source )
|
60
79
|
commentBlock = false
|
61
80
|
multiLineArray = Array.new
|
@@ -88,17 +107,7 @@ module Beautifier
|
|
88
107
|
if(!commentLine)
|
89
108
|
# throw out sequences that will
|
90
109
|
# only sow confusion
|
91
|
-
tline
|
92
|
-
tline.gsub!(/%r\{.*?\}/,"")
|
93
|
-
tline.gsub!(/%r(.).*?\1/,"")
|
94
|
-
tline.gsub!(/\\\"/,"'")
|
95
|
-
tline.gsub!(/".*?"/,"\"\"")
|
96
|
-
tline.gsub!(/'.*?'/,"''")
|
97
|
-
tline.gsub!(/#\{.*?\}/,"")
|
98
|
-
|
99
|
-
# more ..
|
100
|
-
tline.gsub!(/%w\{[^\{]*?\}/, '')
|
101
|
-
tline.gsub!(/%w\([^(]*?\)/, '')
|
110
|
+
tline = clean_line(tline)
|
102
111
|
|
103
112
|
$outdentExp.each do |re|
|
104
113
|
if(tline =~ re)
|
data/test/test_helper.rb
CHANGED
data/test/test_unit.rb
CHANGED
@@ -9,9 +9,9 @@ class TestLazibi < Test::Unit::TestCase
|
|
9
9
|
# load fixtures
|
10
10
|
@meta = {}
|
11
11
|
@real = {}
|
12
|
+
@clean = {}
|
12
13
|
|
13
14
|
fixture_dir = File.dirname(__FILE__) + '/fixtures/meta'
|
14
|
-
|
15
15
|
Dir.open(fixture_dir).each do |fn|
|
16
16
|
next unless fn =~ /[.]txt$/
|
17
17
|
@meta[fn.scan(/(.*)[.]/).to_s.to_sym] = File.read(fixture_dir + "/#{fn}")
|
@@ -22,6 +22,12 @@ 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
|
+
|
26
|
+
clean_dir = File.dirname(__FILE__) + '/fixtures/clean'
|
27
|
+
Dir.open(clean_dir).each do |fn|
|
28
|
+
next unless fn =~ /[.]txt$/
|
29
|
+
@clean[fn.scan(/(.*)[.]/).to_s.to_sym] = File.read(clean_dir + "/#{fn}")
|
30
|
+
end
|
25
31
|
|
26
32
|
@r = Lazibi::Runner.new
|
27
33
|
end
|
@@ -70,6 +76,12 @@ class TestLazibi < Test::Unit::TestCase
|
|
70
76
|
def test_to_py
|
71
77
|
assert_to_py :inline_end
|
72
78
|
end
|
79
|
+
|
80
|
+
def test_beauty
|
81
|
+
@clean.keys.each do |k|
|
82
|
+
assert_beauty k
|
83
|
+
end
|
84
|
+
end
|
73
85
|
|
74
86
|
|
75
87
|
private
|
@@ -93,4 +105,8 @@ class TestLazibi < Test::Unit::TestCase
|
|
93
105
|
def assert_identity( s )
|
94
106
|
assert_equal @r.to_rb( @r.to_py( s ) ), s
|
95
107
|
end
|
108
|
+
|
109
|
+
def assert_beauty( name )
|
110
|
+
assert_equal Beautifier::ruby(@real[name]), @clean[name], name
|
111
|
+
end
|
96
112
|
end
|
data/website/index.html
CHANGED
@@ -33,16 +33,16 @@
|
|
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.7</a>
|
37
37
|
</div>
|
38
38
|
<p>
|
39
|
-
Lazibi is a
|
40
|
-
|
41
|
-
|
39
|
+
Lazibi is a preprocessor that allows you to use Python style indenting in
|
40
|
+
Ruby. It tries to be backward compatible with plain Ruby if you like to
|
41
|
+
indent your blocks properly.
|
42
42
|
</p>
|
43
43
|
<p>
|
44
44
|
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.
|
45
|
+
generates .rb files in the real directory for you in _real time_.
|
46
46
|
</p>
|
47
47
|
<h2>Examples</h2>
|
48
48
|
<p>
|
@@ -148,10 +148,16 @@ Start hacking ruby/python in meta :/
|
|
148
148
|
</pre>
|
149
149
|
</li>
|
150
150
|
</ul>
|
151
|
+
<h2>In Practice</h2>
|
152
|
+
<p>
|
153
|
+
Lazibi is written using Lazibi itself ( incrementally ). Personally I think
|
154
|
+
autotest from http://www.zenspider.com/ZSS/Products/ZenTest/ is a must
|
155
|
+
have, and Lazibi works best using TDD.
|
156
|
+
</p>
|
151
157
|
<h2>Known issues</h2>
|
152
158
|
<p>
|
153
|
-
Here
|
154
|
-
|
159
|
+
Here docs are likely to screw up code generation. Give them enough indent
|
160
|
+
so they are treated like normal code inside current code block ;|
|
155
161
|
</p>
|
156
162
|
<h2>To Do</h2>
|
157
163
|
<ul>
|
data/website/index.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
== Welcome to Lazibi
|
2
2
|
|
3
|
-
Lazibi is a
|
4
|
-
|
3
|
+
Lazibi is a preprocessor that allows you to use Python style indenting in Ruby.
|
4
|
+
It tries to be backward compatible with plain Ruby if you like to indent your blocks properly.
|
5
5
|
|
6
6
|
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.
|
7
|
+
the real directory for you in _real time_.
|
8
8
|
|
9
9
|
== Examples
|
10
10
|
|
@@ -92,10 +92,13 @@ Start hacking ruby/python in meta :/
|
|
92
92
|
- pattern_2
|
93
93
|
- for_example_^vendor
|
94
94
|
|
95
|
+
== In Practice
|
96
|
+
|
97
|
+
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 best using TDD.
|
98
|
+
|
95
99
|
== Known issues
|
96
100
|
|
97
|
-
Here
|
98
|
-
to indent long strings like the fix for rails
|
101
|
+
Here docs are likely to screw up code generation. Give them enough indent so they are treated like normal code inside current code block ;|
|
99
102
|
|
100
103
|
== To Do
|
101
104
|
|