Permalink
Browse files

Do not generate paths like /a/b/c/config/boot.rb/../../Gemfile to re…

…quire and open things, create a proper path instead.
  • Loading branch information...
1 parent 2a7a0b7 commit bf27cca03a516cf127d18d81171096909792418c @jhass jhass committed Nov 30, 2012
Showing with 10 additions and 13 deletions.
  1. +1 −0 Changelog.md
  2. +2 −1 config/application.rb
  3. +3 −8 config/boot.rb
  4. +1 −1 config/environment.rb
  5. +3 −3 config/initializers/locale.rb
View
1 Changelog.md
@@ -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
3 config/application.rb
@@ -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
11 config/boot.rb
@@ -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
2 config/environment.rb
@@ -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
6 config/initializers/locale.rb
@@ -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"

0 comments on commit bf27cca

Please sign in to comment.