Permalink
Browse files

change for compliance: rails 2.3 and 3.1

  • Loading branch information...
1 parent 63a4847 commit f58ba5e826a3fcf614f6b878d139b80ea5952a36 @mflorisson committed Jan 25, 2012
Showing with 16 additions and 5 deletions.
  1. +2 −1 install.rb
  2. +11 −2 lib/map_layers/view_helpers.rb
  3. +3 −2 tasks/map_layers_tasks.rake
View
@@ -3,7 +3,8 @@
Dir.chdir(Dir.getwd.sub(/vendor.*/, '')) do
def copy_files(source_path, destination_path, plugin_root)
- source, destination = File.join(File.expand_path(plugin_root), source_path), File.join(Rails.root, destination_path)
+ rails_root = ( defined?( RAILS_ROOT)) ? RAILS_ROOT : Rails.root
+ source, destination = File.join(File.expand_path(plugin_root), source_path), File.join( rails_root, destination_path)
FileUtils.mkdir(destination) unless File.exist?(destination)
FileUtils.cp_r(source, destination)
end
@@ -27,7 +27,16 @@ def map_layers_includes(options = {})
if options.has_key?(:img_path)
img_path = options[:img_path]
end
- if Rails.env == "development" && File.exist?(File.join(Rails.root, 'public/javascripts/lib/OpenLayers.js'))
+ if defined?( RAILS_ROOT)
+ rails_env = RAILS_ENV
+ rails_root = RAILS_ROOT
+ rails_relative_url_root = ENV['RAILS_RELATIVE_URL_ROOT']
+ else
+ rails_env = Rails.env
+ rails_root = Rails.root
+ rails_relative_url_root = controller.config.relative_url_root
+ end
+ if rails_env == "development" && File.exist?(File.join( rails_root, 'public/javascripts/lib/OpenLayers.js'))
html << '<script src="/javascripts/lib/Firebug/firebug.js"></script>'
html << '<script src="/javascripts/lib/OpenLayers.js"></script>'
else
@@ -36,7 +45,7 @@ def map_layers_includes(options = {})
html << stylesheet_link_tag("map")
- img_path=(Pathname(ENV['RAILS_RELATIVE_URL_ROOT']||"") +img_path).cleanpath.to_s
+ img_path=(Pathname(rails_relative_url_root||"") +img_path).cleanpath.to_s
html << javascript_tag("OpenLayers.ImgPath='"+ img_path + "/';")
proxy = options.has_key?(:proxy) ? options[:proxy] : controller.controller_name
html << javascript_tag("OpenLayers.ProxyHost='/#{proxy}/proxy?url=';")
@@ -7,7 +7,8 @@ namespace :map_layers do
end
def copy_files(source_path, destination_path, plugin_root)
- source, destination = File.join(plugin_root, source_path), File.join(Rails.root, destination_path)
+ rails_root = ( defined?(RAILS_ROOT)) ? RAILS_ROOT : Rails.root
+ source, destination = File.join(plugin_root, source_path), File.join(rails_root, destination_path)
FileUtils.mkdir(destination) unless File.exist?(destination)
FileUtils.cp_r(source, destination)
end
@@ -18,4 +19,4 @@ namespace :map_layers do
end
-end
+end

0 comments on commit f58ba5e

Please sign in to comment.