More Ruby 1.9 Compatibility fixes

Still a long way to go, but these will help.
This commit is contained in:
Jacques Distler 2008-11-12 09:47:24 -06:00
parent 3efc067f06
commit 1b69b148de
7 changed files with 36 additions and 21 deletions

View file

@ -58,4 +58,4 @@ end
# Instiki-specific configuration below # Instiki-specific configuration below
require_dependency 'instiki_errors' require_dependency 'instiki_errors'
require 'jcode' #require 'jcode'

View file

@ -70,7 +70,7 @@ module WikiChunk
attr_reader :escaped_text attr_reader :escaped_text
unless defined? WIKI_WORD 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 end
def self.pattern def self.pattern
@ -105,9 +105,9 @@ module WikiChunk
unless defined? WIKI_LINK unless defined? WIKI_LINK
WIKI_LINK = /(":)?\[\[\s*([^\]\s][^\]]+?)\s*\]\]/ WIKI_LINK = /(":)?\[\[\s*([^\]\s][^\]]+?)\s*\]\]/
LINK_TYPE_SEPARATION = Regexp.new('^(.+):((file)|(pic))$', 0, 'utf-8') LINK_TYPE_SEPARATION = Regexp.new('^(.+):((file)|(pic))$', 0)
ALIAS_SEPARATION = Regexp.new('^(.+)\|(.+)$', 0, 'utf-8') ALIAS_SEPARATION = Regexp.new('^(.+)\|(.+)$', 0)
WEB_SEPARATION = Regexp.new('^(.+):(.+)$', 0, 'utf-8') WEB_SEPARATION = Regexp.new('^(.+):(.+)$', 0)
end end
def self.pattern() WIKI_LINK end def self.pattern() WIKI_LINK end

View file

@ -2,9 +2,15 @@ begin
require "rdoc/markup/simple_markup" require "rdoc/markup/simple_markup"
require 'rdoc/markup/simple_markup/to_html' require 'rdoc/markup/simple_markup/to_html'
rescue LoadError rescue LoadError
# use old version if available # Ruby 1.9
require 'markup/simple_markup' require "rdoc/markup"
require 'markup/simple_markup/to_html' require 'rdoc/markup/to_html'
module SM
class SimpleMarkup < RDoc::Markup
end
class ToHtml <RDoc::Markup::ToHtml
end
end
end end
module RDocSupport module RDocSupport

View file

@ -1,17 +1,18 @@
#coding: utf-8
# Contains all the methods for finding and replacing wiki words # Contains all the methods for finding and replacing wiki words
module WikiWords module WikiWords
# In order of appearance: Latin, greek, cyrillian, armenian # In order of appearance: Latin, greek, cyrillian, armenian
I18N_HIGHER_CASE_LETTERS = I18N_HIGHER_CASE_LETTERS =
"À<EFBFBD>?ÂÃÄÅĀĄĂÆÇĆČĈĊĎ<C48A>?ÈÉÊËĒĘĚĔĖĜĞĠĢĤĦÌ<C4A6><>?ĪĨĬĮİIJĴĶ<C4B4>?ĽĹĻĿÑŃŇŅŊÒÓÔÕÖØŌ<C398>?ŎŒŔŘŖŚŠŞŜȘŤŢŦȚÙÚÛÜŪŮŰŬŨŲŴ<EFBFBD>?ŶŸŹŽŻ" + "ÀÁÂÃÄÅĀĄĂÆÇĆČĈĊĎĐÈÉÊËĒĘĚĔĖĜĞĠĢĤĦÌÍÎÏĪĨĬĮİIJĴĶŁĽĹĻĿÑŃŇŅŊÒÓÔÕÖØŌŐŎŒŔŘŖŚŠŞŜȘŤŢŦȚÙÚÛÜŪŮŰŬŨŲŴŶŸȲÝŹŽŻ" +
"ΑΒΓΔΕΖΗΘΙΚΛΜ<EFBFBD>?ΞΟΠΡΣΤΥΦΧΨΩ" + "ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ" +
"ΆΈΉΊΌΎ<EFBFBD>?ѠѢѤѦѨѪѬѮѰѲѴѶѸѺѼѾҀҊҌҎ<D28C>?ҒҔҖҘҚҜҞҠҢҤҦҨҪҬҮҰҲҴҶҸҺҼҾ<D2BC>?ӃӅӇӉӋ<D389>?<3F>?ӒӔӖӘӚӜӞӠӢӤӦӨӪӬӮӰӲӴӸЖ" + "ΆΈΉΊΌΎΏѠѢѤѦѨѪѬѮѰѲѴѶѸѺѼѾҀҊҌҎҐҒҔҖҘҚҜҞҠҢҤҦҨҪҬҮҰҲҴҶҸҺҼҾӁӃӅӇӉӋӍӏӐӒӔӖӘӚӜӞӠӢӤӦӨӪӬӮӰӲӴӸЖ" +
"ԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀ<EFBFBD>?ՂՃՄՅՆՇՈՉՊՋՌ<D58B>?<3F>?<3F>?ՑՒՓՔՕՖ" "ԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖ"
I18N_LOWER_CASE_LETTERS = I18N_LOWER_CASE_LETTERS =
"àáâãäå<EFBFBD>?ąăæçć<C3A7>?ĉċ<C489>?đèéêëēęěĕėƒ<C497>?ğġģĥħìíîïīĩĭįıijĵķĸłľĺļŀñńňņʼnŋòóôõöø<C3B6><>?œŕřŗśšş<C5A1>?șťţŧțùúûüūůűŭũųŵýÿŷžżźÞþßſ<EFBFBD>?ð" + "àáâãäåāąăæçćĉċčďđèéêëēęěĕėƒĝğġģĥħìíîïīĩĭįıijĵķĸłľĺļŀñńňņʼnŋòóôõöøōŏőœŕřŗśŝšşșťţŧțùúûüūůűŭũųŵýÿŷžżźÞþßſð" +
"άέήίΰαβγδεζηθικλμνξοπ<EFBFBD>στυφχψωϊϋό<CF8B><>?" + "άέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύώΐ" +
"абвгдежзийклмнопр<EFBFBD>уфхцчшщъыь<D18B><>?<3F>?ёђѓєѕіїјљћќ<D19B>?ўџѡѣѥѧѩѫѭѯѱѳѵѷѹѻѽѿ<D1BD><>?<3F>?ґғҕҗҙқ<D299>?ҟҡңҥҧҩҫҭүұҳҵҷҹһҽҿӀӂӄӆӈӊӌӎӑӓӕӗәӛ<D399>?ӟӡӣӥӧөӫӭӯӱӳӵӹ" + "абвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓєѕіїјљћќѝўџѡѣѥѧѩѫѭѯѱѳѵѷѹѻѽѿҁҋҌҍҏґғҕҗҙқҝҟҡңҥҧҩҫҭүұҳҵҷҹһҽҿӀӂӄӆӈӊӌӎӑӓӕӗәӛӝӟӡӣӥӧөӫӭӯӱӳӵӹ" +
"աբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտր<EFBFBD>?ւփքօֆև" "աբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆև"
WIKI_WORD_PATTERN = '[A-Z' + I18N_HIGHER_CASE_LETTERS + '][a-z' + I18N_LOWER_CASE_LETTERS + ']+[A-Z' + I18N_HIGHER_CASE_LETTERS + ']\w+' WIKI_WORD_PATTERN = '[A-Z' + I18N_HIGHER_CASE_LETTERS + '][a-z' + I18N_LOWER_CASE_LETTERS + ']+[A-Z' + I18N_HIGHER_CASE_LETTERS + ']\w+'
CAMEL_CASED_WORD_BORDER = /([a-z#{I18N_LOWER_CASE_LETTERS}])([A-Z#{I18N_HIGHER_CASE_LETTERS}])/u CAMEL_CASED_WORD_BORDER = /([a-z#{I18N_LOWER_CASE_LETTERS}])([A-Z#{I18N_HIGHER_CASE_LETTERS}])/u

View file

@ -32,13 +32,16 @@ ARGV.options do |opts|
opts.on("-p", "--port=port", Integer, opts.on("-p", "--port=port", Integer,
"Runs Instiki on the specified port.", "Runs Instiki on the specified port.",
"Default: 2500") { |OPTIONS[:port]| } "Default: 2500") { }
# "Default: 2500") { |OPTIONS[:port]| }
opts.on("-b", "--binding=ip", String, opts.on("-b", "--binding=ip", String,
"Binds Instiki to the specified ip.", "Binds Instiki to the specified ip.",
"Default: 0.0.0.0") { |OPTIONS[:ip]| } "Default: 0.0.0.0") { }
# "Default: 0.0.0.0") { |OPTIONS[:ip]| }
opts.on("-e", "--environment=name", String, opts.on("-e", "--environment=name", String,
"Specifies the environment to run this server under (test/development/production).", "Specifies the environment to run this server under (test/development/production).",
"Default: development") { |OPTIONS[:environment]| } "Default: development") { }
# "Default: development") { |OPTIONS[:environment]| }
opts.on("-d", "--daemon", opts.on("-d", "--daemon",
"Make Instiki run as a Daemon (only works if fork is available -- meaning on *nix)." "Make Instiki run as a Daemon (only works if fork is available -- meaning on *nix)."
) { OPTIONS[:server_type] = WEBrick::Daemon } ) { OPTIONS[:server_type] = WEBrick::Daemon }

View file

@ -90,7 +90,11 @@ class FileControllerTest < Test::Unit::TestCase
assert_template 'file/file' assert_template 'file/file'
# User uploads the picture # User uploads the picture
picture = File.read("#{RAILS_ROOT}/test/fixtures/rails.gif") begin # Ruby 1.9
picture = File.read("#{RAILS_ROOT}/test/fixtures/rails.gif", :encoding => '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) # updated from post to get - post fails the spam protection (no javascript)
# Moron! If substituting GET for POST actually works, you # Moron! If substituting GET for POST actually works, you
# have much, much bigger problems. # have much, much bigger problems.

View file

@ -1,4 +1,5 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
#coding: utf-8
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') require File.expand_path(File.dirname(__FILE__) + '/../test_helper')