From f7044ecbb4cb05bc77dde83d81928b56ea45109b Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Wed, 2 Dec 2009 12:46:15 -0600 Subject: [PATCH] Ruby 1.9.1 Fixes Some more fixes to deal with Ruby 1.9.1. --- app/controllers/application_controller.rb | 5 +++++ app/controllers/wiki_controller.rb | 2 +- .../lib/form_tag_helper_extensions.rb | 2 +- vendor/plugins/maruku/lib/maruku/output/to_latex.rb | 8 ++++---- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b87d2680..fd7abeb6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -269,3 +269,8 @@ module Instiki end end end + +# Monkey patch, to make Hash#key work in Ruby 1.8 +class Hash + alias_method(:key, :index) unless method_defined?(:key) +end diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 23b1ec7e..19674e4f 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -438,7 +438,7 @@ class WikiController < ApplicationController "" end end - FileUtils.rm_rf(Dir[@wiki.storage_path.join(file_prefix + '*.zip')]) + FileUtils.rm_rf(Dir[@wiki.storage_path.join(file_prefix + '*.zip').to_s]) FileUtils.mv(tmp_path, file_path) send_file file_path end diff --git a/vendor/plugins/form_spam_protection/lib/form_tag_helper_extensions.rb b/vendor/plugins/form_spam_protection/lib/form_tag_helper_extensions.rb index 0a7ff9a2..44c939c8 100644 --- a/vendor/plugins/form_spam_protection/lib/form_tag_helper_extensions.rb +++ b/vendor/plugins/form_spam_protection/lib/form_tag_helper_extensions.rb @@ -11,7 +11,7 @@ module ActionView session[:form_keys][Digest::SHA1.hexdigest(form_key)] = [Time.now, 0] if session[:form_keys].length > 30 first = session[:form_keys].values.sort { |a,b| a[0] <=> b[0] } [0] - session[:form_keys].delete(session[:form_keys].index(first)) + session[:form_keys].delete(session[:form_keys].key(first)) end out << domEnkode(form_key) end diff --git a/vendor/plugins/maruku/lib/maruku/output/to_latex.rb b/vendor/plugins/maruku/lib/maruku/output/to_latex.rb index 8379b883..f1d05820 100644 --- a/vendor/plugins/maruku/lib/maruku/output/to_latex.rb +++ b/vendor/plugins/maruku/lib/maruku/output/to_latex.rb @@ -338,19 +338,19 @@ Otherwise, a standard `verbatim` environment is used. \\end{#{name}}\n" end - SAFE_CHARS = Set.new((?a..?z).to_a + (?A..?Z).to_a) + SAFE_CHARS = Set.new(('a'..'z').to_a + ('A'..'Z').to_a) # the ultimate escaping # (is much better than using \verb) def latex_escape(source) s=""; - source.each_byte do |b| - if b == ?\ + source.each_char do |b| + if b == '\\' s << '~' elsif SAFE_CHARS.include? b s << b else - s += "\\char%d" % b + s += "\\char%d" % b.ord end end s