Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added options to specify database username and password in the refine…

…rycms installer task.
  • Loading branch information...
commit 4e94a9b57b5b01dbf68da5e09c5c8b1076228b88 1 parent fd25e28
@parndt parndt authored
Showing with 26 additions and 7 deletions.
  1. +23 −5 bin/refinerycms
  2. +2 −1  changelog.md
  3. +1 −1  refinerycms.gemspec
View
28 bin/refinerycms
@@ -25,7 +25,11 @@ module Refinery
# Default options
@input = input
@options = {
- :database => 'sqlite3',
+ :database => {
+ :adapter => 'sqlite3',
+ :username => 'root',
+ :password => ''
+ },
:force => false,
:heroku => false,
:gems => []
@@ -41,7 +45,15 @@ module Refinery
# Rails supports more options, but Refinery is only tested on these three
databases = %w(mysql postgresql sqlite3)
opts.on("-d DATABASE", "--database DATABASE", databases, "Select the database (default sqlite3)", " #{databases.join('/')}") do |db|
- @options[:database] = db
+ @options[:database][:adapter] = db
+ end
+
+ opts.on("-u USERNAME", '--database-username USERNAME', String, "Set the database username", ' (default root)') do |username|
+ @options[:database][:username] = username
+ end
+
+ opts.on("-p PASSWORD", '--database-password PASSWORD', String, "Set the database password", " (default '')") do |password|
+ @options[:database][:password] = password
end
opts.on("-g", "--gems gem1,gem2,gem3", Array, "Additional gems to install") do |gems|
@@ -119,7 +131,7 @@ module Refinery
def generate!
# Generate a rails application
rails_command = "rails new \"#{@app_path}\""
- rails_command << " --database #{@options[:database]}"
+ rails_command << " --database #{@options[:database][:adapter]}"
rails_command << " --force" if @options[:force]
rails_command << " --skip-test-unit --skip-prototype"
run_command(rails_command, {:cd => false})
@@ -160,6 +172,10 @@ module Refinery
f.write "\n" + refinery_gems + "\n\n# USER DEFINED\n" + @options[:gems].join("\n") + "\n# END USER DEFINED"
end
+ # Override database username and password
+ find_and_replace('config/database.yml', %r{username:.*}, "username: #{@options[:database][:username]}")
+ find_and_replace('config/database.yml', %r{password:.*}, "password: #{@options[:database][:password]}")
+
# Specify the correct version of the Refinery CMS gem (may be git source).
src = Refinery.version !~ /\.pre$/ ? "'~> #{Refinery.version}'" : ":git => 'git://github.com/resolve/refinerycms.git'"
find_and_replace('Gemfile', "gem 'refinerycms', :path => '.'",
@@ -194,9 +210,11 @@ module Refinery
puts "Installing gem requirements using bundler..\n"
run_command("bundle install")
+ # sqlite3 requires we use 'db:migrate' etc instead of 'db:setup'
puts "\n\nSetting up your development database..\n"
- %w(db:drop db:create db:migrate db:seed).each do |db|
- run_command("rake -f \"#{@app_path.join('Rakefile')}\" #{db}")
+ tasks = @options[:database][:adapter] == 'sqlite3' ? %w(db:migrate db:seed) : %w(db:setup)
+ tasks.each do |task|
+ run_command("rake -f \"#{@app_path.join('Rakefile')}\" #{task}")
end
# Deploy to Heroku
View
3  changelog.md
@@ -1,5 +1,6 @@
## 0.9.8.8 [16 December 2010]
-* Prevented RefinerySetting from accessing its database table before it is created. [Philip Arndt](http://github.com/parndt)
+* Prevented RefinerySetting from accessing its database table before it is created. [Philip Arndt](https://github.com/parndt)
+* Added more options to ``bin/refinerycms`` like ability to specify database username and password. [Philip Arndt](https://github.com/parndt)
* [See full list](https://github.com/resolve/refinerycms/compare/0.9.8.7...0.9.8.8)
## 0.9.8.7 [15 December 2010]
View
2  refinerycms.gemspec
@@ -4,7 +4,7 @@ Gem::Specification.new do |s|
s.name = %q{refinerycms}
s.version = %q{0.9.8.8}
s.description = %q{A Ruby on Rails CMS that supports Rails 3. It's easy to extend and sticks to 'the Rails way' where possible.}
- s.date = %q{2010-12-15}
+ s.date = %q{2010-12-16}
s.summary = %q{A Ruby on Rails CMS that supports Rails 3}
s.email = %q{info@refinerycms.com}
s.homepage = %q{http://refinerycms.com}
Please sign in to comment.
Something went wrong with that request. Please try again.