From: Tom Hughes Date: Thu, 2 Sep 2010 21:49:30 +0000 (+0100) Subject: Use Rails.xxx instead of RAILS_XXX X-Git-Tag: live~6774 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/e1213a4651e72beb660dddcf467d353744e3f336?ds=sidebyside Use Rails.xxx instead of RAILS_XXX --- diff --git a/app/controllers/amf_controller.rb b/app/controllers/amf_controller.rb index 078823cbb..534e41a80 100644 --- a/app/controllers/amf_controller.rb +++ b/app/controllers/amf_controller.rb @@ -265,14 +265,14 @@ class AmfController < ApplicationController loaded_lang = 'en' # Load English defaults - en = YAML::load(File.open("#{RAILS_ROOT}/config/potlatch/locales/en.yml"))["en"] + en = YAML::load(File.open("#{Rails.root}/config/potlatch/locales/en.yml"))["en"] if lang == 'en' return [loaded_lang, en] else # Use English as a fallback begin - other = YAML::load(File.open("#{RAILS_ROOT}/config/potlatch/locales/#{lang}.yml"))[lang] + other = YAML::load(File.open("#{Rails.root}/config/potlatch/locales/#{lang}.yml"))[lang] loaded_lang = lang rescue other = en @@ -916,7 +916,7 @@ class AmfController < ApplicationController end def getlocales - Dir.glob("#{RAILS_ROOT}/config/potlatch/locales/*").collect { |f| File.basename(f, ".yml") } + Dir.glob("#{Rails.root}/config/potlatch/locales/*").collect { |f| File.basename(f, ".yml") } end ## diff --git a/app/views/site/key.html.erb b/app/views/site/key.html.erb index d0fd36148..294224b18 100644 --- a/app/views/site/key.html.erb +++ b/app/views/site/key.html.erb @@ -1,6 +1,6 @@
- <% YAML.load_file("#{RAILS_ROOT}/config/key.yml").each do |name,data| %> + <% YAML.load_file("#{Rails.root}/config/key.yml").each do |name,data| %> <% if params[:layer] == name %> <% data.each do |entry| %> <% if params[:zoom].to_i >= entry['min_zoom'] && params[:zoom].to_i <= entry['max_zoom'] %> diff --git a/config/initializers/i18n.rb b/config/initializers/i18n.rb index 8aadeaacf..2561c07f2 100644 --- a/config/initializers/i18n.rb +++ b/config/initializers/i18n.rb @@ -37,6 +37,6 @@ end I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization) I18n::Backend::Simple.send(:include, I18n::Backend::PluralizationFallback) -I18n.load_path << RAILS_ROOT + "/config/pluralizers.rb" +I18n.load_path << "#{Rails.root}/config/pluralizers.rb" I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks) diff --git a/config/initializers/wiki_pages.rb b/config/initializers/wiki_pages.rb index dbaa4ddac..0b6f7be2a 100644 --- a/config/initializers/wiki_pages.rb +++ b/config/initializers/wiki_pages.rb @@ -1 +1 @@ -WIKI_PAGES = YAML.load_file("#{RAILS_ROOT}/config/wiki_pages.yml") +WIKI_PAGES = YAML.load_file("#{Rails.root}/config/wiki_pages.yml") diff --git a/db/migrate/034_create_languages.rb b/db/migrate/034_create_languages.rb index ab5a7eee6..27994b3fe 100644 --- a/db/migrate/034_create_languages.rb +++ b/db/migrate/034_create_languages.rb @@ -10,7 +10,7 @@ class CreateLanguages < ActiveRecord::Migration add_primary_key :languages, [:code] - Language.load(RAILS_ROOT + "/config/languages.yml") + Language.load("#{Rails.root}/config/languages.yml") add_foreign_key :users, [:locale], :languages, [:code] add_foreign_key :diary_entries, [:language_code], :languages, [:code] diff --git a/lib/osm.rb b/lib/osm.rb index 60e33c7db..8416aab5a 100644 --- a/lib/osm.rb +++ b/lib/osm.rb @@ -529,8 +529,8 @@ module OSM end def self.legal_text_for_country(country_code) - file_name = File.join(RAILS_ROOT, "config", "legales", country_code.to_s + ".yml") - file_name = File.join(RAILS_ROOT, "config", "legales", DEFAULT_LEGALE + ".yml") unless File.exist? file_name + file_name = File.join(Rails.root, "config", "legales", country_code.to_s + ".yml") + file_name = File.join(Rails.root, "config", "legales", DEFAULT_LEGALE + ".yml") unless File.exist? file_name YAML::load_file(file_name) end end diff --git a/lib/potlatch.rb b/lib/potlatch.rb index 29ab4535a..ef3be79a8 100644 --- a/lib/potlatch.rb +++ b/lib/potlatch.rb @@ -97,7 +97,7 @@ module Potlatch when 'FalseClass' 0.chr+encodedouble(0) else - RAILS_DEFAULT_LOGGER.error("Unexpected Ruby type for AMF conversion: "+n.class.to_s) + Rails.logger.error("Unexpected Ruby type for AMF conversion: "+n.class.to_s) end end @@ -130,7 +130,7 @@ module Potlatch # [3] colours, [4] casing, [5] areas, [6] autotags # (all hashes) def self.get_presets - RAILS_DEFAULT_LOGGER.info(" Message: getpresets") + Rails.logger.info(" Message: getpresets") # Read preset menus presets={} @@ -139,7 +139,7 @@ module Potlatch presettype='' presetcategory='' # StringIO.open(txt) do |file| - File.open("#{RAILS_ROOT}/config/potlatch/presets.txt") do |file| + File.open("#{Rails.root}/config/potlatch/presets.txt") do |file| file.each_line {|line| t=line.chomp if (t=~/(\w+)\/(\w+)/) then @@ -160,7 +160,7 @@ module Potlatch # Read colours/styling colours={}; casing={}; areas={} - File.open("#{RAILS_ROOT}/config/potlatch/colours.txt") do |file| + File.open("#{Rails.root}/config/potlatch/colours.txt") do |file| file.each_line {|line| t=line.chomp if (t=~/(\w+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)/) then @@ -174,7 +174,7 @@ module Potlatch # Read relations colours/styling relcolours={}; relalphas={}; relwidths={} - File.open("#{RAILS_ROOT}/config/potlatch/relation_colours.txt") do |file| + File.open("#{Rails.root}/config/potlatch/relation_colours.txt") do |file| file.each_line {|line| t=line.chomp if (t=~/(\w+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)/) then @@ -188,7 +188,7 @@ module Potlatch # Read POI presets icon_list=[]; icon_tags={}; - File.open("#{RAILS_ROOT}/config/potlatch/icon_presets.txt") do |file| + File.open("#{Rails.root}/config/potlatch/icon_presets.txt") do |file| file.each_line {|line| (icon,tags)=line.chomp.split("\t") icon_list.push(icon) @@ -199,7 +199,7 @@ module Potlatch # Read auto-complete autotags={}; autotags['point']={}; autotags['way']={}; autotags['POI']={}; - File.open("#{RAILS_ROOT}/config/potlatch/autocomplete.txt") do |file| + File.open("#{Rails.root}/config/potlatch/autocomplete.txt") do |file| file.each_line {|line| t=line.chomp if (t=~/^([\w:]+)\/(\w+)\s+(.+)$/) then diff --git a/test/test_helper.rb b/test/test_helper.rb index 16b678f83..7d2aa405f 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -168,7 +168,7 @@ class ActiveSupport::TestCase rots_response = Net::HTTP.get_response(URI.parse("http://localhost:1123/")) rescue # It isn't, so start a new instance. - rots = IO.popen(RAILS_ROOT + "/vendor/gems/rots-0.2.1/bin/rots --silent") + rots = IO.popen("#{Rails.root}/vendor/gems/rots-0.2.1/bin/rots --silent") # Wait for up to 30 seconds for the server to start and respond before continuing for i in (1 .. 30)