Do not generate paths like /a/b/c/config/boot.rb/../../Gemfile to require and open things, create a proper path instead.

This commit is contained in:
Jonne Haß 2012-11-30 18:16:23 +01:00
parent 2a7a0b7b99
commit bf27cca03a
5 changed files with 10 additions and 13 deletions

View file

@ -8,6 +8,7 @@
* Extracted configuration system to a gem.
* Made number of unicorn workers configurable.
* Made loading of the configuration environment independent of Rails.
* Do not generate paths like `/a/b/c/config/boot.rb/../../Gemfile` to require and open things, create a proper path instead.
## Bug Fixes

View file

@ -2,7 +2,8 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require File.expand_path('../boot', __FILE__)
require 'pathname'
require Pathname.new(__FILE__).expand_path.dirname.join('boot')
# Needed for versions of ruby 1.9.2 that were compiled with libyaml.
# They use psych by default which doesn't handle having a default set of parameters.

View file

@ -2,17 +2,12 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
if RUBY_VERSION.include?("1.9")
require 'yaml'
YAML::ENGINE.yamler= 'syck'
end
require 'rubygems'
require 'pathname'
# Set up gems listed in the Gemfile.
gemfile = File.expand_path('../../Gemfile', __FILE__)
gemfile = Pathname.new(__FILE__).dirname.join('..').expand_path.join('Gemfile')
begin
ENV['BUNDLE_GEMFILE'] = gemfile
ENV['BUNDLE_GEMFILE'] = gemfile.to_s
require 'bundler'
Bundler.setup
rescue Bundler::GemNotFound => e

View file

@ -12,7 +12,7 @@ def sqlite?
end
# Load the rails application
require File.expand_path('../application', __FILE__)
require Pathname.new(__FILE__).dirname.expand_path.join('application')
require Rails.root.join("lib", "exceptions")
# Load configuration system early

View file

@ -5,9 +5,9 @@
require 'i18n_interpolation_fallbacks'
require "i18n/backend/fallbacks"
if File.exists?(File.expand_path("./config/locale_settings.yml"))
locale_settings = YAML::load(File.open(File.expand_path("./config/locale_settings.yml")))
settings_file = Pathname.new(__FILE__).dirname.join('..').expand_path.join('locale_settings.yml')
if settings_file.exist?
locale_settings = YAML.load_file(settings_file)
AVAILABLE_LANGUAGES = (locale_settings['available'].length > 0) ? locale_settings['available'] : { "en" => 'English' }
AVAILABLE_LANGUAGE_CODES = locale_settings['available'].keys
DEFAULT_LANGUAGE = (AVAILABLE_LANGUAGE_CODES.include?(locale_settings['default'].to_s)) ? locale_settings['default'].to_s : "en"