Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Commit

Permalink
Beginnings of config framework
Browse files Browse the repository at this point in the history
Ability to keep configuration in a git ignored config file or pull
from environment variables.
  • Loading branch information
Malcolm Locke committed Sep 11, 2012
1 parent 56f61b1 commit 70080cb
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,4 +1,5 @@
config/database.yml config/database.yml
config/fulcrum.rb
.bundle .bundle
db/*.sqlite3 db/*.sqlite3
log/*.log log/*.log
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -16,6 +16,7 @@ gem 'jquery-rails'
gem 'devise' gem 'devise'
gem 'transitions', '0.0.9', :require => ["transitions", "active_record/transitions"] gem 'transitions', '0.0.9', :require => ["transitions", "active_record/transitions"]
gem 'i18n-js' gem 'i18n-js'
gem 'configuration'


gem 'fastercsv', '1.5.3', :platforms => :ruby_18 gem 'fastercsv', '1.5.3', :platforms => :ruby_18
# (using standard csv lib if ruby version is 1.9) # (using standard csv lib if ruby version is 1.9)
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Expand Up @@ -48,6 +48,7 @@ GEM
sass (~> 3.1) sass (~> 3.1)
compass-rails (1.0.0.rc.3) compass-rails (1.0.0.rc.3)
compass (~> 0.12.rc.0) compass (~> 0.12.rc.0)
configuration (1.3.2)
database_cleaner (0.7.1) database_cleaner (0.7.1)
devise (2.0.4) devise (2.0.4)
bcrypt-ruby (~> 3.0) bcrypt-ruby (~> 3.0)
Expand Down Expand Up @@ -169,6 +170,7 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
capybara capybara
compass-rails compass-rails
configuration
database_cleaner database_cleaner
devise devise
ejs ejs
Expand Down
21 changes: 17 additions & 4 deletions README.md
Expand Up @@ -79,13 +79,13 @@ to the previous section for instructions. Then:
# Create your app. Replace APPNAME with whatever you want to name it. # Create your app. Replace APPNAME with whatever you want to name it.
$ heroku create APPNAME --stack cedar $ heroku create APPNAME --stack cedar


# Set APP_NAME heroku config so outbound emails have a proper host # Set APP_HOST heroku config so outbound emails have a proper host
# Replace MYAPPNAME below with the value from `heroku create` # Replace APPNAME below with the value from `heroku create`
$ heroku config:add APP_NAME=MYAPPNAME $ heroku config:set APP_HOST=APPNAME.herokuapp.com


# Define where the user emails will be coming from # Define where the user emails will be coming from
# (This email address does not need to exist) # (This email address does not need to exist)
$ heroku config:add MAILER_SENDER=noreply@example.org $ heroku config:set MAILER_SENDER=noreply@example.org


# Allow emails to be sent # Allow emails to be sent
$ heroku addons:add sendgrid:starter $ heroku addons:add sendgrid:starter
Expand All @@ -99,6 +99,19 @@ to the previous section for instructions. Then:
Once that's done, you will be able to view your site at Once that's done, you will be able to view your site at
`http://APPNAME.herokuapp.com`. `http://APPNAME.herokuapp.com`.


Deploying to other platforms
----------------------------

Fulcrum can be deployed to any platform that can host Rails. Setting this
up is beyond the scope of this document, but for the most part Fulcrum does
not have any special operational requirements and can be deployed as a normal
Rails application.

You will need to set up some custom configuration, to do this copy the file
`config/fulcrum.example.rb` to `config/fulcrum.rb` and edit to your
requirements, or ensure the relevant environment variables are set for the
application as described in the file above.

Translating Translating
----------- -----------


Expand Down
6 changes: 6 additions & 0 deletions config/application.rb
Expand Up @@ -49,5 +49,11 @@ class Application < Rails::Application


# Do not initialize the whole Rails stack when precompiling assets # Do not initialize the whole Rails stack when precompiling assets
config.assets.initialize_on_precompile = false config.assets.initialize_on_precompile = false

load Rails.root.join('config','fulcrum_defaults.rb')
if File.exist?(Rails.root.join('config', 'fulcrum.rb'))
load Rails.root.join('config','fulcrum.rb')
end
config.fulcrum = ::Configuration.for 'fulcrum'
end end
end end
2 changes: 1 addition & 1 deletion config/environments/development.rb
Expand Up @@ -16,7 +16,7 @@
# Don't care if the mailer can't send # Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_deliveries = false config.action_mailer.perform_deliveries = false
config.action_mailer.default_url_options = { :host => '127.0.0.1:3000' } config.action_mailer.default_url_options = { :host => config.fulcrum.app_host }
# Print deprecation notices to the Rails logger # Print deprecation notices to the Rails logger
config.active_support.deprecation = :log config.active_support.deprecation = :log


Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Expand Up @@ -47,7 +47,7 @@


# Disable delivery errors, bad email addresses will be ignored # Disable delivery errors, bad email addresses will be ignored
# config.action_mailer.raise_delivery_errors = false # config.action_mailer.raise_delivery_errors = false
config.action_mailer.default_url_options = { :host => "#{ENV['APP_NAME']}.herokuapp.com" } config.action_mailer.default_url_options = { :host => config.fulcrum.app_host }


# Enable threaded mode # Enable threaded mode
# config.threadsafe! # config.threadsafe!
Expand Down
8 changes: 8 additions & 0 deletions config/fulcrum.example.rb
@@ -0,0 +1,8 @@
Configuration.for('fulcrum') do
# Set this to the domain name of your installation. Env var APP_HOST
#app_host 'example.com'

# The email address that notification emails will be sent from. Env var
# MAILER_SENDER
#mailer_sender 'noreply@example.com'
end
7 changes: 7 additions & 0 deletions config/fulcrum_defaults.rb
@@ -0,0 +1,7 @@
Configuration.for('fulcrum') do
# On Heroku, ensure you `heroku config:add APP_HOST=appname.herokuapp.com`
app_host ENV['APP_HOST'] || '127.0.0.1:3000'

# The address which system emails will originate from.
mailer_sender ENV['MAILER_SENDER'] || 'noreply@example.com'
end
2 changes: 1 addition & 1 deletion config/initializers/devise.rb
Expand Up @@ -4,7 +4,7 @@
# ==> Mailer Configuration # ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer, # Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use your own mailer class with default "from" parameter. # note that it will be overwritten if you use your own mailer class with default "from" parameter.
config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com" config.mailer_sender = Rails.application.config.fulcrum.mailer_sender


# Configure the class responsible to send e-mails. # Configure the class responsible to send e-mails.
# config.mailer = "Devise::Mailer" # config.mailer = "Devise::Mailer"
Expand Down

0 comments on commit 70080cb

Please sign in to comment.