Skip to content
Browse files

mysql template file

  • Loading branch information...
1 parent 7dd7398 commit 996e71f7d957ea7eb6fd2ff1bcfb35ad6855d746 @xdite committed
View
16 lib/bootstrapers/app_builder.rb
@@ -39,5 +39,21 @@ def add_jquery_ui
"//= require jquery-ui\n", :before => '//= require_tree .'
end
+ def add_custom_gems
+ additions_path = find_in_source_paths 'Gemfile_additions'
+ new_gems = File.open(additions_path).read
+ inject_into_file 'Gemfile', "\n#{new_gems}",
+ :after => /gem 'jquery-rails'/
+ end
+
+ def use_mysql_config_template
+ template 'mysql_database.yml.erb', 'config/database.yml',
+ :force => true
+ end
+
+ def create_database
+ bundle_command 'exec rake db:create'
+ end
+
end
end
View
20 lib/bootstrapers/generators/app_generator.rb
@@ -5,6 +5,9 @@
module Bootstrapers
class AppGenerator < Rails::Generators::AppGenerator
+ class_option :database, :type => :string, :aliases => '-d', :default => 'mysql',
+ :desc => "Preconfigure for selected database (options: #{DATABASES.join('/')})"
+
def finish_template
invoke :bootstrapers_customization
super
@@ -16,6 +19,8 @@ def bootstrapers_customization
invoke :create_bootstrapers_views
invoke :create_common_javascripts
invoke :add_jquery_ui
+ invoke :customize_gemfile
+ invoke :setup_database
end
def remove_files_we_dont_need
@@ -44,6 +49,21 @@ def add_jquery_ui
build :add_jquery_ui
end
+ def customize_gemfile
+ build :add_custom_gems
+ bundle_command 'install'
+ end
+
+ def setup_database
+ say 'Setting up database'
+
+ if 'mysql' == options[:database]
+ build :use_mysql_config_template
+ end
+
+ build :create_database
+ end
+
protected
def get_builder_class
View
12 templates/Gemfile_additions
@@ -0,0 +1,12 @@
+
+gem 'anjlab-bootstrap-rails', '>= 2.1', :require => 'bootstrap-rails'
+gem 'high_voltage'
+gem 'airbrake'
+
+group :development do
+ gem 'foreman'
+end
+
+group :production do
+ gem 'newrelic_rpm'
+end
View
12 templates/mysql_database.yml.erb
@@ -0,0 +1,12 @@
+development: &default
+ adapter: mysql2
+ encoding: utf8
+ database: <%= app_name %>_development
+ host: localhost
+ username: root
+ password: "123456"
+
+test: &TEST
+ <<: *default
+ database: <%= app_name %>_test
+

0 comments on commit 996e71f

Please sign in to comment.
Something went wrong with that request. Please try again.