Permalink
Browse files

script/bootstrap

  • Loading branch information...
1 parent e2a6560 commit 4cb8d0a28c74ac496da59e121ab8e08d0e2abcb8 @mislav committed May 16, 2012
Showing with 29 additions and 3 deletions.
  1. +10 −2 Rakefile
  2. +1 −1 app.rb
  3. +18 −0 script/bootstrap
View
@@ -4,7 +4,7 @@ task :environment do
require_relative 'app'
end
-task :bootstrap => [:'db:rebuild', :import_index, :import_popular]
+task :bootstrap => [:'db:bootstrap', :import_index, :import_popular]
namespace :db do
task :rebuild => :environment do
@@ -14,14 +14,22 @@ namespace :db do
task :migrate => :environment do
DataMapper.auto_upgrade!
end
+
+ task :bootstrap => :environment do
+ if RfcEntry.storage_exists?
+ Rake::Task[:'db:migrate'].invoke
+ else
+ Rake::Task[:'db:rebuild'].invoke
+ end
+ end
end
task :import_index => ['tmp/rfc-index.xml', :environment] do |task|
require 'nokogiri'
require 'active_support/core_ext/object/try'
require 'date'
- DataMapper.logger.set_log($stderr, :debug)
+ DataMapper.logger.set_log($stderr, :warn)
index = Nokogiri File.open(task.prerequisites.first)
num = 0
View
2 app.rb
@@ -33,7 +33,7 @@
require 'dm-core'
configure :development do
- DataMapper::Logger.new($stderr, :debug)
+ DataMapper::Logger.new($stderr, :info)
end
configure do
View
@@ -0,0 +1,18 @@
+#!/bin/bash
+set -e
+
+if [[ -n $DATABASE_URL ]]; then
+ dbname=$(basename "$DATABASE_URL")
+else
+ dbname=rfc
+fi
+
+git submodule update --init
+
+bundle install --without production
+
+# check if database exists; otherwise create it
+psql -tAl | grep -E "^$dbname\|" >/dev/null || \
+ createdb --no-password $dbname
+
+rake bootstrap

0 comments on commit 4cb8d0a

Please sign in to comment.