bivouac 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +0 -0
- data/COPYING +0 -0
- data/README +14 -2
- data/bin/bivouac +0 -0
- data/examples/blog_erb/app/controllers/add.rb +19 -0
- data/examples/blog_erb/app/controllers/blog.rb +84 -0
- data/examples/blog_erb/app/controllers/comment.rb +9 -0
- data/examples/blog_erb/app/controllers/edit.rb +18 -0
- data/examples/blog_erb/app/controllers/index.rb +8 -0
- data/examples/blog_erb/app/controllers/info.rb +11 -0
- data/examples/blog_erb/app/controllers/login.rb +15 -0
- data/examples/blog_erb/app/controllers/logout.rb +8 -0
- data/examples/blog_erb/app/controllers/view.rb +9 -0
- data/examples/blog_erb/app/models/comment.rb +5 -0
- data/examples/blog_erb/app/models/post.rb +5 -0
- data/examples/blog_erb/app/models/user.rb +4 -0
- data/examples/blog_erb/app/views/add.html +18 -0
- data/examples/blog_erb/app/views/edit.html +18 -0
- data/examples/blog_erb/app/views/index.html +12 -0
- data/examples/blog_erb/app/views/layout.html +12 -0
- data/examples/blog_erb/app/views/login.html +2 -0
- data/examples/blog_erb/app/views/logout.html +2 -0
- data/examples/blog_erb/app/views/view.html +20 -0
- data/examples/blog_erb/config/environment.rb +27 -0
- data/examples/blog_erb/db/create.rb +8 -0
- data/examples/blog_erb/db/migrate/comment.rb +15 -0
- data/examples/blog_erb/db/migrate/post.rb +15 -0
- data/examples/blog_erb/db/migrate/user.rb +15 -0
- data/examples/blog_erb/log/Blog.log +112 -0
- data/examples/blog_erb/public/images/camping.png +0 -0
- data/examples/blog_erb/public/index.html +242 -0
- data/examples/blog_erb/public/stylesheets/style.css +10 -0
- data/examples/blog_erb/script/generate +3 -0
- data/examples/blog_erb/script/server +5 -0
- data/examples/blog_goh/app/controllers/add.rb +19 -0
- data/examples/blog_goh/app/controllers/blog.rb +76 -0
- data/examples/blog_goh/app/controllers/comment.rb +9 -0
- data/examples/blog_goh/app/controllers/edit.rb +18 -0
- data/examples/blog_goh/app/controllers/index.rb +8 -0
- data/examples/blog_goh/app/controllers/info.rb +11 -0
- data/examples/blog_goh/app/controllers/login.rb +15 -0
- data/examples/blog_goh/app/controllers/logout.rb +8 -0
- data/examples/blog_goh/app/controllers/view.rb +9 -0
- data/examples/blog_goh/app/models/comment.rb +5 -0
- data/examples/blog_goh/app/models/post.rb +5 -0
- data/examples/blog_goh/app/models/user.rb +4 -0
- data/examples/blog_goh/app/views/_form.rb +16 -0
- data/examples/blog_goh/app/views/_login.rb +13 -0
- data/examples/blog_goh/app/views/_post.rb +9 -0
- data/examples/blog_goh/app/views/add.rb +9 -0
- data/examples/blog_goh/app/views/edit.rb +9 -0
- data/examples/blog_goh/app/views/index.rb +12 -0
- data/examples/blog_goh/app/views/layout.rb +18 -0
- data/examples/blog_goh/app/views/login.rb +6 -0
- data/examples/blog_goh/app/views/logout.rb +6 -0
- data/examples/blog_goh/app/views/view.rb +20 -0
- data/examples/blog_goh/config/environment.rb +27 -0
- data/examples/blog_goh/db/create.rb +4 -0
- data/examples/blog_goh/db/migrate/comment.rb +15 -0
- data/examples/blog_goh/db/migrate/post.rb +15 -0
- data/examples/blog_goh/db/migrate/user.rb +15 -0
- data/examples/blog_goh/log/camping.log +19 -0
- data/examples/blog_goh/public/images/camping.png +0 -0
- data/examples/blog_goh/public/index.html +242 -0
- data/examples/blog_goh/public/stylesheets/style.css +10 -0
- data/examples/blog_goh/script/generate +3 -0
- data/examples/blog_goh/script/server +5 -0
- data/lib/bivouac/commands/generate.rb +87 -40
- data/lib/bivouac/commands/server.rb +0 -0
- data/lib/bivouac/template/application/postamble_cgi.rb +2 -2
- data/lib/bivouac/template/application/postamble_fastcgi.rb +2 -2
- data/lib/bivouac/template/application/postamble_mongrel.rb +0 -0
- data/lib/bivouac/template/application/postamble_none.rb +0 -0
- data/lib/bivouac/template/application/postamble_webrick.rb +2 -2
- data/lib/bivouac/template/application_erb.rb +3 -1
- data/lib/bivouac/template/application_goh.rb +1 -0
- data/lib/bivouac/template/application_jof.rb +5 -0
- data/lib/bivouac/template/environment.rb +0 -0
- data/lib/bivouac/template/generate/controller.rb +1 -1
- data/lib/bivouac/template/generate/create.rb +5 -1
- data/lib/bivouac/template/generate/migrate.rb +0 -0
- data/lib/bivouac/template/generate/model.rb +0 -0
- data/lib/bivouac/template/generate/view_erb.rb +2 -0
- data/lib/bivouac/template/generate/{view.rb → view_goh.rb} +0 -0
- data/lib/bivouac/template/generate.rb +0 -0
- data/lib/bivouac/template/server.rb +0 -0
- data/lib/bivouac/template/static/camping.png +0 -0
- data/lib/bivouac/template/static/index.html +0 -0
- data/lib/bivouac/template/static/index.rb +0 -0
- data/lib/bivouac/template.rb +0 -0
- data/lib/bivouac.rb +0 -0
- data/setup.rb +1585 -0
- data/test/test_bivouac.rb +0 -0
- data/test/test_template.rb +0 -0
- metadata +99 -14
- data/doc/created.rid +0 -1
- data/doc/files/AUTHORS.html +0 -95
- data/doc/files/COPYING.html +0 -519
- data/doc/files/README.html +0 -160
- data/doc/index.html +0 -10
- data/doc/permalink.gif +0 -0
- data/doc/rdoc-style.css +0 -106
- data/doc/rubyfr.png +0 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
module Blog::Models
|
2
|
+
class CreateUser < V 1.0
|
3
|
+
def self.up
|
4
|
+
create_table :blog_users do |t|
|
5
|
+
t.column :id , :integer , :null => false
|
6
|
+
t.column :username , :string
|
7
|
+
t.column :password , :string
|
8
|
+
end
|
9
|
+
User.create :username => 'admin', :password => 'bivouac'
|
10
|
+
end
|
11
|
+
def self.down
|
12
|
+
drop_table :blog_users
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Logfile created on Tue Jul 31 18:06:59 +0200 2007 by /
|
2
|
+
[4;36;1mSQL (0.000289)[0m [0;1mSELECT name FROM sqlite_master WHERE type = 'table'[0m
|
3
|
+
[4;35;1mSQL (0.000000)[0m [0mSQLite3::SQLException: no such table: sessions: DROP TABLE sessions[0m
|
4
|
+
[4;36;1mSQL (0.075142)[0m [0;1mCREATE TABLE sessions ("id" INTEGER PRIMARY KEY NOT NULL, "hashid" varchar(32) DEFAULT NULL, "created_at" datetime DEFAULT NULL, "ivars" text DEFAULT NULL) [0m
|
5
|
+
[4;35;1mSQL (0.000466)[0m [0mSELECT name FROM sqlite_master WHERE type = 'table'[0m
|
6
|
+
[4;36;1mSQL (0.000276)[0m [0;1mSELECT name FROM sqlite_master WHERE type = 'table'[0m
|
7
|
+
[4;35;1mSQL (0.056713)[0m [0mCREATE TABLE blog_schema_infos ("id" INTEGER PRIMARY KEY NOT NULL, "version" float DEFAULT NULL) [0m
|
8
|
+
[4;36;1mBlog::Models::SchemaInfo Load (0.000256)[0m [0;1mSELECT * FROM blog_schema_infos LIMIT 1[0m
|
9
|
+
[4;35;1mSQL (0.052790)[0m [0mCREATE TABLE blog_comments ("id" INTEGER PRIMARY KEY NOT NULL, "post_id" integer NOT NULL, "username" varchar(255) DEFAULT NULL, "body" text DEFAULT NULL) [0m
|
10
|
+
[4;36;1mSQL (0.064286)[0m [0;1mCREATE TABLE blog_posts ("id" INTEGER PRIMARY KEY NOT NULL, "user_id" integer NOT NULL, "title" varchar(255) DEFAULT NULL, "body" text DEFAULT NULL) [0m
|
11
|
+
[4;35;1mSQL (0.054837)[0m [0mCREATE TABLE blog_users ("id" INTEGER PRIMARY KEY NOT NULL, "username" varchar(255) DEFAULT NULL, "password" varchar(255) DEFAULT NULL) [0m
|
12
|
+
[4;36;1mSQL (0.000642)[0m [0;1mINSERT INTO blog_users ("username", "password") VALUES('admin', 'bivouac')[0m
|
13
|
+
[4;35;1mSQL (0.000488)[0m [0mINSERT INTO blog_schema_infos ("version") VALUES(1.0)[0m
|
14
|
+
[4;36;1mCamping::Models::Session Load (0.000347)[0m [0;1mSELECT * FROM sessions WHERE (sessions."hashid" = 'rfdZccdRGZpTif7vT2lwggt43wsHyGLi') LIMIT 1[0m
|
15
|
+
[4;35;1mSQL (0.000590)[0m [0mINSERT INTO sessions ("hashid", "created_at", "ivars") VALUES('embQk59C3ESMmQvAyXAwvYP3eBTDoegY', '2007-07-31 18:07:10', '--- !map:HashWithIndifferentAccess {}
|
16
|
+
|
17
|
+
')[0m
|
18
|
+
[4;36;1mBlog::Models::Post Load (0.000249)[0m [0;1mSELECT * FROM blog_posts [0m
|
19
|
+
[4;35;1mCamping::Models::Session Load (0.000529)[0m [0mSELECT * FROM sessions WHERE (sessions."hashid" = 'embQk59C3ESMmQvAyXAwvYP3eBTDoegY') LIMIT 1[0m
|
Binary file
|
@@ -0,0 +1,242 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
6
|
+
<title>Bivouac: Welcome aboard</title>
|
7
|
+
<style type="text/css" media="screen">
|
8
|
+
body {
|
9
|
+
margin: 0;
|
10
|
+
margin-bottom: 25px;
|
11
|
+
padding: 0;
|
12
|
+
background-color: #f0f0f0;
|
13
|
+
font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana";
|
14
|
+
font-size: 13px;
|
15
|
+
color: #333;
|
16
|
+
}
|
17
|
+
|
18
|
+
h1 {
|
19
|
+
font-size: 28px;
|
20
|
+
color: #000;
|
21
|
+
}
|
22
|
+
|
23
|
+
a {color: #03c}
|
24
|
+
a:hover {
|
25
|
+
background-color: #03c;
|
26
|
+
color: white;
|
27
|
+
text-decoration: none;
|
28
|
+
}
|
29
|
+
|
30
|
+
|
31
|
+
#page {
|
32
|
+
background-color: #f0f0f0;
|
33
|
+
width: 750px;
|
34
|
+
margin: 0;
|
35
|
+
margin-left: auto;
|
36
|
+
margin-right: auto;
|
37
|
+
}
|
38
|
+
|
39
|
+
#content {
|
40
|
+
float: left;
|
41
|
+
background-color: white;
|
42
|
+
border: 3px solid #aaa;
|
43
|
+
border-top: none;
|
44
|
+
padding: 25px;
|
45
|
+
width: 500px;
|
46
|
+
}
|
47
|
+
|
48
|
+
#sidebar {
|
49
|
+
float: right;
|
50
|
+
width: 175px;
|
51
|
+
}
|
52
|
+
|
53
|
+
#footer {
|
54
|
+
clear: both;
|
55
|
+
}
|
56
|
+
|
57
|
+
|
58
|
+
#header, #about, #getting-started {
|
59
|
+
padding-left: 75px;
|
60
|
+
padding-right: 30px;
|
61
|
+
}
|
62
|
+
|
63
|
+
|
64
|
+
#header {
|
65
|
+
background-image: url("images/camping.png");
|
66
|
+
background-repeat: no-repeat;
|
67
|
+
background-position: top right;
|
68
|
+
height: 100px;
|
69
|
+
}
|
70
|
+
#header h1, #header h2 {margin: 0}
|
71
|
+
#header h2 {
|
72
|
+
color: #888;
|
73
|
+
font-weight: normal;
|
74
|
+
font-size: 16px;
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
#about h3 {
|
79
|
+
margin: 0;
|
80
|
+
margin-bottom: 10px;
|
81
|
+
font-size: 14px;
|
82
|
+
}
|
83
|
+
|
84
|
+
#about-content {
|
85
|
+
background-color: #ffd;
|
86
|
+
border: 1px solid #fc0;
|
87
|
+
margin-left: -11px;
|
88
|
+
}
|
89
|
+
#about-content table {
|
90
|
+
margin-top: 10px;
|
91
|
+
margin-bottom: 10px;
|
92
|
+
font-size: 11px;
|
93
|
+
border-collapse: collapse;
|
94
|
+
}
|
95
|
+
#about-content td {
|
96
|
+
padding: 10px;
|
97
|
+
padding-top: 3px;
|
98
|
+
padding-bottom: 3px;
|
99
|
+
}
|
100
|
+
#about-content td.name {color: #555}
|
101
|
+
#about-content td.value {color: #000}
|
102
|
+
|
103
|
+
#about-content.failure {
|
104
|
+
background-color: #fcc;
|
105
|
+
border: 1px solid #f00;
|
106
|
+
}
|
107
|
+
#about-content.failure p {
|
108
|
+
margin: 0;
|
109
|
+
padding: 10px;
|
110
|
+
}
|
111
|
+
|
112
|
+
|
113
|
+
#getting-started {
|
114
|
+
border-top: 1px solid #ccc;
|
115
|
+
margin-top: 25px;
|
116
|
+
padding-top: 15px;
|
117
|
+
}
|
118
|
+
#getting-started h1 {
|
119
|
+
margin: 0;
|
120
|
+
font-size: 20px;
|
121
|
+
}
|
122
|
+
#getting-started h2 {
|
123
|
+
margin: 0;
|
124
|
+
font-size: 14px;
|
125
|
+
font-weight: normal;
|
126
|
+
color: #333;
|
127
|
+
margin-bottom: 25px;
|
128
|
+
}
|
129
|
+
#getting-started ol {
|
130
|
+
margin-left: 0;
|
131
|
+
padding-left: 0;
|
132
|
+
}
|
133
|
+
#getting-started li {
|
134
|
+
font-size: 18px;
|
135
|
+
color: #888;
|
136
|
+
margin-bottom: 25px;
|
137
|
+
}
|
138
|
+
#getting-started li h2 {
|
139
|
+
margin: 0;
|
140
|
+
font-weight: normal;
|
141
|
+
font-size: 18px;
|
142
|
+
color: #333;
|
143
|
+
}
|
144
|
+
#getting-started li p {
|
145
|
+
color: #555;
|
146
|
+
font-size: 13px;
|
147
|
+
}
|
148
|
+
|
149
|
+
|
150
|
+
#search {
|
151
|
+
margin: 0;
|
152
|
+
padding-top: 10px;
|
153
|
+
padding-bottom: 10px;
|
154
|
+
font-size: 11px;
|
155
|
+
}
|
156
|
+
#search input {
|
157
|
+
font-size: 11px;
|
158
|
+
margin: 2px;
|
159
|
+
}
|
160
|
+
#search-text {width: 170px}
|
161
|
+
|
162
|
+
|
163
|
+
#sidebar ul {
|
164
|
+
margin-left: 0;
|
165
|
+
padding-left: 0;
|
166
|
+
}
|
167
|
+
#sidebar ul h3 {
|
168
|
+
margin-top: 25px;
|
169
|
+
font-size: 16px;
|
170
|
+
padding-bottom: 10px;
|
171
|
+
border-bottom: 1px solid #ccc;
|
172
|
+
}
|
173
|
+
#sidebar li {
|
174
|
+
list-style-type: none;
|
175
|
+
}
|
176
|
+
#sidebar ul.links li {
|
177
|
+
margin-bottom: 5px;
|
178
|
+
}
|
179
|
+
|
180
|
+
</style>
|
181
|
+
</head>
|
182
|
+
<body>
|
183
|
+
<div id="page">
|
184
|
+
<div id="sidebar">
|
185
|
+
<ul id="sidebar-items">
|
186
|
+
<li>
|
187
|
+
<form id="search" action="http://www.google.com/search" method="get">
|
188
|
+
<input type="hidden" name="hl" value="en" />
|
189
|
+
<input type="text" id="search-text" name="q" value="site:code.whytheluckystiff.net/camping " />
|
190
|
+
<input type="submit" value="Search" /> the Camping site
|
191
|
+
</form>
|
192
|
+
</li>
|
193
|
+
|
194
|
+
<li>
|
195
|
+
<h3>Join the community</h3>
|
196
|
+
<ul class="links">
|
197
|
+
<li><a href="http://redhanded.hobix.com/bits/campingAMicroframework.html">Camping</a></li>
|
198
|
+
<li><a href="http://code.whytheluckystiff.net/camping">Wiki</a></li>
|
199
|
+
<li><a href="http://code.whytheluckystiff.net/camping/browser/">Code</a></li>
|
200
|
+
<li><a href="http://code.whytheluckystiff.net/camping/report/1">Bug tracker</a></li>
|
201
|
+
</ul>
|
202
|
+
</li>
|
203
|
+
|
204
|
+
<li>
|
205
|
+
<h3>Browse the documentation</h3>
|
206
|
+
<ul class="links">
|
207
|
+
<li><a href="http://camping.rubyforge.org/files/README.html">Camping API</a></li>
|
208
|
+
<li><a href="http://stdlib.rubyonrails.org/">Ruby standard library</a></li>
|
209
|
+
<li><a href="http://corelib.rubyonrails.org/">Ruby core</a></li>
|
210
|
+
</ul>
|
211
|
+
</li>
|
212
|
+
</ul>
|
213
|
+
</div>
|
214
|
+
|
215
|
+
<div id="content">
|
216
|
+
<div id="header">
|
217
|
+
<h1>Welcome aboard</h1>
|
218
|
+
<h2>You can now go in the tent!</h2>
|
219
|
+
</div>
|
220
|
+
|
221
|
+
<div id="getting-started">
|
222
|
+
<h1>Getting started</h1>
|
223
|
+
<h2>Here’s how to get rolling:</h2>
|
224
|
+
|
225
|
+
<ol>
|
226
|
+
<li>
|
227
|
+
<h2>Use <tt>script/generate</tt> to create your models and controllers</h2>
|
228
|
+
<p>To see all available options, run it without parameters.</p>
|
229
|
+
</li>
|
230
|
+
|
231
|
+
<li>
|
232
|
+
<h2>That's all folks...</h2>
|
233
|
+
<p>...time for barbecue!</p>
|
234
|
+
</li>
|
235
|
+
</ol>
|
236
|
+
</div>
|
237
|
+
</div>
|
238
|
+
|
239
|
+
<div id="footer"> </div>
|
240
|
+
</div>
|
241
|
+
</body>
|
242
|
+
</html>
|
@@ -3,6 +3,8 @@
|
|
3
3
|
# (c)2007 Grégoire Lejeune
|
4
4
|
|
5
5
|
require 'rubygems'
|
6
|
+
require 'optparse'
|
7
|
+
require 'ostruct'
|
6
8
|
require 'bivouac/template'
|
7
9
|
require 'active_support'
|
8
10
|
require File.dirname($0) + '/../config/environment.rb'
|
@@ -12,39 +14,97 @@ module Bivouac
|
|
12
14
|
include Bivouac::Template
|
13
15
|
|
14
16
|
def initialize( argv )
|
15
|
-
@
|
16
|
-
# if @script_arguments.include?( '-h' ) or @script_arguments.include?( '--help' )
|
17
|
-
# help( )
|
18
|
-
# exit
|
19
|
-
# end
|
17
|
+
@generator_type = argv.shift
|
20
18
|
|
21
|
-
@
|
22
|
-
@
|
19
|
+
@options = OpenStruct.new( :noview => false, :default_route => true, :routes => [] )
|
20
|
+
@opts = OptionParser.new do |opts|
|
21
|
+
opts.banner = "Usage: script/generate generator [options] [args]"
|
22
|
+
|
23
|
+
opts.separator ""
|
24
|
+
opts.separator "Generators"
|
25
|
+
opts.separator " Builtin: controller, model, migrate, view"
|
26
|
+
|
27
|
+
opts.separator ""
|
28
|
+
opts.separator "controller generator options:"
|
29
|
+
opts.on("-v", "--no-view", "Do not generate any view for the controller") { |@options.noview|
|
30
|
+
if @generator_type != 'controller'
|
31
|
+
puts @opts
|
32
|
+
exit
|
33
|
+
end
|
34
|
+
@options.noview = true
|
35
|
+
}
|
36
|
+
opts.on("-d", "--no-route", "Do not add the default route to the controller (/controller_name)") { |@options.default_route|
|
37
|
+
if @generator_type != 'controller'
|
38
|
+
puts @opts
|
39
|
+
exit
|
40
|
+
end
|
41
|
+
@options.default_route = false
|
42
|
+
}
|
43
|
+
opts.on("-r", "--route ROUTE,ROUTE,...", "Add ROUTES to the controller") { |routes|
|
44
|
+
if @generator_type != 'controller'
|
45
|
+
puts @opts
|
46
|
+
exit
|
47
|
+
end
|
48
|
+
@options.routes = routes.split(',')
|
49
|
+
}
|
50
|
+
|
51
|
+
opts.separator ""
|
52
|
+
opts.separator "Common options:"
|
53
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
54
|
+
puts opts
|
55
|
+
exit
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
if ['-h', '--help'].include?( @generator_type )
|
60
|
+
puts @opts
|
61
|
+
exit
|
62
|
+
end
|
23
63
|
|
24
|
-
@
|
25
|
-
|
26
|
-
|
27
|
-
|
64
|
+
@opts.parse! argv
|
65
|
+
if argv.length < 1
|
66
|
+
puts @opts
|
67
|
+
exit
|
68
|
+
end
|
69
|
+
|
70
|
+
@script_arguments = argv.dup
|
28
71
|
|
29
|
-
@
|
72
|
+
@app = Bivouac::Environment.new( )
|
73
|
+
@generation_app_name = @app.environment.appname
|
74
|
+
@generation_type = @app.environment.orgtype
|
30
75
|
end
|
31
76
|
|
32
77
|
def run
|
33
|
-
|
78
|
+
@script_arguments.each do |@generation_name|
|
79
|
+
@generation_class_name = @generation_name.classify
|
80
|
+
@generation_file_name = @generation_class_name.underscore
|
81
|
+
send( @generator_type.to_sym )
|
82
|
+
end
|
34
83
|
end
|
35
84
|
|
36
85
|
private
|
37
86
|
def controller
|
87
|
+
@destination_file = File.dirname( $0 ) + "/../app/" + @generator_type.pluralize + "/" + @generation_file_name.underscore + ".rb"
|
38
88
|
@generation_view_name = @generation_class_name.underscore
|
89
|
+
|
90
|
+
default_route = '/' + @generation_view_name
|
91
|
+
@options.routes << default_route if @options.default_route and @options.routes.include?( default_route ) == false
|
92
|
+
@generation_routes = if @options.routes.size > 0
|
93
|
+
" < R '" + @options.routes.join("', '") + "'"
|
94
|
+
else
|
95
|
+
""
|
96
|
+
end
|
97
|
+
|
39
98
|
createFile( @destination_file ) do |io|
|
40
99
|
io.puts template( "generate/controller", binding )
|
41
100
|
end
|
42
101
|
|
43
|
-
view( )
|
102
|
+
view( ) if @options.noview == false
|
44
103
|
end
|
45
104
|
|
46
105
|
def migrate
|
47
|
-
@generation_table_name = (@
|
106
|
+
@generation_table_name = (@generation_class_name.downcase + "_" + @generation_name).tableize
|
107
|
+
|
48
108
|
@destination_file = File.dirname( $0 ) + "/../db/migrate/" + @generation_file_name.underscore + ".rb"
|
49
109
|
createFile( @destination_file ) do |io|
|
50
110
|
io.puts template( "generate/migrate", binding )
|
@@ -57,6 +117,7 @@ module Bivouac
|
|
57
117
|
end
|
58
118
|
|
59
119
|
def model
|
120
|
+
@destination_file = File.dirname( $0 ) + "/../app/" + @generator_type.pluralize + "/" + @generation_file_name.underscore + ".rb"
|
60
121
|
createFile( @destination_file ) do |io|
|
61
122
|
io.puts template( "generate/model", binding )
|
62
123
|
end
|
@@ -64,35 +125,21 @@ module Bivouac
|
|
64
125
|
migrate( )
|
65
126
|
end
|
66
127
|
|
67
|
-
def view
|
68
|
-
|
69
|
-
|
70
|
-
|
128
|
+
def view
|
129
|
+
if @generation_type.downcase == "erb"
|
130
|
+
@destination_file = File.dirname( $0 ) + "/../app/views/" + @generation_file_name.underscore + ".html"
|
131
|
+
else
|
132
|
+
@destination_file = File.dirname( $0 ) + "/../app/views/" + @generation_file_name.underscore + ".rb"
|
71
133
|
end
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
return @script_arguments.shift
|
77
|
-
rescue
|
78
|
-
help( )
|
79
|
-
exit
|
134
|
+
|
135
|
+
@generation_view_name = @generation_class_name.underscore
|
136
|
+
createFile( @destination_file ) do |io|
|
137
|
+
io.puts template( "generate/view_#{@generation_type.downcase}", binding )
|
80
138
|
end
|
81
139
|
end
|
82
140
|
|
83
|
-
def help
|
84
|
-
puts <<-'END_PRODUCT'.gsub(/^\s+/, "")
|
85
|
-
Usage: script/generate generator [args]
|
86
|
-
|
87
|
-
Bivouac Info:
|
88
|
-
-h, --help Show this help message and quit.
|
89
|
-
|
90
|
-
Generators
|
91
|
-
Builtin: controller, model, migrate
|
92
|
-
END_PRODUCT
|
93
|
-
end
|
94
|
-
|
95
141
|
end
|
96
142
|
end
|
97
143
|
|
98
|
-
|
144
|
+
|
145
|
+
Bivouac::Generate.new( ARGV ).run( )
|
File without changes
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# CGI postamble
|
2
2
|
|
3
3
|
if __FILE__ == $0
|
4
|
-
<%= @appname %>::Models::Base.establish_connection :adapter => 'sqlite3', :database =>
|
5
|
-
<%= @appname %>::Models::Base.logger = Logger.new(File.dirname(__FILE__) + "/../../log
|
4
|
+
<%= @appname %>::Models::Base.establish_connection :adapter => 'sqlite3', :database => File.dirname(__FILE__) + "/../../db/<%= @appname %>.db"
|
5
|
+
<%= @appname %>::Models::Base.logger = Logger.new(File.dirname(__FILE__) + "/../../log/<%= @appname %>.log")
|
6
6
|
<%= @appname %>.create if <%= @appname %>.respond_to? :create
|
7
7
|
puts <%= @appname %>.run
|
8
8
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# FastCGI postamble
|
2
2
|
if __FILE__ == $0
|
3
3
|
require 'camping/fastcgi'
|
4
|
-
<%= @appname %>::Models::Base.establish_connection :adapter => 'sqlite3', :database =>
|
5
|
-
<%= @appname %>::Models::Base.logger = Logger.new(File.dirname(__FILE__) + "/../../log
|
4
|
+
<%= @appname %>::Models::Base.establish_connection :adapter => 'sqlite3', :database => File.dirname(__FILE__) + "/../../db/<%= @appname %>.db"
|
5
|
+
<%= @appname %>::Models::Base.logger = Logger.new(File.dirname(__FILE__) + "/../../log/<%= @appname %>.log")
|
6
6
|
<%= @appname %>.create if <%= @appname %>.respond_to? :create
|
7
7
|
Camping::FastCGI.start(<%= @appname %>)
|
8
8
|
end
|
File without changes
|
File without changes
|
@@ -3,8 +3,8 @@ if __FILE__ == $0
|
|
3
3
|
require 'webrick/httpserver'
|
4
4
|
require 'camping/webrick'
|
5
5
|
|
6
|
-
<%= @appname %>::Models::Base.establish_connection :adapter => 'sqlite3', :database =>
|
7
|
-
<%= @appname %>::Models::Base.logger = Logger.new(File.dirname(__FILE__) + "/../../log
|
6
|
+
<%= @appname %>::Models::Base.establish_connection :adapter => 'sqlite3', :database => File.dirname(__FILE__) + "/../../db/<%= @appname %>.db"
|
7
|
+
<%= @appname %>::Models::Base.logger = Logger.new(File.dirname(__FILE__) + "/../../log/<%= @appname %>.log")
|
8
8
|
<%= @appname %>.create if <%= @appname %>.respond_to? :create
|
9
9
|
s = WEBrick::HTTPServer.new :BindAddress => "0.0.0.0", :Port => 3301
|
10
10
|
s.mount "/", WEBrick::CampingHandler, <%= @appname %>
|
@@ -9,6 +9,8 @@
|
|
9
9
|
|
10
10
|
require 'rubygems'
|
11
11
|
require 'camping'
|
12
|
+
require 'camping/session'
|
13
|
+
require 'mime/types'
|
12
14
|
require 'bivouac'
|
13
15
|
|
14
16
|
include Bivouac
|
@@ -16,7 +18,7 @@ include Bivouac
|
|
16
18
|
begin
|
17
19
|
require 'erubis'
|
18
20
|
ERB = Erubis::Eruby
|
19
|
-
rescue
|
21
|
+
rescue MissingSourceFile
|
20
22
|
require 'erb'
|
21
23
|
end
|
22
24
|
|
@@ -9,9 +9,14 @@
|
|
9
9
|
|
10
10
|
require 'rubygems'
|
11
11
|
require 'camping'
|
12
|
+
require 'camping/session'
|
12
13
|
|
13
14
|
Camping.goes :<%= @appname %>
|
14
15
|
|
16
|
+
# module <%= @appname %>
|
17
|
+
# include Camping::Session
|
18
|
+
# end
|
19
|
+
|
15
20
|
module <%= @appname %>::Helpers
|
16
21
|
# Add your helpers here !
|
17
22
|
end
|
File without changes
|
@@ -1,4 +1,8 @@
|
|
1
|
+
module <%= @generation_app_name %>
|
2
|
+
include Camping::Session
|
3
|
+
end
|
4
|
+
|
1
5
|
def <%= @generation_app_name %>.create
|
2
6
|
Camping::Models::Session.create_schema
|
3
|
-
<%= @generation_app_name %>::Models.create_schema :assume => (<%= @generation_app_name %>::Models
|
7
|
+
<%= @generation_app_name %>::Models.create_schema :assume => (<%= @generation_app_name %>::Models::<%= @generation_class_name %>.table_exists? ? 1.0 : 0.0)
|
4
8
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/bivouac/template.rb
CHANGED
File without changes
|
data/lib/bivouac.rb
CHANGED
File without changes
|