Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

abstract settings for heroku, can use travis-cli for configuring and …

…deploying to heroku now
  • Loading branch information...
commit db5436316aeff4143743a4d6578df0a644061d57 1 parent 692be63
@svenfuchs svenfuchs authored
View
2  .gitignore
@@ -1,6 +1,6 @@
.bundle
config/database.yml
-config/settings.yml
+config/travis.yml
db/*.sqlite3
log/*.log
tmp/
View
2  Rakefile
@@ -4,4 +4,4 @@
require File.expand_path('../config/application', __FILE__)
-Saas::Application.load_tasks
+Travis::Application.load_tasks
View
2  config/application.rb
@@ -9,7 +9,7 @@
# Bundler.require(:default, :assets, Rails.env)
end
-module Saas
+module Travis
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
View
2  config/environment.rb
@@ -2,4 +2,4 @@
require File.expand_path('../application', __FILE__)
# Initialize the rails application
-Saas::Application.initialize!
+Travis::Application.initialize!
View
2  config/environments/development.rb
@@ -1,4 +1,4 @@
-Saas::Application.configure do
+Travis::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
View
2  config/environments/production.rb
@@ -1,4 +1,4 @@
-Saas::Application.configure do
+Travis::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Code is not reloaded between requests
View
2  config/environments/test.rb
@@ -1,4 +1,4 @@
-Saas::Application.configure do
+Travis::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The test environment is used exclusively to run your application's
View
14 config/initializers/assets.rb
@@ -1,14 +0,0 @@
-expansions = {
- jquery: %w(
- http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js
- https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js
- ),
- stripe: %w(
-
- )
-}
-
-expansions.each do |name, scripts|
- ActionView::Helpers::AssetTagHelper::register_javascript_expansion :name => scripts
-end
-
View
3  config/initializers/config.rb
@@ -0,0 +1,3 @@
+require 'settings'
+
+Rails.application.config.settings = Settings.new.load('config/settings.yml', Rails.env)
View
6 config/initializers/devise.rb
@@ -1,10 +1,10 @@
-settings = Hashr.new(YAML.load(File.read('config/settings.yml')))
+settings = Rails.application.config.settings
Devise.setup do |c|
require 'devise/orm/active_record'
c.http_authenticatable = true
- c.omniauth :github, settings.github.client_id, settings.github.client_secret, :scope => settings.github.scope
- c.omniauth :twitter, settings.twitter.client_id, settings.twitter.client_secret
+ # c.omniauth :github, settings.github.client_id, settings.github.client_secret, :scope => settings.github.scope
+ # c.omniauth :twitter, settings.twitter.client_id, settings.twitter.client_secret
end
View
2  config/initializers/secret_token.rb
@@ -4,4 +4,4 @@
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
-Saas::Application.config.secret_token = '6e2b941713e5b9fa57cdff558772b88dc6dca42e74641bb01b835b0caa70526a0baf3c264a5bb6815cf1f5943ed48499ec66939e8984e0d84beed97b01923c0c'
+Travis::Application.config.secret_token = '6e2b941713e5b9fa57cdff558772b88dc6dca42e74641bb01b835b0caa70526a0baf3c264a5bb6815cf1f5943ed48499ec66939e8984e0d84beed97b01923c0c'
View
2  config/initializers/session_store.rb
@@ -1,6 +1,6 @@
# Be sure to restart your server when you modify this file.
-Saas::Application.config.session_store :cookie_store, key: '_saas_session'
+Travis::Application.config.session_store :cookie_store, key: '_travis_session'
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
View
2  config/initializers/stripe.rb
@@ -1,4 +1,4 @@
-settings = Hashr.new(YAML.load(File.read('config/settings.yml')))
+settings = Rails.application.config.settings
Stripe.api_key = settings.stripe.secret_key
STRIPE_PUBLIC_KEY = settings.stripe.public_key
View
2  config/routes.rb
@@ -1,4 +1,4 @@
-Saas::Application.routes.draw do
+Travis::Application.routes.draw do
root to: 'home#show'
match 'packages/:package', as: :new_package, to: 'orders#new'
View
0  config/settings.example.yml → config/travis.example.yml
File renamed without changes
View
32 lib/settings.rb
@@ -0,0 +1,32 @@
+require 'hashr'
+require 'yaml'
+
+class Settings < Hashr
+ extend Hashr::EnvDefaults
+
+ self.env_namespace = 'travis'
+
+ define :stripe => { secret_key: '', public_key: '' }
+
+ def load(filename, env = nil)
+ settings = File.exists?(filename) ? YAML.load(File.read(filename)) : {}
+ settings = settings[env.to_s] || {} if env
+ settings.each { |key, value| self[key] = value }
+ self
+ end
+
+ def export_env!
+ export_env.each { |key, value| ENV[key] = value }
+ end
+
+ def export_env
+ collector = lambda do |hash, stack|
+ hash.map do |key, value|
+ stack.push(key.to_s.upcase)
+ result = value.is_a?(Hash) ? collector.call(value, stack) : [stack.join('_'), value]
+ result.tap { stack.pop }
+ end
+ end
+ Hash[*collector.call(self, [self.class.env_namespace].compact).flatten]
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.