update settings logic, and heroku rake task
This commit is contained in:
parent
efe55f395d
commit
c45057bd94
4 changed files with 17 additions and 19 deletions
2
Gemfile
2
Gemfile
|
|
@ -40,7 +40,7 @@ group :heroku do
|
|||
gem 'pg'
|
||||
end
|
||||
|
||||
gem 'settingslogic', '2.0.6'
|
||||
gem 'settingslogic', :git => 'https://github.com/binarylogic/settingslogic.git'
|
||||
# database
|
||||
|
||||
gem 'activerecord-import'
|
||||
|
|
|
|||
|
|
@ -40,6 +40,12 @@ GIT
|
|||
specs:
|
||||
http_accept_language (1.0.1)
|
||||
|
||||
GIT
|
||||
remote: https://github.com/binarylogic/settingslogic.git
|
||||
revision: 4884d455bf18d92723cb8190cfd2dbf87f3aafd5
|
||||
specs:
|
||||
settingslogic (2.0.8)
|
||||
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
|
|
@ -360,7 +366,6 @@ GEM
|
|||
ffi (~> 1.0.9)
|
||||
multi_json (~> 1.0.4)
|
||||
rubyzip
|
||||
settingslogic (2.0.6)
|
||||
simple_oauth (0.1.5)
|
||||
sinatra (1.2.8)
|
||||
rack (~> 1.1)
|
||||
|
|
@ -479,7 +484,7 @@ DEPENDENCIES
|
|||
ruby-oembed
|
||||
sass
|
||||
selenium-webdriver (~> 2.16.0)
|
||||
settingslogic (= 2.0.6)
|
||||
settingslogic!
|
||||
sqlite3
|
||||
thin (~> 1.3.1)
|
||||
timecop
|
||||
|
|
|
|||
|
|
@ -6,9 +6,11 @@ require 'uri'
|
|||
require File.join(Rails.root, 'lib', 'enviroment_configuration')
|
||||
|
||||
class AppConfig < Settingslogic
|
||||
ARRAY_VARS = [:community_spotlight, :admins]
|
||||
|
||||
def self.source_file_name
|
||||
if ENV['application_yml'].present?
|
||||
puts "using remote application.yml"
|
||||
return ENV['application_yml']
|
||||
end
|
||||
config_file = File.join(Rails.root, "config", "application.yml")
|
||||
if !File.exists?(config_file) && (Rails.env == 'test' || Rails.env.include?("integration") || EnviromentConfiguration.heroku?)
|
||||
config_file = File.join(Rails.root, "config", "application.yml.example")
|
||||
|
|
@ -121,18 +123,9 @@ HELP
|
|||
|
||||
def self.[] (key)
|
||||
return self.pod_uri if key == :pod_uri
|
||||
return fetch_from_env(key.to_s) if EnviromentConfiguration.heroku?
|
||||
super
|
||||
end
|
||||
|
||||
def fetch_from_env(key)
|
||||
if ARRAY_VARS.include?(key.to_sym)
|
||||
ENV[key].split(EnviromentConfiguration::ARRAY_SEPERATOR)
|
||||
else
|
||||
ENV[key] if ENV[key]
|
||||
end
|
||||
end
|
||||
|
||||
def self.[]= (key, value)
|
||||
super
|
||||
if key.to_sym == :pod_url
|
||||
|
|
|
|||
|
|
@ -12,15 +12,15 @@ namespace :heroku do
|
|||
application_config = YAML.load_file('config/application.yml')['production'] rescue {}
|
||||
application_config.delete_if { |k, v| v.nil? or v.to_s.empty? }
|
||||
|
||||
heroku_env = application_config.map do|key, value|
|
||||
value =value.join(EnviromentConfiguration::ARRAY_SEPERATOR) if value.respond_to?(:join)
|
||||
#heroku_env = application_config.map do|key, value|
|
||||
#value =value.join(EnviromentConfiguration::ARRAY_SEPERATOR) if value.respond_to?(:join)
|
||||
|
||||
"#{key}=\"#{value}\""
|
||||
end.join(' ')
|
||||
#"#{key}=\"#{value}\""
|
||||
#end.join(' ')
|
||||
|
||||
puts "Generating and setting a new secret token"
|
||||
token = ActiveSupport::SecureRandom.hex(40)#reloads secret token every time you reload vars.... this expires cookies, and kinda sucks
|
||||
system "#{HEROKU_CONFIG_ADD_COMMAND} #{heroku_env} SECRET_TOKEN=#{token}"
|
||||
system "#{HEROKU_CONFIG_ADD_COMMAND} HEROKU=true SECRET_TOKEN=#{token}"
|
||||
end
|
||||
|
||||
task :install_requirements do
|
||||
|
|
|
|||
Loading…
Reference in a new issue