bivouac 0.1.6 → 0.2.0

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.
Files changed (30) hide show
  1. data/README +7 -0
  2. data/bin/bivouac +23 -8
  3. data/doc/rdoc/created.rid +1 -1
  4. data/doc/rdoc/files/README.html +19 -1
  5. data/lib/bivouac/commands/generate.rb +251 -169
  6. data/lib/bivouac/commands/plugin.rb +31 -4
  7. data/lib/bivouac/template/Rakefile.rb +10 -4
  8. data/lib/bivouac/template/application/helpers_goh.rb +2 -2
  9. data/lib/bivouac/template/application/postamble.rb +21 -19
  10. data/lib/bivouac/template/application_goh.rb +6 -4
  11. data/lib/bivouac/template/environment.rb +1 -1
  12. data/lib/bivouac/template/generate/controller.rb +11 -4
  13. data/lib/bivouac/template/generate/create.rb +10 -4
  14. data/lib/bivouac/template/generate/migrate.rb +11 -4
  15. data/lib/bivouac/template/generate/migration.rb +9 -2
  16. data/lib/bivouac/template/generate/model.rb +9 -2
  17. data/lib/bivouac/template/generate/test_begin.rb +11 -4
  18. data/lib/bivouac/template/generate/view_goh.rb +11 -4
  19. data/lib/bivouac/template/generate.rb +6 -0
  20. data/lib/bivouac/template/static/README +0 -0
  21. data/lib/bivouac/template/static/index.rb +8 -1
  22. data/lib/bivouac/template.rb +7 -2
  23. data/lib/bivouac/utils.rb +11 -0
  24. metadata +4 -8
  25. data/lib/bivouac/template/generate/scaffold_controller_create.rb +0 -15
  26. data/lib/bivouac/template/generate/scaffold_controller_list.rb +0 -8
  27. data/lib/bivouac/template/generate/scaffold_controller_view.rb +0 -14
  28. data/lib/bivouac/template/generate/scaffold_view_create_goh.rb +0 -11
  29. data/lib/bivouac/template/generate/scaffold_view_list_goh.rb +0 -11
  30. data/lib/bivouac/template/generate/scaffold_view_view_goh.rb +0 -14
data/README CHANGED
@@ -12,6 +12,13 @@ Bivouac is a simple generator for camping[http://code.whytheluckystiff.net/campi
12
12
 
13
13
  == FEATURES/PROBLEMS:
14
14
 
15
+ === 0.2.0:
16
+ * Class Bivouac::Generate has been completely rewritten
17
+ * Scaffold generator is no longer un Bivouac Core, use scaffold_s_tent plugin
18
+ * Add Generator plugins support
19
+ * iUI's Tent Plugin (alpha-2)
20
+ * Add Scaffols's Tent Plugin
21
+
15
22
  === 0.1.6:
16
23
  * Plugins now support Rake tasks
17
24
  * Add plugin:list task
data/bin/bivouac CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  =begin
3
3
  bivouac
4
- (c)2007 Grégoire Lejeune
4
+ (c)2007, 2008 Grégoire Lejeune
5
5
  =end
6
6
 
7
7
  require 'rubygems'
@@ -13,6 +13,7 @@ require 'fileutils'
13
13
  require 'bivouac/template'
14
14
  include Bivouac::Template
15
15
 
16
+ # Default configuration
16
17
  database_configuration = {
17
18
  :adapter => "sqlite3"
18
19
  }
@@ -51,14 +52,10 @@ opts = OptionParser.new do |opts|
51
52
 
52
53
  @conf.db = "{\n\t:adapter => '#{dbtype}'\n\t:database => 'db/bivouac.db'\n}"
53
54
  }
55
+
54
56
  opts.on("-P", "--port PORT", "Which port to bind to (3301)") { |@conf.port| }
57
+
55
58
  opts.on("-a", "--address ADDR", "Address to bind to (0.0.0.0)") { |@conf.address| }
56
- # opts.on("-o", "--organize TYPE", "Type or organisation (options: JOF:Just On File/GOH:Get Out of Hand/ERB:use Eruby or Erb)") { |@conf.orgtype|
57
- # unless %w{jof goh erb}.include?( @conf.orgtype.downcase )
58
- # puts opts
59
- # exit
60
- # end
61
- # }
62
59
 
63
60
  opts.separator ""
64
61
  opts.separator "Common options:"
@@ -78,17 +75,22 @@ opts = OptionParser.new do |opts|
78
75
  end
79
76
  end
80
77
 
78
+ # Parse options
81
79
  opts.parse! ARGV
82
80
  if ARGV.length < 1
83
81
  puts opts
84
82
  exit
85
83
  end
86
84
 
85
+ # Get APP name
87
86
  name = ARGV.dup
88
87
 
88
+ # Add APP name to config
89
89
  @conf.appname = name[0].classify
90
+ # Add APP path to config
90
91
  @conf.appdir = @conf.appname.underscore
91
92
 
93
+ # Add DataBase configuration to config
92
94
  if database_configuration[:adapter] =~ /sqlite/
93
95
  database_configuration[:database] = "db/" + @conf.appdir + ".db"
94
96
  else
@@ -96,8 +98,9 @@ else
96
98
  end
97
99
  @conf.db = database_configuration.inspect
98
100
 
99
- @appname = @conf.appname
101
+ ## REMOVE ME ## ---------------- @appname = @conf.appname
100
102
 
103
+ # Create Application Directories
101
104
  createDir( @conf.appdir )
102
105
  createDir( "#{@conf.appdir}/config" )
103
106
  createDir( "#{@conf.appdir}/app" )
@@ -117,48 +120,60 @@ createDir( "#{@conf.appdir}/test" )
117
120
  createDir( "#{@conf.appdir}/lib" )
118
121
  createDir( "#{@conf.appdir}/plugins" )
119
122
 
123
+ # Create Application Environment file
120
124
  createFile( "#{@conf.appdir}/config/environment.rb" ) { |io|
121
125
  io.puts template( "environment" )
122
126
  }
123
127
 
128
+ # Create Application Postamble file
124
129
  createFile( "#{@conf.appdir}/config/postamble.rb" ) { |io|
125
130
  io.puts template( "application/postamble" )
126
131
  }
127
132
 
133
+ # Create Application file
128
134
  createFile( "#{@conf.appdir}/app/#{@conf.appdir}.rb" ) { |io|
129
135
  io.puts template( "application_#{@conf.orgtype.downcase}" )
130
136
  }
131
137
 
138
+ # Create Application Helpers Loader file
132
139
  createFile( "#{@conf.appdir}/app/helpers/_helpers.rb" ) { |io|
133
140
  io.puts template( "application/helpers_#{@conf.orgtype.downcase}" )
134
141
  }
135
142
 
143
+ # Create generate script
136
144
  createFile( "#{@conf.appdir}/script/generate", true ) { |io|
137
145
  io.puts template( "generate" )
138
146
  }
139
147
 
148
+ # Create server script
140
149
  createFile( "#{@conf.appdir}/script/server", true ) { |io|
141
150
  io.puts template( "server" )
142
151
  }
143
152
 
153
+ # Create console script
144
154
  createFile( "#{@conf.appdir}/script/console", true ) { |io|
145
155
  io.puts template( "console" )
146
156
  }
147
157
 
158
+ # Create plugin script
148
159
  createFile( "#{@conf.appdir}/script/plugin", true ) { |io|
149
160
  io.puts template( "plugin" )
150
161
  }
151
162
 
163
+ # Create Rakefile
152
164
  createFile( "#{@conf.appdir}/Rakefile", true ) { |io|
153
165
  io.puts template( "Rakefile" )
154
166
  }
155
167
 
168
+ # Copy statics files
156
169
  copyTemplate( "static/index.html", "#{@conf.appdir}/public" )
157
170
  copyTemplate( "static/camping.png", "#{@conf.appdir}/public/images" )
158
171
  %w{builder.js dragdrop.js prototype.js slider.js unittest.js controls.js effects.js sound.js scriptaculous.js}.each do |f|
159
172
  copyTemplate( "static/#{f}", "#{@conf.appdir}/public/javascripts" )
160
173
  end
161
174
  copyTemplate( "static/autocomplete.css", "#{@conf.appdir}/public/stylesheets" )
175
+
176
+ # Create index controller
162
177
  createFile( "#{@conf.appdir}/app/controllers/index.rb" ) { |io|
163
178
  io.puts template( "static/index" )
164
179
  }
data/doc/rdoc/created.rid CHANGED
@@ -1 +1 @@
1
- Mon, 24 Mar 2008 04:25:25 +0100
1
+ Mon, 31 Mar 2008 12:46:54 +0200
@@ -87,7 +87,7 @@ end</strong>
87
87
  <div id="README" class="page_shade">
88
88
  <div class="page">
89
89
  <div class="header">
90
- <div class="path">README / Mon Mar 24 04:25:10 +0100 2008</div>
90
+ <div class="path">README / Mon Mar 31 12:12:43 +0200 2008</div>
91
91
  </div>
92
92
 
93
93
  <h1>Bivouac</h1>
@@ -112,6 +112,24 @@ Bivouac is a simple generator for <a
112
112
  href="http://code.whytheluckystiff.net/camping">camping</a>.
113
113
  </p>
114
114
  <h2>FEATURES/PROBLEMS:</h2>
115
+ <h3>0.2.0:</h3>
116
+ <ul>
117
+ <li>Class Bivouac::Generate has been completely rewritten
118
+
119
+ </li>
120
+ <li>Scaffold generator is no longer un Bivouac Core, use scaffold_s_tent plugin
121
+
122
+ </li>
123
+ <li>Add Generator plugins support
124
+
125
+ </li>
126
+ <li>iUI&#8216;s Tent Plugin (alpha-2)
127
+
128
+ </li>
129
+ <li>Add Scaffols&#8216;s Tent Plugin
130
+
131
+ </li>
132
+ </ul>
115
133
  <h3>0.1.6:</h3>
116
134
  <ul>
117
135
  <li>Plugins now support Rake tasks
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
- # bivouac - 0.0.1
3
- # (c)2007 Grégoire Lejeune
2
+ # bivouac
3
+ # (c)2007, 2008 Grégoire Lejeune
4
4
 
5
5
  require 'rubygems'
6
6
  require 'optparse'
7
7
  require 'ostruct'
8
8
  require 'bivouac/template'
9
+ require 'bivouac/utils'
9
10
  require 'active_support'
10
11
  require 'active_record'
11
12
  require 'find'
@@ -14,128 +15,278 @@ require File.dirname($0) + '/../config/environment.rb'
14
15
  module Bivouac
15
16
  class Generate
16
17
  include Bivouac::Template
18
+ # Initialize the optionnal generators table
19
+ add_generator []
17
20
 
18
21
  def initialize( argv )
19
22
  # Generator type (controller, model, migration, view, ...)
20
23
  @generator_type = argv.shift
21
24
 
22
- # Generator options
23
- @options = OpenStruct.new( :noview => false, :notest => false, :default_route => true, :routes => [] )
24
- @opts = OptionParser.new do |opts|
25
- opts.banner = "Usage: script/generate generator [options] [args]"
26
-
27
- opts.separator ""
28
- opts.separator "Generators"
29
- opts.separator " Builtin: controller, model, migration, view, test, scaffold"
30
-
31
- opts.separator ""
25
+ # Display help if asked
26
+ if ['-h', '--help'].include?( @generator_type )
27
+ help
28
+ exit
29
+ end
30
+
31
+ # Generator arguments.
32
+ # Example :
33
+ # script/generate controller Hello World
34
+ # @script_arguments = ['Hello', 'World']
35
+ @script_arguments = argv.dup
36
+
37
+ # Application environment
38
+ @app = Bivouac::Environment.new( )
39
+
40
+ # Database configuration
41
+ @database_configuration = @app.environment.db
42
+ if @database_configuration[:adapter] =~ /sqlite/
43
+ @database_configuration[:database] = File.expand_path( File.dirname( $0 ) + "/../" + @database_configuration[:database] )
44
+ end
45
+ end
46
+
47
+ def run
48
+ # If the générator is not installed, display help and exit
49
+ unless ( ["controller", "model", "migration", "view", "test"] + @@plugins_generators ).include?( @generator_type )
50
+ help
51
+ exit
52
+ end
53
+
54
+ # Call generator
55
+ send( @generator_type.to_sym )
56
+ return
57
+ end
58
+
59
+ private
60
+ def help
61
+ puts "Usage: script/generate generator [options] [args]"
62
+ puts ""
63
+ puts "Generators"
64
+ puts " Builtin: controller, model, migration, view, test"
65
+ puts " Plugins: " + @@plugins_generators.join(", ") if @@plugins_generators.size > 0
66
+ puts ""
67
+ puts "Commun options:"
68
+ puts " -h, --help Show general help message"
69
+ end
70
+
71
+ def controller
72
+ # controller generator options
73
+ controller_options = OpenStruct.new( :noview => false, :notest => false, :default_route => true, :routes => [] )
74
+
75
+ # Controller options
76
+ argument_options = OptionParser.new do |opts|
77
+ opts.banner = ""
32
78
  opts.separator "controller generator options:"
33
- opts.on("-v", "--no-view", "Do not generate any view for the controller") { |@options.noview|
34
- if @generator_type != 'controller'
35
- puts @opts
36
- exit
37
- end
38
- @options.noview = true
79
+ opts.on("-v", "--no-view", "Do not generate any view for the controller") { |controller_options.noview|
80
+ controller_options.noview = true
39
81
  }
40
- opts.on("-d", "--no-route", "Do not add the default route to the controller (/controller_name)") { |@options.default_route|
41
- if @generator_type != 'controller'
42
- puts @opts
43
- exit
44
- end
45
- @options.default_route = false
82
+ opts.on("-d", "--no-route", "Do not add the default route to the controller (/controller_name)") { |controller_options.default_route|
83
+ controller_options.default_route = false
46
84
  }
47
85
  opts.on("-r", "--route ROUTE,ROUTE,...", "Add ROUTES to the controller") { |routes|
48
- if @generator_type != 'controller'
49
- puts @opts
50
- exit
51
- end
52
- @options.routes = routes.split(',')
86
+ controller_options.routes = routes.split(',')
53
87
  }
54
- opts.on("-t", "--no-test", "Do not generate any test for the controller") { |@options.notest|
55
- if @generator_type != 'controller'
56
- puts @opts
57
- exit
58
- end
59
- @options.notest = true
88
+ opts.on("-t", "--no-test", "Do not generate any test for the controller") { |controller_options.notest|
89
+ controller_options.notest = true
60
90
  }
61
91
 
62
92
  opts.separator ""
63
- opts.separator "Common options:"
64
93
  opts.on_tail("-h", "--help", "Show this message") do
94
+ help
65
95
  puts opts
66
96
  exit
67
97
  end
68
98
  end
69
-
70
- if ['-h', '--help'].include?( @generator_type )
71
- puts @opts
72
- exit
73
- end
74
99
 
75
100
  # parse options
76
- @opts.parse! argv
77
- if argv.length < 1
78
- puts @opts
79
- exit
101
+ argument_options.parse! @script_arguments
102
+ if @script_arguments.length < 1
103
+ help
104
+ puts argument_options
105
+ exit
80
106
  end
81
107
 
82
- # Generator arguments.
83
- # Example :
84
- # script/generate controller Hello World
85
- # @script_arguments = ['Hello', 'World']
86
- @script_arguments = argv.dup
87
-
88
- # Application environment
89
- @app = Bivouac::Environment.new( )
108
+ @script_arguments.each do |controller_name|
109
+ # Controller class name, passed to the template
110
+ @controller_class_name = controller_name.classify
111
+ # File name for the template
112
+ controller_file_name = @controller_class_name.underscore
113
+
114
+ # Destination file
115
+ destination_file = File.dirname( $0 ) + "/../app/controllers/" + controller_file_name + ".rb"
116
+
117
+ # Set view name, passed to the template
118
+ @view_name = @controller_class_name.underscore
119
+
120
+ # Set routes, passed to the template
121
+ default_route = @view_name
122
+ controller_options.routes << default_route if controller_options.default_route and controller_options.routes.include?( default_route ) == false
123
+ @controller_routes = if controller_options.routes.size > 0
124
+ " < R '/" + controller_options.routes.join("', '/") + "'"
125
+ else
126
+ ""
127
+ end
128
+
129
+ # Create controller
130
+ createFile( destination_file ) do |io|
131
+ io.puts template( "generate/controller", binding )
132
+ end
133
+
134
+ # Create view @view_name
135
+ view( @view_name ) if controller_options.noview == false
136
+
137
+ # Create test for @view_name with routes controller_options.routes
138
+ test( @view_name, controller_options.routes ) if controller_options.notest == false
139
+ end
140
+ end
141
+
142
+ def view( view_name = nil )
143
+ if @app.environment.orgtype.downcase == "erb"
144
+ raise "ERB applications are no longer supported. Sorry!"
145
+ end
90
146
 
91
- # Application name for the generator, passed to the template
92
- @generation_app_name = @app.environment.appname
147
+ # View options
148
+ argument_options = OptionParser.new do |opts|
149
+ opts.banner = ""
150
+ opts.separator "view generator options:"
151
+ opts.on_tail("-h", "--help", "Show this message") do
152
+ help
153
+ puts opts
154
+ exit
155
+ end
156
+ end
93
157
 
94
- @generation_app_dir = @app.environment.appdir
158
+ # parse options if view name is not passed
159
+ if view_name.nil?
160
+ argument_options.parse! @script_arguments
161
+ if @script_arguments.length < 1
162
+ help
163
+ puts argument_options
164
+ exit
165
+ end
166
+
167
+ view_name = @script_arguments
168
+ else
169
+ view_name = [ view_name ]
170
+ end
95
171
 
96
- # Application organisation (goh, jof or erb)
97
- @generation_type = @app.environment.orgtype
172
+ view_name.each do |view|
173
+ # Set view name, passed to the template
174
+ @view_name = view.underscore
175
+
176
+ # Set destination file, passed to the template
177
+ @destination_file = File.dirname( $0 ) + "/../app/views/" + @view_name.underscore + ".rb"
98
178
 
99
- # Database configuration
100
- @database_configuration = @app.environment.db
101
- if @database_configuration[:adapter] =~ /sqlite/
102
- @database_configuration[:database] = File.expand_path( File.dirname( $0 ) + "/../" + @database_configuration[:database] )
179
+ # Create view file
180
+ createFile( @destination_file ) do |io|
181
+ io.puts template( "generate/view_goh", binding )
182
+ end
103
183
  end
104
184
  end
105
185
 
106
- def run
107
- @script_arguments.each do |@generation_name|
108
- # Class name passed to the template
109
- @generation_class_name = @generation_name.classify
110
- # File name for the template
111
- @generation_file_name = @generation_class_name.underscore
112
- # Call the generator
113
- send( @generator_type.to_sym )
186
+ def test( test_name = nil, routes = nil )
187
+ # Test options
188
+ argument_options = OptionParser.new do |opts|
189
+ opts.banner = ""
190
+ opts.separator "test generator options:"
191
+ opts.on_tail("-h", "--help", "Show this message") do
192
+ help
193
+ puts opts
194
+ exit
195
+ end
196
+ end
197
+
198
+ # parse options if view name is not passed
199
+ if test_name.nil?
200
+ argument_options.parse! @script_arguments
201
+ if @script_arguments.length < 1
202
+ help
203
+ puts argument_options
204
+ exit
205
+ end
206
+
207
+ test_name = @script_arguments.shift
208
+ routes = @script_arguments
209
+ end
210
+
211
+ # Create test file
212
+ destination_file = File.dirname( $0 ) + "/../test/test_" + test_name.underscore + ".rb"
213
+ createFile( destination_file ) do |io|
214
+ io.puts template( "generate/test_begin", binding )
215
+
216
+ routes.each do |@test_route|
217
+ io.puts template( "generate/test_views", binding )
218
+ end
219
+
220
+ io.puts template( "generate/test_end", binding )
114
221
  end
115
222
  end
116
223
 
117
- private
118
- def controller
119
- @destination_file = File.dirname( $0 ) + "/../app/controllers/" + @generation_file_name.underscore + ".rb"
120
- @generation_view_name = @generation_class_name.underscore
224
+ def model( model = nil )
225
+ # Model options
226
+ argument_options = OptionParser.new do |opts|
227
+ opts.banner = ""
228
+ opts.separator "model generator options:"
229
+ opts.on_tail("-h", "--help", "Show this message") do
230
+ help
231
+ puts opts
232
+ exit
233
+ end
234
+ end
121
235
 
122
- default_route = @generation_view_name
123
- @options.routes << default_route if @options.default_route and @options.routes.include?( default_route ) == false
124
- @generation_routes = if @options.routes.size > 0
125
- " < R '/" + @options.routes.join("', '/") + "'"
236
+ # parse options
237
+ if model.nil?
238
+ argument_options.parse! @script_arguments
239
+ if @script_arguments.length < 1
240
+ help
241
+ puts argument_options
242
+ exit
243
+ end
244
+ model_list = @script_arguments
126
245
  else
127
- ""
246
+ model_list = [ model ]
128
247
  end
248
+
249
+ model_list.each do |model_name|
250
+ # Model class name, passed to the template
251
+ @model_class_name = model_name.classify
129
252
 
130
- createFile( @destination_file ) do |io|
131
- io.puts template( "generate/controller", binding )
132
- end
253
+ destination_file = File.dirname( $0 ) + "/../app/models/" + @model_class_name.underscore + ".rb"
254
+ createFile( destination_file ) do |io|
255
+ io.puts template( "generate/model", binding )
256
+ end
133
257
 
134
- view( ) if @options.noview == false
135
- test( ) if @options.notest == false
258
+ migration( model_name )
259
+ end
136
260
  end
137
261
 
138
- def migration( from_model = false )
262
+ def migration( model = nil )
263
+ # Test options
264
+ argument_options = OptionParser.new do |opts|
265
+ opts.banner = ""
266
+ opts.separator "migration generator options:"
267
+ opts.on_tail("-h", "--help", "Show this message") do
268
+ help
269
+ puts opts
270
+ exit
271
+ end
272
+ end
273
+
274
+ # parse options if view name is not passed
275
+ if model.nil?
276
+ argument_options.parse! @script_arguments
277
+ if @script_arguments.length < 1
278
+ help
279
+ puts argument_options
280
+ exit
281
+ end
282
+
283
+ model = @script_arguments
284
+ from_model = false
285
+ else
286
+ model = [ model ]
287
+ from_model = true
288
+ end
289
+
139
290
  # Get old and new version
140
291
  old_version = 0.0
141
292
  begin
@@ -163,98 +314,29 @@ module Bivouac
163
314
 
164
315
  puts "\t* Migration from version #{old_version} to version #{@new_version}" if old_version > 0.0
165
316
 
166
- @generation_table_name = (@generation_app_name.downcase + "_" + @generation_name).tableize
317
+ model.each do |model_name|
318
+ # Model class name
319
+ @model_class_name = model_name.classify
320
+
321
+ # Model class name
322
+ @model_table_name = (@app.environment.appname.downcase + "_" + model_name).tableize
167
323
 
168
- @destination_file = File.dirname( $0 ) + "/../db/migrate/" + file_prefix + "_" + @generation_file_name.underscore + ".rb"
169
- createFile( @destination_file ) do |io|
170
- if from_model
171
- io.puts template( "generate/migrate", binding )
172
- else
173
- io.puts template( "generate/migration", binding )
324
+ destination_file = File.dirname( $0 ) + "/../db/migrate/" + file_prefix + "_" + model_name.underscore + ".rb"
325
+ createFile( destination_file ) do |io|
326
+ if from_model
327
+ io.puts template( "generate/migrate", binding )
328
+ else
329
+ io.puts template( "generate/migration", binding )
330
+ end
174
331
  end
175
332
  end
176
333
 
177
- @destination_file = File.dirname( $0 ) + "/../db/create.rb"
178
- createFile( @destination_file, false, false ) do |io|
334
+ destination_file = File.dirname( $0 ) + "/../db/create.rb"
335
+ createFile( destination_file, false, false ) do |io|
179
336
  io.puts template( "generate/create", binding )
180
337
  end
181
338
  end
182
-
183
- def model
184
- @destination_file = File.dirname( $0 ) + "/../app/models/" + @generation_file_name.underscore + ".rb"
185
- createFile( @destination_file ) do |io|
186
- io.puts template( "generate/model", binding )
187
- end
188
-
189
- migration( true )
190
- end
191
-
192
- def view
193
- file_extension = ".rb"
194
- if @generation_type.downcase == "erb"
195
- raise "ERB applications are no longer supported. Sorry!"
196
- file_extension = ".html"
197
- end
198
- @destination_file = File.dirname( $0 ) + "/../app/views/" + @generation_file_name.underscore + file_extension
199
-
200
- @generation_view_name = @generation_class_name.underscore
201
- createFile( @destination_file ) do |io|
202
- io.puts template( "generate/view_#{@generation_type.downcase}", binding )
203
- end
204
- end
205
-
206
- def test
207
- @destination_file = File.dirname( $0 ) + "/../test/test_" + @generation_file_name.underscore + ".rb"
208
- createFile( @destination_file ) do |io|
209
- io.puts template( "generate/test_begin", binding )
210
- @options.routes.each do |@test_route|
211
- io.puts template( "generate/test_views", binding )
212
- end
213
- io.puts template( "generate/test_end", binding )
214
- end
215
- end
216
-
217
- def scaffold
218
- @generation_view_name = @generation_class_name.underscore
219
-
220
- # Generate model and migrate
221
- model( )
222
-
223
- # Generate scaffold controllers
224
- @destination_file = File.dirname( $0 ) + "/../app/controllers/list_" + @generation_file_name + ".rb"
225
- createFile( @destination_file ) do |io|
226
- io.puts template( "generate/scaffold_controller_list", binding )
227
- end
228
- @destination_file = File.dirname( $0 ) + "/../app/controllers/create_" + @generation_file_name + ".rb"
229
- createFile( @destination_file ) do |io|
230
- io.puts template( "generate/scaffold_controller_create", binding )
231
- end
232
- @destination_file = File.dirname( $0 ) + "/../app/controllers/view_" + @generation_file_name + ".rb"
233
- createFile( @destination_file ) do |io|
234
- io.puts template( "generate/scaffold_controller_view", binding )
235
- end
236
-
237
- # Generate scaffold views
238
- file_extension = ".rb"
239
- if @generation_type.downcase == "erb"
240
- raise "ERB applications are no longer supported. Sorry!"
241
- file_extension = ".html"
242
- end
243
- @destination_file = File.dirname( $0 ) + "/../app/views/list_" + @generation_file_name + file_extension
244
- createFile( @destination_file ) do |io|
245
- io.puts template( "generate/scaffold_view_list_#{@generation_type.downcase}", binding )
246
- end
247
- @destination_file = File.dirname( $0 ) + "/../app/views/create_" + @generation_file_name + file_extension
248
- createFile( @destination_file ) do |io|
249
- io.puts template( "generate/scaffold_view_create_#{@generation_type.downcase}", binding )
250
- end
251
- @destination_file = File.dirname( $0 ) + "/../app/views/view_" + @generation_file_name + file_extension
252
- createFile( @destination_file ) do |io|
253
- io.puts template( "generate/scaffold_view_view_#{@generation_type.downcase}", binding )
254
- end
255
- end
256
339
  end
257
340
  end
258
341
 
259
-
260
342
  Bivouac::Generate.new( ARGV ).run( )
@@ -1,12 +1,15 @@
1
1
  require 'rubygems'
2
2
  require 'bivouac/template'
3
3
  require 'fileutils'
4
+ require 'open-uri'
4
5
  require File.dirname($0) + '/../config/environment.rb'
5
6
 
6
7
  BASE_URL = "http://bivouac.rubyforge.org/svn/trunk/plugins/"
7
8
 
8
9
  module Bivouac
9
10
  class Plugin
11
+ @@cmds = [:help, :install, :list]
12
+
10
13
  def initialize( argv )
11
14
  # Command (install, list, ...)
12
15
  @command = argv.shift
@@ -24,12 +27,30 @@ module Bivouac
24
27
  end
25
28
 
26
29
  def run
27
- send( @command.to_sym )
30
+ begin
31
+ send( @command.to_sym )
32
+ rescue
33
+ send( :help )
34
+ end
28
35
  end
29
36
 
30
37
  private
31
38
 
32
- def install
39
+ def help( desc = false )
40
+ return "Display this help" if desc
41
+
42
+ puts "Usage : plugin command"
43
+ puts "Bivouac plugin manager"
44
+ puts
45
+ puts "COMMANDS"
46
+ @@cmds.each do |m|
47
+ puts " #{(m.to_s + ' :').ljust(15)} #{send(m, true)}"
48
+ end
49
+ end
50
+
51
+ def install(desc = false)
52
+ return "Install plugin" if desc
53
+
33
54
  FileUtils::cd( File.dirname($0) + '/../plugins' )
34
55
 
35
56
  r = system "svn", "co", "#{BASE_URL}#{@script_arguments}"
@@ -38,8 +59,14 @@ module Bivouac
38
59
  end
39
60
  end
40
61
 
41
- def list
42
- puts "Not yet implemented!"
62
+ def list(desc = false)
63
+ return "List available plugins" if desc
64
+
65
+ open(BASE_URL).read.each do |l|
66
+ if m = /<li><a href="([^"]*)">(\1)<\/a><\/li>/.match( l )
67
+ puts " - " + m[1].gsub( /\//, '' )
68
+ end
69
+ end
43
70
  end
44
71
  end
45
72
  end
@@ -1,3 +1,9 @@
1
+ #
2
+ # Project <%= @conf.appname %>
3
+ #
4
+ # Created using bivouac on <%= Time.now %>.
5
+ # Copyright (c) <%= Time.now.year %> __My__. All rights reserved.
6
+ #
1
7
  require 'rubygems'
2
8
  require 'camping'
3
9
  require 'camping/session'
@@ -7,7 +13,7 @@ include Bivouac
7
13
  ENV['BIVOUAC_ROOT'] = File.expand_path( File.dirname(__FILE__) )
8
14
 
9
15
  task :environment do
10
- Camping.goes :<%= @appname %>
16
+ Camping.goes :<%= @conf.appname %>
11
17
 
12
18
  # Load models from app/models
13
19
  files( 'models' ) { |file| require( file ) }
@@ -24,14 +30,14 @@ task :environment do
24
30
  if database_connection[:adapter] =~ /sqlite/
25
31
  database_connection[:database] = ENV['BIVOUAC_ROOT'] + "/" + database_connection[:database]
26
32
  end
27
- <%= @appname %>::Models::Base.establish_connection database_connection
33
+ <%= @conf.appname %>::Models::Base.establish_connection database_connection
28
34
  end
29
35
 
30
36
  namespace :db do
31
37
  desc "Migrate the database through scripts in db/migrate."
32
38
  task :migrate => :environment do
33
- if <%= @appname %>.respond_to? :create
34
- <%= @appname %>.create
39
+ if <%= @conf.appname %>.respond_to? :create
40
+ <%= @conf.appname %>.create
35
41
  else
36
42
  puts "Nothing to do!"
37
43
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Project <%= @appname %>
2
+ # Project <%= @conf.appname %>
3
3
  #
4
4
  # Created using bivouac on <%= Time.now %>.
5
5
  # Copyright (c) <%= Time.now.year %> __My__. All rights reserved.
@@ -23,4 +23,4 @@ helpers = [
23
23
  BivouacHelpers::SoundView,
24
24
  ] + viewHelperModule
25
25
 
26
- <%= @appname %>.module_eval "class Mab < Markaby::Builder; include #{helpers.join(', ')}; end"
26
+ <%= @conf.appname %>.module_eval "class Mab < Markaby::Builder; include #{helpers.join(', ')}; end"
@@ -1,10 +1,12 @@
1
1
  #
2
- # Project <%= @appname %>
2
+ # Project <%= @conf.appname %>
3
3
  #
4
4
  # Created using bivouac on <%= Time.now %>.
5
5
  # Copyright (c) <%= Time.now.year %> __My__. All rights reserved.
6
6
  #
7
-
7
+ # DO NOT EDIT THIS FILE OR YOU REALLY KNOW WHAT YOU ARE DOING
8
+ # USE script/generate helper my_helper
9
+ #
8
10
  windows_process = false
9
11
  if /Windows/.match( ENV['OS'] )
10
12
  begin
@@ -20,7 +22,7 @@ require 'simple-daemon'
20
22
  DIRNAME = File.expand_path( File.dirname(__FILE__) )
21
23
  SimpleDaemon::WORKING_DIRECTORY = DIRNAME + "/../log/"
22
24
 
23
- class <%= @appname %>Daemon < SimpleDaemon::Base
25
+ class <%= @conf.appname %>Daemon < SimpleDaemon::Base
24
26
  @@server = nil
25
27
  @@use = nil
26
28
 
@@ -35,10 +37,10 @@ class <%= @appname %>Daemon < SimpleDaemon::Base
35
37
  if database_connection[:adapter] =~ /sqlite/
36
38
  database_connection[:database] = DIRNAME + "/../" + database_connection[:database]
37
39
  end
38
- <%= @appname %>::Models::Base.establish_connection database_connection
39
- <%= @appname %>::Models::Base.logger = Logger.new(DIRNAME + "/../log/<%= @appname %>.log")
40
- # -- DON'T WORK WITH RAILS 2 -- # <%= @appname %>::Models::Base.threaded_connections = false
41
- <%= @appname %>.create if <%= @appname %>.respond_to? :create
40
+ <%= @conf.appname %>::Models::Base.establish_connection database_connection
41
+ <%= @conf.appname %>::Models::Base.logger = Logger.new(DIRNAME + "/../log/<%= @conf.appname %>.log")
42
+ # -- DON'T WORK WITH RAILS 2 -- # <%= @conf.appname %>::Models::Base.threaded_connections = false
43
+ <%= @conf.appname %>.create if <%= @conf.appname %>.respond_to? :create
42
44
 
43
45
  trap(:INT) do
44
46
  stop
@@ -49,13 +51,13 @@ class <%= @appname %>Daemon < SimpleDaemon::Base
49
51
  begin
50
52
  require 'thin'
51
53
 
52
- Rack::Handler::Thin.run Rack::Adapter::Camping.new( <%= @appname %> ), :Host => config.environment.address, :Port => config.environment.port
53
- puts "** <%= @appname %> is running at http://#{config.environment.address}:#{config.environment.port}"
54
+ Rack::Handler::Thin.run Rack::Adapter::Camping.new( <%= @conf.appname %> ), :Host => config.environment.address, :Port => config.environment.port
55
+ puts "** <%= @conf.appname %> is running at http://#{config.environment.address}:#{config.environment.port}"
54
56
  rescue LoadError
55
57
  require 'mongrel/camping'
56
58
 
57
- @@server = Mongrel::Camping.start( config.environment.address, config.environment.port, "/", <%= @appname %>)
58
- puts "** <%= @appname %> is running at http://#{config.environment.address}:#{config.environment.port}"
59
+ @@server = Mongrel::Camping.start( config.environment.address, config.environment.port, "/", <%= @conf.appname %>)
60
+ puts "** <%= @conf.appname %> is running at http://#{config.environment.address}:#{config.environment.port}"
59
61
  @@server.run.join
60
62
  end
61
63
  else
@@ -66,8 +68,8 @@ class <%= @appname %>Daemon < SimpleDaemon::Base
66
68
  require 'camping/webrick'
67
69
 
68
70
  @@server = WEBrick::HTTPServer.new :BindAddress => config.environment.address, :Port => config.environment.port
69
- puts "** <%= @appname %> is running at http://#{config.environment.address}:#{config.environment.port}"
70
- @@server.mount "/", WEBrick::CampingHandler, <%= @appname %>
71
+ puts "** <%= @conf.appname %> is running at http://#{config.environment.address}:#{config.environment.port}"
72
+ @@server.mount "/", WEBrick::CampingHandler, <%= @conf.appname %>
71
73
  @@server.start
72
74
  end
73
75
  end
@@ -86,19 +88,19 @@ while ARGV.size > 0
86
88
  deamonize = ARGV.shift
87
89
  case deamonize
88
90
  when 'webrick'
89
- <%= @appname %>Daemon.use='webrick'
91
+ <%= @conf.appname %>Daemon.use='webrick'
90
92
  when '-c'
91
93
  ARGV.clear
92
94
 
93
- include <%= @appname %>::Models
95
+ include <%= @conf.appname %>::Models
94
96
 
95
97
  config = Bivouac::Environment.new( )
96
98
  database_connection = config.environment.db
97
99
  if database_connection[:adapter] =~ /sqlite/
98
100
  database_connection[:database] = DIRNAME + "/../" + database_connection[:database]
99
101
  end
100
- <%= @appname %>::Models::Base.establish_connection database_connection
101
- <%= @appname %>.create if <%= @appname %>.respond_to? :create
102
+ <%= @conf.appname %>::Models::Base.establish_connection database_connection
103
+ <%= @conf.appname %>.create if <%= @conf.appname %>.respond_to? :create
102
104
 
103
105
  require 'irb'
104
106
  require 'irb/completion'
@@ -113,7 +115,7 @@ while ARGV.size > 0
113
115
  exit 1
114
116
  end
115
117
 
116
- <%= @appname %>Daemon.daemonize
118
+ <%= @conf.appname %>Daemon.daemonize
117
119
  break
118
120
  when '-h'
119
121
  begin
@@ -125,7 +127,7 @@ while ARGV.size > 0
125
127
  puts "script/server [-d start|stop|restart] [-h]"
126
128
  exit
127
129
  when '--'
128
- <%= @appname %>Daemon.start
130
+ <%= @conf.appname %>Daemon.start
129
131
  break
130
132
  else
131
133
  puts "Ignore unknown option '#{deamonize}' !"
@@ -1,12 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  #
4
- # Project <%= @appname %>
4
+ # Project <%= @conf.appname %>
5
5
  #
6
6
  # Created using bivouac on <%= Time.now %>.
7
7
  # Copyright (c) <%= Time.now.year %> __My__. All rights reserved.
8
8
  #
9
-
9
+ # DO NOT EDIT THIS FILE OR YOU REALLY KNOW WHAT YOU ARE DOING
10
+ # USE script/generate helper my_helper
11
+ #
10
12
  require 'rubygems'
11
13
  require 'camping'
12
14
  require 'camping/session'
@@ -25,7 +27,7 @@ Dir.glob( filePath( __FILE__, '../plugins/**/init.rb' ) ).each { |p| require p }
25
27
  # Indent the code -- See http://code.whytheluckystiff.net/markaby/wiki/TipsAndTrickery
26
28
  Markaby::Builder.set(:indent, 2)
27
29
 
28
- Camping.goes :<%= @appname %>
30
+ Camping.goes :<%= @conf.appname %>
29
31
 
30
32
  # Load helpers from app/helpers
31
33
  files( 'helpers' ) { |file| require( file ) }
@@ -42,7 +44,7 @@ files( 'views' ) { |file| require( file ) }
42
44
  # Load controllers from app/controllers
43
45
  files( 'controllers', :except => [File.basename(__FILE__)] ) { |file| require( file ) }
44
46
 
45
- module <%= @appname %>::Controllers
47
+ module <%= @conf.appname %>::Controllers
46
48
  class Public < R '/public/(.+)'
47
49
  PATH = filePath( __FILE__ )
48
50
 
@@ -1,5 +1,5 @@
1
1
  #
2
- # Project <%= @appname %>
2
+ # Project <%= @conf.appname %>
3
3
  #
4
4
  # Created using bivouac on <%= Time.now %>.
5
5
  # Copyright (c) <%= Time.now.year %> __My__. All rights reserved.
@@ -1,10 +1,17 @@
1
- module <%= @generation_app_name %>::Controllers
2
- class <%= @generation_class_name %><%= @generation_routes %>
1
+ #
2
+ # Project <%= @app.environment.appname %>
3
+ #
4
+ # Created using bivouac on <%= Time.now %>.
5
+ # Copyright (c) <%= Time.now.year %> __My__. All rights reserved.
6
+ #
7
+
8
+ module <%= @app.environment.appname %>::Controllers
9
+ class <%= @controller_class_name %><%= @controller_routes %>
3
10
  def get
4
- render :<%= @generation_view_name %>
11
+ render :<%= @view_name %>
5
12
  end
6
13
  def post
7
- render :<%= @generation_view_name %>
14
+ render :<%= @view_name %>
8
15
  end
9
16
  end
10
17
  end
@@ -1,9 +1,15 @@
1
- module <%= @generation_app_name %>
1
+ #
2
+ # Project <%= @app.environment.appname %>
3
+ #
4
+ # Created using bivouac on <%= Time.now %>.
5
+ # Copyright (c) <%= Time.now.year %> __My__. All rights reserved.
6
+ #
7
+
8
+ module <%= @app.environment.appname %>
2
9
  include Camping::Session
3
10
  end
4
11
 
5
- def <%= @generation_app_name %>.create
12
+ def <%= @app.environment.appname %>.create
6
13
  Camping::Models::Session.create_schema
7
- <%= @generation_app_name %>::Models.create_schema
8
- # :assume => (<%= @generation_app_name %>::Models::<%= @generation_class_name %>.table_exists? ? 1.0 : 0.0)
14
+ <%= @app.environment.appname %>::Models.create_schema
9
15
  end
@@ -1,14 +1,21 @@
1
- module <%= @generation_app_name %>::Models
2
- class Create<%= @generation_class_name %> < V <%= @new_version %>
1
+ #
2
+ # Project <%= @app.environment.appname %>
3
+ #
4
+ # Created using bivouac on <%= Time.now %>.
5
+ # Copyright (c) <%= Time.now.year %> __My__. All rights reserved.
6
+ #
7
+
8
+ module <%= @app.environment.appname %>::Models
9
+ class Create<%= @model_class_name %> < V <%= @new_version %>
3
10
  def self.up
4
- create_table :<%= @generation_table_name %> do |t|
11
+ create_table :<%= @model_table_name %> do |t|
5
12
  t.column :id, :integer, :null => false
6
13
  # ...
7
14
  end
8
15
  end
9
16
 
10
17
  def self.down
11
- drop_table :<%= @generation_table_name %>
18
+ drop_table :<%= @model_table_name %>
12
19
  end
13
20
  end
14
21
  end
@@ -1,5 +1,12 @@
1
- module <%= @generation_app_name %>::Models
2
- class <%= @generation_class_name %> < V <%= @new_version %>
1
+ #
2
+ # Project <%= @app.environment.appname %>
3
+ #
4
+ # Created using bivouac on <%= Time.now %>.
5
+ # Copyright (c) <%= Time.now.year %> __My__. All rights reserved.
6
+ #
7
+
8
+ module <%= @app.environment.appname %>::Models
9
+ class <%= @model_class_name %> < V <%= @new_version %>
3
10
  def self.up
4
11
  end
5
12
 
@@ -1,5 +1,12 @@
1
- module <%= @generation_app_name %>::Models
2
- class <%= @generation_class_name %> < Base
1
+ #
2
+ # Project <%= @app.environment.appname %>
3
+ #
4
+ # Created using bivouac on <%= Time.now %>.
5
+ # Copyright (c) <%= Time.now.year %> __My__. All rights reserved.
6
+ #
7
+
8
+ module <%= @app.environment.appname %>::Models
9
+ class <%= @model_class_name %> < Base
3
10
  # ...
4
11
  end
5
12
  end
@@ -1,10 +1,17 @@
1
+ #
2
+ # Project <%= @app.environment.appname %>
3
+ #
4
+ # Created using bivouac on <%= Time.now %>.
5
+ # Copyright (c) <%= Time.now.year %> __My__. All rights reserved.
6
+ #
7
+
1
8
  require 'rubygems'
2
9
  require 'mosquito'
3
10
 
4
11
  ENV['BIVOUAC_ROOT'] = File.expand_path( File.dirname(__FILE__) + "/../" )
5
- require ENV['BIVOUAC_ROOT'] + "/app/<%= @generation_app_dir %>"
12
+ require ENV['BIVOUAC_ROOT'] + "/app/<%= @app.environment.appdir %>"
6
13
 
7
- <%= @generation_app_name %>.create if <%= @generation_app_name %>.respond_to? :create
8
- include <%= @generation_app_name %>::Models
14
+ <%= @app.environment.appname %>.create if <%= @app.environment.appname %>.respond_to? :create
15
+ include <%= @app.environment.appname %>::Models
9
16
 
10
- class Test<%= @generation_app_name %> < Camping::FunctionalTest
17
+ class Test<%= @app.environment.appname %> < Camping::FunctionalTest
@@ -1,6 +1,13 @@
1
- module <%= @generation_app_name %>::Views
2
- def <%= @generation_view_name %>
3
- h1.header { "<%= @generation_app_name %>::Views#<%= @generation_view_name %>" }
4
- p "Find me in <%= @destination_file %>"
1
+ #
2
+ # Project <%= @app.environment.appname %>
3
+ #
4
+ # Created using bivouac on <%= Time.now %>.
5
+ # Copyright (c) <%= Time.now.year %> __My__. All rights reserved.
6
+ #
7
+
8
+ module <%= @app.environment.appname %>::Views
9
+ def <%= @view_name %>
10
+ h1.header { "<%= @app.environment.appname %>::Views#<%= @view_name %>" }
11
+ p "Find me in <%= @destination_file.gsub( /script\/\.\.\//, "" ) %>"
5
12
  end
6
13
  end
@@ -1,3 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'rubygems'
3
+
4
+ def filePath( from, *data )
5
+ File.join File.expand_path(File.dirname(from)), data
6
+ end
7
+
8
+ Dir.glob( filePath( __FILE__, '../plugins/**/generators/*.rb' ) ).each { |p| require p }
3
9
  require 'bivouac/commands/generate'
File without changes
@@ -1,4 +1,11 @@
1
- module <%= @appname %>::Controllers
1
+ #
2
+ # Project <%= @conf.appname %>
3
+ #
4
+ # Created using bivouac on <%= Time.now %>.
5
+ # Copyright (c) <%= Time.now.year %> __My__. All rights reserved.
6
+ #
7
+
8
+ module <%= @conf.appname %>::Controllers
2
9
  class Index < R '/', '/index'
3
10
  def get
4
11
  redirect Public, "index.html"
@@ -64,8 +64,7 @@ module Bivouac
64
64
  end
65
65
  end
66
66
 
67
- def template( template_name, b = nil )
68
- template_file = File.dirname(__FILE__) + "/template/" + template_name + ".rb"
67
+ def plugin_template( template_file, b = nil )
69
68
  result = if b.nil?
70
69
  ERB.new(File.readlines(template_file).join, nil, '-').result( )
71
70
  else
@@ -73,5 +72,11 @@ module Bivouac
73
72
  end
74
73
  return( result )
75
74
  end
75
+
76
+ def template( template_name, b = nil )
77
+ template_file = File.dirname(__FILE__) + "/template/" + template_name + ".rb"
78
+
79
+ return plugin_template( template_file, b )
80
+ end
76
81
  end
77
82
  end
@@ -0,0 +1,11 @@
1
+ # Bivouac Project
2
+ class Module
3
+ def add_generator( g ) #:nodoc:
4
+ if self.class_variable_defined?(:@@plugins_generators)
5
+ x = class_variable_get( :@@plugins_generators ) + g.map{|x| x.to_s}
6
+ class_variable_set( :@@plugins_generators, x )
7
+ else
8
+ class_variable_set(:@@plugins_generators, g.map{|x| x.to_s})
9
+ end
10
+ end
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bivouac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Gr\xC3\xA9goire Lejeune"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-03-24 00:00:00 +01:00
12
+ date: 2008-03-31 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -138,12 +138,6 @@ files:
138
138
  - lib/bivouac/template/generate/migrate.rb
139
139
  - lib/bivouac/template/generate/migration.rb
140
140
  - lib/bivouac/template/generate/model.rb
141
- - lib/bivouac/template/generate/scaffold_controller_create.rb
142
- - lib/bivouac/template/generate/scaffold_controller_list.rb
143
- - lib/bivouac/template/generate/scaffold_controller_view.rb
144
- - lib/bivouac/template/generate/scaffold_view_create_goh.rb
145
- - lib/bivouac/template/generate/scaffold_view_list_goh.rb
146
- - lib/bivouac/template/generate/scaffold_view_view_goh.rb
147
141
  - lib/bivouac/template/generate/test_begin.rb
148
142
  - lib/bivouac/template/generate/test_end.rb
149
143
  - lib/bivouac/template/generate/test_views.rb
@@ -162,11 +156,13 @@ files:
162
156
  - lib/bivouac/template/static/index.html
163
157
  - lib/bivouac/template/static/index.rb
164
158
  - lib/bivouac/template/static/prototype.js
159
+ - lib/bivouac/template/static/README
165
160
  - lib/bivouac/template/static/scriptaculous.js
166
161
  - lib/bivouac/template/static/slider.js
167
162
  - lib/bivouac/template/static/sound.js
168
163
  - lib/bivouac/template/static/unittest.js
169
164
  - lib/bivouac/template.rb
165
+ - lib/bivouac/utils.rb
170
166
  - lib/bivouac.rb
171
167
  - examples/bivouac_sample
172
168
  - examples/bivouac_sample/app
@@ -1,15 +0,0 @@
1
- module <%= @generation_app_name %>::Controllers
2
- class Create<%= @generation_class_name %> < R '/<%= @generation_view_name %>/add'
3
- def get
4
- render :create_<%= @generation_view_name %>
5
- end
6
-
7
- def post
8
- @<%= @generation_view_name %> = Models::<%= @generation_class_name %>.create
9
- # @<%= @generation_view_name %>.<field> = input.<field>
10
- @<%= @generation_view_name %>.save
11
- redirect List<%= @generation_class_name %>
12
- # render :view_<%= @generation_view_name %>
13
- end
14
- end
15
- end
@@ -1,8 +0,0 @@
1
- module <%= @generation_app_name %>::Controllers
2
- class List<%= @generation_class_name %> < R '/<%= @generation_view_name %>'
3
- def get
4
- @<%= @generation_view_name.pluralize %> = Models::<%= @generation_class_name %>.find( :all )
5
- render :list_<%= @generation_view_name %>
6
- end
7
- end
8
- end
@@ -1,14 +0,0 @@
1
- module <%= @generation_app_name %>::Controllers
2
- class View<%= @generation_class_name %> < R '/<%= @generation_view_name %>/(\d)'
3
- def get(id)
4
- @<%= @generation_view_name %> = Models::<%= @generation_class_name %>.find(id)
5
- render :view_<%= @generation_view_name %>
6
- end
7
- def post(id)
8
- @<%= @generation_view_name %> = Models::<%= @generation_class_name %>.find(id)
9
- # @<%= @generation_view_name %>.<field> = input.<field>
10
- @<%= @generation_view_name %>.save
11
- render :view_<%= @generation_view_name %>
12
- end
13
- end
14
- end
@@ -1,11 +0,0 @@
1
- module <%= @generation_app_name %>::Views
2
- def create_<%= @generation_view_name %>
3
- p "Add a new <%= @generation_class_name %>"
4
- div.<%= @generation_view_name %>_form do
5
- form(:method => 'post', :action => R(Create<%= @generation_class_name %>)) do
6
- # ...
7
- input :type => 'submit'
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module <%= @generation_app_name %>::Views
2
- def list_<%= @generation_view_name %>
3
- a 'add a <%= @generation_class_name %>', :href => R(Create<%= @generation_class_name %>)
4
- div.<%= @generation_view_name.pluralize %> do
5
- @<%= @generation_view_name.pluralize %>.each do |<%= @generation_view_name %>|
6
- #...
7
- a 'view', :href => R(View<%= @generation_class_name %>, <%= @generation_view_name %>.id)
8
- end
9
- end
10
- end
11
- end
@@ -1,14 +0,0 @@
1
- module <%= @generation_app_name %>::Views
2
- def view_<%= @generation_view_name %>
3
- div.<%= @generation_view_name %> do
4
- #...
5
- a 'List', :href => R(List<%= @generation_class_name %>)
6
- end
7
- div.<%= @generation_view_name %>_form do
8
- form(:method => 'post', :action => R(View<%= @generation_class_name %>, @<%= @generation_view_name %>.id)) do
9
- # ...
10
- input :type => 'submit'
11
- end
12
- end
13
- end
14
- end