From 1b69b148deb618cee9a9308e873e0deb369022d8 Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Wed, 12 Nov 2008 09:47:24 -0600 Subject: [PATCH] More Ruby 1.9 Compatibility fixes Still a long way to go, but these will help. --- config/environment.rb | 2 +- lib/chunks/wiki.rb | 8 ++++---- lib/rdocsupport.rb | 14 ++++++++++---- lib/wiki_words.rb | 17 +++++++++-------- script/server | 9 ++++++--- test/functional/file_controller_test.rb | 6 +++++- test/unit/wiki_words_test.rb | 1 + 7 files changed, 36 insertions(+), 21 deletions(-) diff --git a/config/environment.rb b/config/environment.rb index cf16fad1..a15d97ef 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -58,4 +58,4 @@ end # Instiki-specific configuration below require_dependency 'instiki_errors' -require 'jcode' +#require 'jcode' diff --git a/lib/chunks/wiki.rb b/lib/chunks/wiki.rb index 27168c87..a57fc5a0 100644 --- a/lib/chunks/wiki.rb +++ b/lib/chunks/wiki.rb @@ -70,7 +70,7 @@ module WikiChunk attr_reader :escaped_text unless defined? WIKI_WORD - WIKI_WORD = Regexp.new('(":)?(\\\\)?(' + WikiWords::WIKI_WORD_PATTERN + ')\b', 0, "utf-8") + WIKI_WORD = Regexp.new('(":)?(\\\\)?(' + WikiWords::WIKI_WORD_PATTERN + ')\b', 0) end def self.pattern @@ -105,9 +105,9 @@ module WikiChunk unless defined? WIKI_LINK WIKI_LINK = /(":)?\[\[\s*([^\]\s][^\]]+?)\s*\]\]/ - LINK_TYPE_SEPARATION = Regexp.new('^(.+):((file)|(pic))$', 0, 'utf-8') - ALIAS_SEPARATION = Regexp.new('^(.+)\|(.+)$', 0, 'utf-8') - WEB_SEPARATION = Regexp.new('^(.+):(.+)$', 0, 'utf-8') + LINK_TYPE_SEPARATION = Regexp.new('^(.+):((file)|(pic))$', 0) + ALIAS_SEPARATION = Regexp.new('^(.+)\|(.+)$', 0) + WEB_SEPARATION = Regexp.new('^(.+):(.+)$', 0) end def self.pattern() WIKI_LINK end diff --git a/lib/rdocsupport.rb b/lib/rdocsupport.rb index 0aaf842f..b518a651 100644 --- a/lib/rdocsupport.rb +++ b/lib/rdocsupport.rb @@ -2,9 +2,15 @@ begin require "rdoc/markup/simple_markup" require 'rdoc/markup/simple_markup/to_html' rescue LoadError - # use old version if available - require 'markup/simple_markup' - require 'markup/simple_markup/to_html' + # Ruby 1.9 + require "rdoc/markup" + require 'rdoc/markup/to_html' + module SM + class SimpleMarkup < RDoc::Markup + end + class ToHtml 'ascii-8bit') + rescue #Ruby 1.8 + picture = File.read("#{RAILS_ROOT}/test/fixtures/rails.gif") + end # updated from post to get - post fails the spam protection (no javascript) # Moron! If substituting GET for POST actually works, you # have much, much bigger problems. diff --git a/test/unit/wiki_words_test.rb b/test/unit/wiki_words_test.rb index 62a7a908..1099c160 100755 --- a/test/unit/wiki_words_test.rb +++ b/test/unit/wiki_words_test.rb @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +#coding: utf-8 require File.expand_path(File.dirname(__FILE__) + '/../test_helper')