remove trailing white-spaces from lib/redmine/configuration.rb.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6943 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-09-01 00:48:02 +00:00
parent ab558ee331
commit 7d26d8167b

View File

@ -5,42 +5,42 @@
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2 # as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version. # of the License, or (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module Redmine module Redmine
module Configuration module Configuration
# Configuration default values # Configuration default values
@defaults = { @defaults = {
'email_delivery' => nil 'email_delivery' => nil
} }
@config = nil @config = nil
class << self class << self
# Loads the Redmine configuration file # Loads the Redmine configuration file
# Valid options: # Valid options:
# * <tt>:file</tt>: the configuration file to load (default: config/configuration.yml) # * <tt>:file</tt>: the configuration file to load (default: config/configuration.yml)
# * <tt>:env</tt>: the environment to load the configuration for (default: Rails.env) # * <tt>:env</tt>: the environment to load the configuration for (default: Rails.env)
def load(options={}) def load(options={})
filename = options[:file] || File.join(Rails.root, 'config', 'configuration.yml') filename = options[:file] || File.join(Rails.root, 'config', 'configuration.yml')
env = options[:env] || Rails.env env = options[:env] || Rails.env
@config = @defaults.dup @config = @defaults.dup
load_deprecated_email_configuration(env) load_deprecated_email_configuration(env)
if File.file?(filename) if File.file?(filename)
@config.merge!(load_from_yaml(filename, env)) @config.merge!(load_from_yaml(filename, env))
end end
# Compatibility mode for those who copy email.yml over configuration.yml # Compatibility mode for those who copy email.yml over configuration.yml
%w(delivery_method smtp_settings sendmail_settings).each do |key| %w(delivery_method smtp_settings sendmail_settings).each do |key|
if value = @config.delete(key) if value = @config.delete(key)
@ -48,7 +48,7 @@ module Redmine
@config['email_delivery'][key] = value @config['email_delivery'][key] = value
end end
end end
if @config['email_delivery'] if @config['email_delivery']
ActionMailer::Base.perform_deliveries = true ActionMailer::Base.perform_deliveries = true
@config['email_delivery'].each do |k, v| @config['email_delivery'].each do |k, v|
@ -56,16 +56,16 @@ module Redmine
ActionMailer::Base.send("#{k}=", v) ActionMailer::Base.send("#{k}=", v)
end end
end end
@config @config
end end
# Returns a configuration setting # Returns a configuration setting
def [](name) def [](name)
load unless @config load unless @config
@config[name] @config[name]
end end
# Yields a block with the specified hash configuration settings # Yields a block with the specified hash configuration settings
def with(settings) def with(settings)
settings.stringify_keys! settings.stringify_keys!
@ -75,9 +75,9 @@ module Redmine
yield if block_given? yield if block_given?
@config.merge! was @config.merge! was
end end
private private
def load_from_yaml(filename, env) def load_from_yaml(filename, env)
yaml = YAML::load_file(filename) yaml = YAML::load_file(filename)
conf = {} conf = {}
@ -94,7 +94,7 @@ module Redmine
end end
conf conf
end end
def load_deprecated_email_configuration(env) def load_deprecated_email_configuration(env)
deprecated_email_conf = File.join(Rails.root, 'config', 'email.yml') deprecated_email_conf = File.join(Rails.root, 'config', 'email.yml')
if File.file?(deprecated_email_conf) if File.file?(deprecated_email_conf)