diff --git a/Rakefile b/Rakefile index 81fbce0b..ca153db9 100644 --- a/Rakefile +++ b/Rakefile @@ -47,7 +47,7 @@ task :default => :test require 'rake/testtask' Rake::TestTask.new(:test) do |test| - test.libs << 'lib' << 'test' + test.libs << 'lib' << 'test' << '.' test.pattern = 'test/**/test_*.rb' test.verbose = true end @@ -143,4 +143,4 @@ task :validate do puts "A `VERSION` file at root level violates Gem best practices." exit! end -end \ No newline at end of file +end diff --git a/lib/gollum.rb b/lib/gollum.rb index 4b8c44f7..f4b82ca7 100644 --- a/lib/gollum.rb +++ b/lib/gollum.rb @@ -1,11 +1,15 @@ # stdlib require 'digest/md5' +require 'ostruct' # external require 'grit' require 'github/markup' require 'sanitize' +# ruby 1.8 compatibility +require 'gollum/ruby1.8' + # internal require 'gollum/pagination' require 'gollum/wiki' diff --git a/lib/gollum/markup.rb b/lib/gollum/markup.rb index 0a6fe3a9..6359c528 100644 --- a/lib/gollum/markup.rb +++ b/lib/gollum/markup.rb @@ -320,7 +320,7 @@ module Gollum @codemap.each do |id, spec| lang = spec[:lang] code = spec[:code] - if code.all? { |line| line =~ /\A\r?\n\Z/ || line =~ /^( |\t)/ } + if code.lines.all? { |line| line =~ /\A\r?\n\Z/ || line =~ /^( |\t)/ } code.gsub!(/^( |\t)/m, '') end data.gsub!(id, Gollum::Albino.new(code, lang).colorize) @@ -328,4 +328,4 @@ module Gollum data end end -end \ No newline at end of file +end diff --git a/lib/gollum/ruby1.8.rb b/lib/gollum/ruby1.8.rb new file mode 100644 index 00000000..d24d5f29 --- /dev/null +++ b/lib/gollum/ruby1.8.rb @@ -0,0 +1,3 @@ +class String + alias :lines :to_a if defined?(RUBY_VERSION) && RUBY_VERSION < '1.9' +end diff --git a/lib/gollum/wiki.rb b/lib/gollum/wiki.rb index 09df6bd1..d4d68b6e 100644 --- a/lib/gollum/wiki.rb +++ b/lib/gollum/wiki.rb @@ -332,4 +332,4 @@ module Gollum map end end -end \ No newline at end of file +end diff --git a/test/test_page.rb b/test/test_page.rb index 6f2376e9..0df52ecf 100644 --- a/test/test_page.rb +++ b/test/test_page.rb @@ -1,3 +1,4 @@ +# ~*~ encoding: utf-8 ~*~ require File.join(File.dirname(__FILE__), *%w[helper]) context "Page" do @@ -109,4 +110,4 @@ context "Page" do footer = @wiki.page("_Footer") assert_nil footer.footer end -end \ No newline at end of file +end