changeset 147:812711965af1

Added support for disabling supported web server without changing Gemfile.
author Edho Arief <edho@myconan.net>
date Sun, 18 Nov 2012 22:57:36 +0700
parents 601c608637e7
children 9337084b18d7
files Gemfile config/application.rb config/default_config.rb config/init_config.rb config/local_config.rb.example
diffstat 5 files changed, 20 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Gemfile	Sun Nov 18 00:48:32 2012 +0700
+++ b/Gemfile	Sun Nov 18 22:57:36 2012 +0700
@@ -28,9 +28,11 @@
 # To use Jbuilder templates for JSON
 # gem 'jbuilder'
 
-# Use unicorn as the app server
-gem 'unicorn', :platforms => :mri
-gem 'puma', :platforms => [:rbx, :jruby]
+group :standalone do
+  # Use unicorn as the app server
+  gem 'unicorn', :platforms => :mri
+  gem 'puma', :platforms => [:rbx, :jruby]
+end
 
 # Deploy with Capistrano
 # gem 'capistrano'
--- a/config/application.rb	Sun Nov 18 00:48:32 2012 +0700
+++ b/config/application.rb	Sun Nov 18 22:57:36 2012 +0700
@@ -1,6 +1,5 @@
 require File.expand_path('../boot', __FILE__)
 
-# Pick the frameworks you want:
 require "active_record/railtie"
 require "action_controller/railtie"
 # require "action_mailer/railtie"
@@ -8,9 +7,14 @@
 require "sprockets/railtie"
 # require "rails/test_unit/railtie"
 
+require File.expand_path('../init_config', __FILE__)
+require File.expand_path('../local_config', __FILE__)
+require File.expand_path('../default_config', __FILE__)
+
+# Pick the frameworks you want:
 if defined?(Bundler)
   # If you precompile assets before deploying to production, use this line
-  Bundler.require(*Rails.groups(:assets => %w(development test)))
+  Bundler.require(*CONFIG['bundler_groups'])
   # If you want your assets lazily compiled in production, use this line
   # Bundler.require(:default, :assets, Rails.env)
 end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config/default_config.rb	Sun Nov 18 22:57:36 2012 +0700
@@ -0,0 +1,3 @@
+CONFIG['standalone'] ||= true
+CONFIG['bundler_groups'] ||= Rails.groups(:assets => %w(development test))
+CONFIG['bundler_groups'] << 'standalone' if CONFIG['standalone']
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config/init_config.rb	Sun Nov 18 22:57:36 2012 +0700
@@ -0,0 +1,1 @@
+CONFIG = {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config/local_config.rb.example	Sun Nov 18 22:57:36 2012 +0700
@@ -0,0 +1,5 @@
+# Set to false if you want to use different web server (e.g. passenger)
+# Default is set to use standalone server:
+# - MRI Ruby: Unicorn
+# - JRuby and Rubinius: Puma
+# CONFIG['standalone'] = true