lib/bivouac/commands/generate.rb in bivouac-0.0.1 vs lib/bivouac/commands/generate.rb in bivouac-0.0.2
- old
+ new
@@ -28,16 +28,11 @@
@destination_file = File.dirname( $0 ) + "/../app/" + @file_type.pluralize + "/" + @generation_file_name.underscore + ".rb"
end
def run
- #begin
- send( @file_type.to_sym )
- #rescue
- # help( )
- # exit
- #end
+ send( @file_type.to_sym )
end
private
def controller
@generation_view_name = @generation_class_name.underscore
@@ -47,18 +42,27 @@
view( )
end
def migrate
- puts "hello from migrate"
- puts "generate from #{@template_file} in #{@destination_file} for #{@app.environment.appname}::#{@generation_class_name}"
+ @generation_table_name = (@generation_app_name + "_" + @generation_name).tableize
+ @destination_file = File.dirname( $0 ) + "/../db/migrate/" + @generation_file_name.underscore + ".rb"
+ createFile( @destination_file ) do |io|
+ io.puts template( "generate/migrate", binding )
+ end
+ @destination_file = File.dirname( $0 ) + "/../db/create.rb"
+ createFile( @destination_file, false, false ) do |io|
+ io.puts template( "generate/create", binding )
+ end
end
def model
- puts "hello from model"
- puts "generate from #{@template_file} in #{@destination_file} for #{@app.environment.appname}::#{@generation_class_name}"
+ createFile( @destination_file ) do |io|
+ io.puts template( "generate/model", binding )
+ end
+ migrate( )
end
def view( )
@destination_file = File.dirname( $0 ) + "/../app/views/" + @generation_file_name.underscore + ".rb"
createFile( @destination_file ) do |io|
\ No newline at end of file