lazibi 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/README.txt +8 -7
- data/Rakefile +1 -1
- data/lib/lazibi/version.rb +2 -2
- data/lib/lazibi.rb +208 -208
- data/test/test_unit.rb +1 -1
- data/website/index.html +149 -48
- data/website/index.txt +96 -17
- data/website/template.rhtml +1 -1
- metadata +1 -1
data/History.txt
CHANGED
data/README.txt
CHANGED
@@ -44,12 +44,12 @@ Even sexier migrations ( with sexy_migration Rails plugin )
|
|
44
44
|
|
45
45
|
== Download
|
46
46
|
|
47
|
-
gem install lazibi
|
47
|
+
gem install lazibi
|
48
48
|
svn checkout http://lazibi.googlecode.com/svn/trunk/real lazibi
|
49
49
|
|
50
50
|
== Install
|
51
51
|
|
52
|
-
from source
|
52
|
+
If from source
|
53
53
|
|
54
54
|
rake gem
|
55
55
|
gem install pkg/lazibi-0.1.0.gem
|
@@ -60,7 +60,8 @@ Bootstrap
|
|
60
60
|
|
61
61
|
mkdir shiny_project
|
62
62
|
cd shiny_project
|
63
|
-
|
63
|
+
# put trunk in real
|
64
|
+
svn co $svn_path/shiny_project/trunk real
|
64
65
|
lazibi
|
65
66
|
|
66
67
|
Make sure everything still works
|
@@ -80,10 +81,10 @@ Start hacking ruby/python :/
|
|
80
81
|
|
81
82
|
After bootstrap, edit config/boot.py.rb in meta
|
82
83
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
84
|
+
STDERR.puts %(Cannot find gem for Rails ~>#{version}.0:
|
85
|
+
Install the missing gem with 'gem install -v=#{version} rails', or
|
86
|
+
change environment.rb to define RAILS_GEM_VERSION with your desired version.
|
87
|
+
)
|
87
88
|
|
88
89
|
=== Manually create meta files
|
89
90
|
|
data/Rakefile
CHANGED
@@ -82,7 +82,7 @@ hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc'
|
|
82
82
|
desc 'Generate website files'
|
83
83
|
task :website_generate do
|
84
84
|
Dir['website/**/*.txt'].each do |txt|
|
85
|
-
sh %{ ruby scripts/
|
85
|
+
sh %{ ruby scripts/rdoc2html #{txt} > #{txt.gsub(/txt$/,'html')} }
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
data/lib/lazibi/version.rb
CHANGED
data/lib/lazibi.rb
CHANGED
@@ -3,274 +3,274 @@ require 'find'
|
|
3
3
|
require 'yaml'
|
4
4
|
|
5
5
|
module Lazibi
|
6
|
-
class Lazibi
|
7
|
-
|
6
|
+
class Lazibi
|
7
|
+
attr :config
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
9
|
+
def load_config
|
10
|
+
@config = {}
|
11
|
+
default = {:exclude => ['^vendor']}
|
12
|
+
if File.exists? '.lazibi'
|
13
|
+
f = open '.lazibi'
|
14
|
+
h = YAML.load(f)
|
15
|
+
for k in h.keys
|
16
|
+
begin
|
17
|
+
@config[k.to_sym] = h[k]
|
18
|
+
rescue
|
19
|
+
raise "wrong pattern #{h[k]}"
|
20
|
+
end
|
20
21
|
end
|
21
22
|
end
|
23
|
+
@config = default
|
22
24
|
end
|
23
|
-
@config = default
|
24
|
-
end
|
25
25
|
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
def init_meta
|
28
|
+
# backup real
|
29
|
+
real_dir = 'real'
|
30
|
+
if File.directory? real_dir
|
31
|
+
backup_dir = '.backup'
|
32
|
+
unless File.exists? backup_dir
|
33
|
+
FileUtils.cp_r real_dir, backup_dir
|
34
|
+
end
|
35
|
+
else
|
36
|
+
raise 'No directory named "real"'
|
34
37
|
end
|
35
|
-
else
|
36
|
-
raise 'No directory named "real"'
|
37
|
-
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
39
|
+
# generate meta
|
40
|
+
meta_dir = 'meta'
|
41
|
+
if File.exists? meta_dir
|
42
|
+
if File.directory? meta_dir
|
43
|
+
FileUtils.rm_rf meta_dir
|
44
|
+
else
|
45
|
+
raise 'meta directory is reserved for instiki'
|
46
|
+
end
|
46
47
|
end
|
47
|
-
end
|
48
48
|
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
50
|
+
puts "Generating meta files:"
|
51
|
+
puts "-" * 40
|
52
|
+
Dir.glob(File.join('real', '**', '*.rb')) do |f|
|
53
|
+
if skip_path? f
|
54
|
+
puts "- #{f}"
|
55
|
+
next
|
56
|
+
end
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
next unless File.file? f
|
59
|
+
next if f =~ /.*[.]py[.]rb$/
|
60
|
+
py_path = convert_path f
|
61
|
+
dir_name = File.dirname py_path
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
63
|
+
puts ' ' + py_path
|
64
|
+
FileUtils.mkdir_p dir_name
|
65
|
+
make_py f, py_path
|
66
|
+
end
|
67
67
|
|
68
|
-
|
69
|
-
|
68
|
+
puts "-" * 40
|
69
|
+
end
|
70
70
|
|
71
71
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
72
|
+
def skip_path?(path)
|
73
|
+
return false if @config[:exclude].nil?
|
74
|
+
@config[:exclude].each do |f|
|
75
|
+
offset = 'meta'.size + 1
|
76
|
+
return true if path[offset..-1] =~ Regexp.new(f)
|
77
|
+
end
|
78
|
+
false
|
77
79
|
end
|
78
|
-
false
|
79
|
-
end
|
80
80
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
81
|
+
def convert_path( path )
|
82
|
+
if path =~ /.*[.]py[.]rb/
|
83
|
+
from = 'meta'
|
84
|
+
to = 'real'
|
85
|
+
old_ext = '.py.rb'
|
86
|
+
new_ext = '.rb'
|
87
|
+
else
|
88
|
+
from = 'real'
|
89
|
+
to = 'meta'
|
90
|
+
old_ext = '.rb'
|
91
|
+
new_ext = '.py.rb'
|
92
|
+
end
|
93
93
|
|
94
|
-
|
95
|
-
|
94
|
+
dir_name = File.dirname path
|
95
|
+
base_name = File.basename path, old_ext
|
96
96
|
|
97
|
-
|
98
|
-
|
99
|
-
|
97
|
+
new_dir_name = to + dir_name[from.size..-1]
|
98
|
+
new_path = File.join new_dir_name, base_name + new_ext
|
99
|
+
end
|
100
100
|
|
101
|
-
|
102
|
-
|
101
|
+
def make_py( rb_path, py_path )
|
102
|
+
rb = open(rb_path).read
|
103
103
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
104
|
+
py_file = open(py_path, 'w')
|
105
|
+
py_file.write(to_py(rb))
|
106
|
+
py_file.close
|
107
|
+
end
|
108
108
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
109
|
+
def to_py( rb )
|
110
|
+
py = []
|
111
|
+
rb.split("\n").each do |l|
|
112
|
+
if l.strip =~ /^end$/
|
113
|
+
next
|
114
|
+
end
|
115
|
+
s = l
|
116
|
+
if l.rstrip[-4..-1] == ' end'
|
117
|
+
s = l.rstrip[0...-3].rstrip
|
118
|
+
end
|
119
119
|
|
120
|
-
|
121
|
-
|
120
|
+
py << s
|
121
|
+
end
|
122
122
|
|
123
|
-
|
124
|
-
|
123
|
+
py.join("\n")
|
124
|
+
end
|
125
125
|
|
126
126
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
127
|
+
def run
|
128
|
+
load_config
|
129
|
+
init_meta unless File.exists? '.backup'
|
130
|
+
@metas = {}
|
131
|
+
while true
|
132
|
+
current_metas = get_metas
|
133
|
+
current_metas.each_pair do |meta, m_time|
|
134
|
+
if @metas[meta] != m_time
|
135
|
+
update_rb meta
|
136
|
+
puts "+ #{meta}..."
|
137
|
+
end
|
137
138
|
end
|
139
|
+
@metas = current_metas
|
140
|
+
sleep 1
|
138
141
|
end
|
139
|
-
@metas = current_metas
|
140
|
-
sleep 1
|
141
142
|
end
|
142
|
-
end
|
143
143
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
144
|
+
def get_metas
|
145
|
+
meta_files = File.join('meta', "**", "*.py.rb")
|
146
|
+
metas = {}
|
147
|
+
Dir.glob(meta_files).each do |t|
|
148
|
+
metas[t] = File.mtime t
|
149
|
+
end
|
150
|
+
metas
|
149
151
|
end
|
150
|
-
metas
|
151
|
-
end
|
152
152
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
153
|
+
def update_rb( meta_name )
|
154
|
+
meta = open(meta_name)
|
155
|
+
real_name = convert_path meta_name
|
156
|
+
begin
|
157
|
+
real_rb = open( real_name, 'w' )
|
158
|
+
real_rb.write(to_rb(meta.read))
|
159
|
+
rescue Exception => e
|
160
|
+
puts e
|
161
|
+
ensure
|
162
|
+
real_rb.close unless real_rb.nil?
|
163
|
+
end
|
164
|
+
meta.close
|
163
165
|
end
|
164
|
-
meta.close
|
165
|
-
end
|
166
166
|
|
167
|
-
|
168
|
-
|
169
|
-
|
167
|
+
def to_rb( content )
|
168
|
+
insert_end content
|
169
|
+
end
|
170
170
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
171
|
+
def insert_end( content )
|
172
|
+
@lines = content.split("\n")
|
173
|
+
progress = 0
|
174
|
+
while progress < @lines.size
|
175
|
+
lines = @lines[progress..-1]
|
176
|
+
lines.each_index do |index|
|
177
|
+
l = lines[index]
|
178
|
+
if start_anchor?(get_rest(l))
|
179
|
+
relative_index_for_end = find_end( lines[index..-1], get_indent(l))
|
180
|
+
unless relative_index_for_end
|
181
|
+
progress += 1
|
182
|
+
break
|
183
|
+
end
|
184
|
+
index_for_end = relative_index_for_end + index
|
185
|
+
lines[index_for_end] = lines[index_for_end] + "\n" + ' ' * get_indent(l) + "end"
|
186
|
+
head = @lines[0...progress]
|
187
|
+
tail = lines[index..-1].join("\n").split("\n")
|
188
|
+
@lines = head + tail
|
181
189
|
progress += 1
|
182
190
|
break
|
183
191
|
end
|
184
|
-
index_for_end = relative_index_for_end + index
|
185
|
-
lines[index_for_end] = lines[index_for_end] + "\n" + ' ' * get_indent(l) + "end"
|
186
|
-
head = @lines[0...progress]
|
187
|
-
tail = lines[index..-1].join("\n").split("\n")
|
188
|
-
@lines = head + tail
|
189
192
|
progress += 1
|
190
|
-
break
|
191
193
|
end
|
192
|
-
progress += 1
|
193
194
|
end
|
194
|
-
end
|
195
195
|
|
196
|
-
|
197
|
-
|
196
|
+
result = @lines.join("\n")
|
197
|
+
end
|
198
198
|
|
199
|
-
|
200
|
-
|
199
|
+
def find_end( lines, indent )
|
200
|
+
return 0 if lines.size == 1
|
201
201
|
|
202
|
-
|
202
|
+
anchor = 0
|
203
203
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
next
|
213
|
-
end
|
214
|
-
return anchor if get_indent(l) < indent
|
215
|
-
if get_indent(l) == indent
|
216
|
-
rest = get_rest l
|
217
|
-
if middle_anchor? rest
|
218
|
-
anchor = i + 1
|
204
|
+
lines = lines[1..-1]
|
205
|
+
lines.each_index do |i|
|
206
|
+
l = lines[i]
|
207
|
+
next if l.strip == ''
|
208
|
+
if l.strip =~ /^#/
|
209
|
+
if get_indent(l) > indent
|
210
|
+
anchor = i + 1
|
211
|
+
end
|
219
212
|
next
|
220
|
-
elsif end_anchor? rest
|
221
|
-
return false
|
222
|
-
else
|
223
|
-
return anchor
|
224
213
|
end
|
214
|
+
return anchor if get_indent(l) < indent
|
215
|
+
if get_indent(l) == indent
|
216
|
+
rest = get_rest l
|
217
|
+
if middle_anchor? rest
|
218
|
+
anchor = i + 1
|
219
|
+
next
|
220
|
+
elsif end_anchor? rest
|
221
|
+
return false
|
222
|
+
else
|
223
|
+
return anchor
|
224
|
+
end
|
225
|
+
end
|
226
|
+
anchor = i + 1
|
225
227
|
end
|
226
|
-
anchor
|
228
|
+
return anchor
|
227
229
|
end
|
228
|
-
return anchor
|
229
|
-
end
|
230
230
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
231
|
+
def get_indent( line )
|
232
|
+
line =~ /( *)/
|
233
|
+
$1.size
|
234
|
+
end
|
235
235
|
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
236
|
+
def get_rest( line )
|
237
|
+
line =~/( *)/
|
238
|
+
$'
|
239
|
+
end
|
240
240
|
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
241
|
+
def begin_keys
|
242
|
+
s = %w( module def class if begin for while unless do )
|
243
|
+
m = ['\sdo\s*$|\sdo\s+(\|[^|]+\|)']
|
244
|
+
s.map!{|key| "^#{key}\\b"}
|
245
245
|
|
246
|
-
|
247
|
-
|
246
|
+
Regexp.new(s.concat(m).join('|'))
|
247
|
+
end
|
248
248
|
|
249
249
|
|
250
250
|
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
251
|
+
def middle_keys
|
252
|
+
s = %w( rescue else ensure elsif )
|
253
|
+
s.map!{|key| "^#{key}\\b"}
|
254
|
+
Regexp.new(s.join('|'))
|
255
|
+
end
|
256
256
|
|
257
|
-
|
258
|
-
|
259
|
-
|
257
|
+
def end_keys
|
258
|
+
/^end\b/
|
259
|
+
end
|
260
260
|
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
261
|
+
def start_anchor?( str )
|
262
|
+
str.gsub! /"[^"]+"|'[^']+'/, ''
|
263
|
+
return false if str =~ /^#/
|
264
|
+
return true if str =~ begin_keys
|
265
|
+
end
|
266
266
|
|
267
|
-
|
268
|
-
|
269
|
-
|
267
|
+
def middle_anchor?( str )
|
268
|
+
str =~ middle_keys
|
269
|
+
end
|
270
270
|
|
271
|
-
|
272
|
-
|
271
|
+
def end_anchor?(str)
|
272
|
+
str =~ end_keys
|
273
|
+
end
|
273
274
|
end
|
274
275
|
end
|
275
|
-
|
276
|
-
require 'lazibi/version'
|
276
|
+
require 'lazibi/version'
|
data/test/test_unit.rb
CHANGED
data/website/index.html
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
<link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
|
6
6
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
7
7
|
<title>
|
8
|
-
|
8
|
+
Welcome to Lazibi
|
9
9
|
</title>
|
10
10
|
<script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>
|
11
11
|
<style>
|
@@ -30,58 +30,159 @@
|
|
30
30
|
<body>
|
31
31
|
<div id="main">
|
32
32
|
|
33
|
-
<h1>
|
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.3</a>
|
37
37
|
</div>
|
38
|
-
<
|
38
|
+
<p>
|
39
|
+
Lazibi is a meta language which allows you to use Python like syntax (
|
40
|
+
tab-indented block ) in Ruby. It’s backward compatible with plain
|
41
|
+
Ruby if you indent your blocks properly.
|
42
|
+
</p>
|
43
|
+
<p>
|
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.
|
46
|
+
</p>
|
47
|
+
<h2>Examples</h2>
|
48
|
+
<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
|
+
More DIY Rails controller
|
61
|
+
</p>
|
62
|
+
<pre>
|
63
|
+
class AuctionsController < ApplicationController
|
64
|
+
|
65
|
+
def index
|
66
|
+
@auctions = Auction.paginate :page => params[:page]
|
67
|
+
|
68
|
+
respond_to do |format|
|
69
|
+
format.html # index.rhtml
|
70
|
+
format.xml { render :xml => @auctions.to_xml }
|
71
|
+
</pre>
|
72
|
+
<p>
|
73
|
+
Even sexier migrations ( with sexy_migration Rails plugin )
|
74
|
+
</p>
|
75
|
+
<pre>
|
76
|
+
class CreateOrders < ActiveRecord::Migration
|
77
|
+
def self.up
|
78
|
+
create_table :orders do
|
79
|
+
fkey :user
|
80
|
+
fkey :auction
|
81
|
+
integer :bid_type
|
82
|
+
timestamps!
|
83
|
+
|
84
|
+
def self.down
|
85
|
+
drop_table :orders
|
86
|
+
</pre>
|
87
|
+
<h2>Download</h2>
|
88
|
+
<pre>
|
89
|
+
gem install lazibi
|
90
|
+
svn checkout http://lazibi.googlecode.com/svn/trunk/real lazibi
|
91
|
+
</pre>
|
92
|
+
<h2>Install</h2>
|
93
|
+
<p>
|
94
|
+
If from source
|
95
|
+
</p>
|
96
|
+
<pre>
|
97
|
+
rake gem
|
98
|
+
gem install pkg/lazibi-0.1.0.gem
|
99
|
+
</pre>
|
100
|
+
<h2>Usage</h2>
|
101
|
+
<p>
|
102
|
+
Bootstrap
|
103
|
+
</p>
|
104
|
+
<pre>
|
105
|
+
mkdir shiny_project
|
106
|
+
cd shiny_project
|
107
|
+
# put trunk in real
|
108
|
+
svn co $svn_path/shiny_project/trunk real
|
109
|
+
lazibi
|
110
|
+
</pre>
|
111
|
+
<p>
|
112
|
+
Make sure everything still works
|
113
|
+
</p>
|
114
|
+
<pre>
|
115
|
+
_start_a_new_terminal_
|
116
|
+
cd shiny_project/real
|
117
|
+
rake test / autotest
|
118
|
+
</pre>
|
119
|
+
<p>
|
120
|
+
Start hacking ruby/python :/
|
121
|
+
</p>
|
122
|
+
<pre>
|
123
|
+
cd shiny_project
|
124
|
+
$your_editor meta
|
125
|
+
</pre>
|
126
|
+
<h2>Tips</h2>
|
127
|
+
<h3>Rails fix</h3>
|
128
|
+
<p>
|
129
|
+
After bootstrap, edit config/boot.py.rb in meta
|
130
|
+
</p>
|
131
|
+
<pre>
|
132
|
+
STDERR.puts %(Cannot find gem for Rails ~>#{version}.0:
|
133
|
+
Install the missing gem with 'gem install -v=#{version} rails', or
|
134
|
+
change environment.rb to define RAILS_GEM_VERSION with your desired version.
|
135
|
+
)
|
136
|
+
</pre>
|
137
|
+
<h3>Manually create meta files</h3>
|
138
|
+
<ul>
|
139
|
+
<li>Bootstrap your project as usual, just don’t run lazibi
|
140
|
+
|
141
|
+
</li>
|
142
|
+
<li>setup environment
|
143
|
+
|
144
|
+
<pre>
|
145
|
+
mkdir .backup
|
146
|
+
mkdir meta
|
147
|
+
</pre>
|
148
|
+
</li>
|
149
|
+
<li>run lazibi
|
150
|
+
|
151
|
+
</li>
|
152
|
+
<li>create .py.rb files in corresponding directories inside ‘meta’,
|
153
|
+
.rb files will be created and updated in ‘real’ as usual
|
154
|
+
|
155
|
+
</li>
|
156
|
+
</ul>
|
157
|
+
<h2>Known issues</h2>
|
158
|
+
<p>
|
159
|
+
Here document like long strings are likely to screw up code generation, try
|
160
|
+
to indent long strings like the fix for rails
|
161
|
+
</p>
|
162
|
+
<h2>To Do</h2>
|
163
|
+
<ul>
|
164
|
+
<li>Here doc fix
|
165
|
+
|
166
|
+
</li>
|
167
|
+
<li>Two way sync between real and meta
|
168
|
+
|
169
|
+
</li>
|
170
|
+
<li>Erb for rhtml
|
171
|
+
|
172
|
+
</li>
|
173
|
+
</ul>
|
174
|
+
<h2>Author</h2>
|
175
|
+
<ul>
|
176
|
+
<li>Jinjing (mailto:nfjinjing@gmail.com)
|
177
|
+
|
178
|
+
</li>
|
179
|
+
</ul>
|
180
|
+
<p>
|
181
|
+
Released under the MIT license (included)
|
182
|
+
</p>
|
39
183
|
|
40
|
-
|
41
|
-
<h2>What</h2>
|
42
|
-
|
43
|
-
|
44
|
-
<h2>Installing</h2>
|
45
|
-
|
46
|
-
|
47
|
-
<pre syntax="ruby">sudo gem install lazibi</pre>
|
48
|
-
|
49
|
-
<h2>The basics</h2>
|
50
|
-
|
51
|
-
|
52
|
-
<h2>Demonstration of usage</h2>
|
53
|
-
|
54
|
-
|
55
|
-
<h2>Forum</h2>
|
56
|
-
|
57
|
-
|
58
|
-
<p><a href="http://groups.google.com/group/lazibi">http://groups.google.com/group/lazibi</a></p>
|
59
|
-
|
60
|
-
|
61
|
-
<p><span class="caps">TODO</span> – create Google Group – lazibi</p>
|
62
|
-
|
63
|
-
|
64
|
-
<h2>How to submit patches</h2>
|
65
|
-
|
66
|
-
|
67
|
-
<p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people’s code</a> and for section <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups">8b: Submit patch to Google Groups</a>, use the Google Group above.</p>
|
68
|
-
|
69
|
-
|
70
|
-
<p>The trunk repository is <code>svn://rubyforge.org/var/svn/lazibi/trunk</code> for anonymous access.</p>
|
71
|
-
|
72
|
-
|
73
|
-
<h2>License</h2>
|
74
|
-
|
75
|
-
|
76
|
-
<p>This code is free to use under the terms of the <span class="caps">MIT</span> license.</p>
|
77
|
-
|
78
|
-
|
79
|
-
<h2>Contact</h2>
|
80
|
-
|
81
|
-
|
82
|
-
<p>Comments are welcome. Send an email to <a href="mailto:nfjinjing@gmail.com">Jinjing</a> email.</p>
|
83
184
|
<p class="coda">
|
84
|
-
<a href="mailto:
|
185
|
+
<a href="mailto:nfjinjing@gmail.com">Jinjing</a>, 14th June 2007<br>
|
85
186
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
86
187
|
</p>
|
87
188
|
</div>
|
data/website/index.txt
CHANGED
@@ -1,38 +1,117 @@
|
|
1
|
-
|
1
|
+
== Welcome to Lazibi
|
2
2
|
|
3
|
-
|
3
|
+
Lazibi is a meta language which allows you to use Python like syntax ( tab-indented block ) in
|
4
|
+
Ruby. It's backward compatible with plain Ruby if you indent your blocks properly.
|
4
5
|
|
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.
|
5
8
|
|
6
|
-
|
9
|
+
== Examples
|
7
10
|
|
11
|
+
Is this Ruby or Python?
|
8
12
|
|
9
|
-
|
13
|
+
class MyClass
|
14
|
+
|
15
|
+
def hello
|
16
|
+
puts 'hello world'
|
17
|
+
|
18
|
+
MyClass.new.hello
|
10
19
|
|
11
|
-
|
20
|
+
More DIY Rails controller
|
12
21
|
|
13
|
-
|
22
|
+
class AuctionsController < ApplicationController
|
14
23
|
|
24
|
+
def index
|
25
|
+
@auctions = Auction.paginate :page => params[:page]
|
26
|
+
|
27
|
+
respond_to do |format|
|
28
|
+
format.html # index.rhtml
|
29
|
+
format.xml { render :xml => @auctions.to_xml }
|
15
30
|
|
16
|
-
h2. Demonstration of usage
|
17
31
|
|
32
|
+
Even sexier migrations ( with sexy_migration Rails plugin )
|
18
33
|
|
34
|
+
class CreateOrders < ActiveRecord::Migration
|
35
|
+
def self.up
|
36
|
+
create_table :orders do
|
37
|
+
fkey :user
|
38
|
+
fkey :auction
|
39
|
+
integer :bid_type
|
40
|
+
timestamps!
|
19
41
|
|
20
|
-
|
42
|
+
def self.down
|
43
|
+
drop_table :orders
|
21
44
|
|
22
|
-
|
45
|
+
== Download
|
23
46
|
|
24
|
-
|
47
|
+
gem install lazibi
|
48
|
+
svn checkout http://lazibi.googlecode.com/svn/trunk/real lazibi
|
25
49
|
|
26
|
-
|
50
|
+
== Install
|
27
51
|
|
28
|
-
|
52
|
+
If from source
|
29
53
|
|
30
|
-
|
54
|
+
rake gem
|
55
|
+
gem install pkg/lazibi-0.1.0.gem
|
31
56
|
|
32
|
-
|
57
|
+
== Usage
|
33
58
|
|
34
|
-
|
59
|
+
Bootstrap
|
35
60
|
|
36
|
-
|
61
|
+
mkdir shiny_project
|
62
|
+
cd shiny_project
|
63
|
+
# put trunk in real
|
64
|
+
svn co $svn_path/shiny_project/trunk real
|
65
|
+
lazibi
|
37
66
|
|
38
|
-
|
67
|
+
Make sure everything still works
|
68
|
+
|
69
|
+
_start_a_new_terminal_
|
70
|
+
cd shiny_project/real
|
71
|
+
rake test / autotest
|
72
|
+
|
73
|
+
Start hacking ruby/python :/
|
74
|
+
|
75
|
+
cd shiny_project
|
76
|
+
$your_editor meta
|
77
|
+
|
78
|
+
== Tips
|
79
|
+
|
80
|
+
=== Rails fix
|
81
|
+
|
82
|
+
After bootstrap, edit config/boot.py.rb in meta
|
83
|
+
|
84
|
+
STDERR.puts %(Cannot find gem for Rails ~>#{version}.0:
|
85
|
+
Install the missing gem with 'gem install -v=#{version} rails', or
|
86
|
+
change environment.rb to define RAILS_GEM_VERSION with your desired version.
|
87
|
+
)
|
88
|
+
|
89
|
+
=== Manually create meta files
|
90
|
+
|
91
|
+
* Bootstrap your project as usual, just don't run lazibi
|
92
|
+
|
93
|
+
* setup environment
|
94
|
+
|
95
|
+
mkdir .backup
|
96
|
+
mkdir meta
|
97
|
+
|
98
|
+
* run lazibi
|
99
|
+
|
100
|
+
* create .py.rb files in corresponding directories inside 'meta', .rb files will be created and updated in 'real' as usual
|
101
|
+
|
102
|
+
|
103
|
+
== Known issues
|
104
|
+
|
105
|
+
Here document like long strings are likely to screw up code generation, try
|
106
|
+
to indent long strings like the fix for rails
|
107
|
+
|
108
|
+
== To Do
|
109
|
+
|
110
|
+
* Here doc fix
|
111
|
+
* Two way sync between real and meta
|
112
|
+
* Erb for rhtml
|
113
|
+
|
114
|
+
== Author
|
115
|
+
* Jinjing (mailto:nfjinjing@gmail.com)
|
116
|
+
|
117
|
+
Released under the MIT license (included)
|
data/website/template.rhtml
CHANGED
@@ -37,7 +37,7 @@
|
|
37
37
|
</div>
|
38
38
|
<%= body %>
|
39
39
|
<p class="coda">
|
40
|
-
<a href="mailto:
|
40
|
+
<a href="mailto:nfjinjing@gmail.com">Jinjing</a>, <%= modified.pretty %><br>
|
41
41
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
42
42
|
</p>
|
43
43
|
</div>
|