Rework application configuration

Use a preinitializer to load the settings from application.yml so
that they are available as early as possible. All settings can also
be overridden using environment variables.

The ad-hoc settins in environment.rb are then moved to this new
system so we have one consistent location for settings.
This commit is contained in:
Tom Hughes 2010-08-04 22:06:05 +01:00
parent 8b9cacd3c2
commit f07819d81a
33 changed files with 100 additions and 99 deletions

View file

@ -58,7 +58,7 @@ class Node < ActiveRecord::Base
find_by_area(min_lat, min_lon, max_lat, max_lon,
:conditions => {:visible => true},
:limit => APP_CONFIG['max_number_of_nodes']+1)
:limit => MAX_NUMBER_OF_NODES+1)
end
# Read in xml as text and return it's Node object representation

View file

@ -105,7 +105,7 @@ private
end
def from_header(name, type, id, digest)
if domain = APP_CONFIG['messages_domain']
if domain = MESSAGES_DOMAIN
from quote_address_if_necessary("#{name} <#{type}-#{id}-#{digest[0,6]}@#{domain}>", "utf-8")
end
end

View file

@ -8,7 +8,7 @@ class SpamObserver < ActiveRecord::Observer
when record.is_a?(DiaryComment): user = record.user
end
if user.status == "active" and user.spam_score > APP_CONFIG['spam_threshold']
if user.status == "active" and user.spam_score > SPAM_THRESHOLD
user.update_attributes(:status => "suspended")
end
end

View file

@ -5,7 +5,7 @@ class UserBlock < ActiveRecord::Base
belongs_to :creator, :class_name => "User", :foreign_key => :creator_id
belongs_to :revoker, :class_name => "User", :foreign_key => :revoker_id
PERIODS = APP_CONFIG['user_block_periods']
PERIODS = USER_BLOCK_PERIODS
##
# returns true if the block is currently active (i.e: the user can't

View file

@ -234,8 +234,8 @@ class Way < ActiveRecord::Base
def preconditions_ok?(old_nodes = [])
return false if self.nds.empty?
if self.nds.length > APP_CONFIG['max_number_of_way_nodes']
raise OSM::APITooManyWayNodesError.new(self.id, self.nds.length, APP_CONFIG['max_number_of_way_nodes'])
if self.nds.length > MAX_NUMBER_OF_WAY_NODES
raise OSM::APITooManyWayNodesError.new(self.id, self.nds.length, MAX_NUMBER_OF_WAY_NODES)
end
# check only the new nodes, for efficiency - old nodes having been checked last time and can't