From 49012793913217537d9fd1ebae5509a165dd90a3 Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Thu, 22 May 2008 09:36:23 -0500 Subject: [PATCH] Style: Don't put 'require' statements inside methods --- lib/chunks/engines.rb | 16 +++++----------- lib/chunks/nowiki.rb | 2 +- lib/wiki_content.rb | 3 ++- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/chunks/engines.rb b/lib/chunks/engines.rb index 84e984b0..892be49a 100644 --- a/lib/chunks/engines.rb +++ b/lib/chunks/engines.rb @@ -2,7 +2,10 @@ $: << File.dirname(__FILE__) + "../../lib" require_dependency 'chunks/chunk' require 'stringsupport' - +require 'maruku' +require 'maruku/ext/math' +require_dependency 'rdocsupport' +require 'redcloth' # The markup engines are Chunks that call the one of RedCloth # or RDoc to convert text. This markup occurs when the chunk is required @@ -27,7 +30,6 @@ module Engines class Textile < AbstractEngine def mask - require 'redcloth' redcloth = RedCloth.new(@content, [:hard_breaks] + @content.options[:engine_opts]) redcloth.filter_html = false redcloth.no_span_caps = false @@ -37,9 +39,6 @@ module Engines class Markdown < AbstractEngine def mask - require 'maruku' - require 'maruku/ext/math' - # If the request is for S5, call Maruku accordingly (without math) if @content.options[:mode] == :s5 my_content = Maruku.new(@content.delete("\r").to_utf8, @@ -57,9 +56,6 @@ module Engines class MarkdownMML < AbstractEngine def mask - require 'maruku' - require 'maruku/ext/math' - # If the request is for S5, call Maruku accordingly if @content.options[:mode] == :s5 my_content = Maruku.new(@content.delete("\r").to_utf8, @@ -81,7 +77,6 @@ module Engines class Mixed < AbstractEngine def mask - require 'redcloth' redcloth = RedCloth.new(@content, @content.options[:engine_opts]) redcloth.filter_html = false redcloth.no_span_caps = false @@ -91,11 +86,10 @@ module Engines class RDoc < AbstractEngine def mask - require_dependency 'rdocsupport' html = RDocSupport::RDocFormatter.new(@content).to_html end end MAP = { :textile => Textile, :markdown => Markdown, :markdownMML => MarkdownMML, :mixed => Mixed, :rdoc => RDoc } - MAP.default = Textile + MAP.default = MarkdownMML end diff --git a/lib/chunks/nowiki.rb b/lib/chunks/nowiki.rb index 23f97f6f..6d9641ef 100644 --- a/lib/chunks/nowiki.rb +++ b/lib/chunks/nowiki.rb @@ -1,4 +1,5 @@ require 'chunks/chunk' +require 'sanitize' # This chunks allows certain parts of a wiki page to be hidden from the # rest of the rendering pipeline. It should be run at the beginning @@ -16,7 +17,6 @@ require 'chunks/chunk' class NoWiki < Chunk::Abstract - require 'sanitize' include Sanitize NOWIKI_PATTERN = Regexp.new('(.*?)', Regexp::MULTILINE) diff --git a/lib/wiki_content.rb b/lib/wiki_content.rb index b72b20b3..1e1593ed 100644 --- a/lib/wiki_content.rb +++ b/lib/wiki_content.rb @@ -5,6 +5,8 @@ require_dependency 'chunks/include' require_dependency 'chunks/wiki' require_dependency 'chunks/literal' require 'chunks/nowiki' +require 'sanitizer' + # Wiki content is just a string that can process itself with a chain of # actions. The actions can modify wiki content so that certain parts of @@ -112,7 +114,6 @@ end class WikiContent < String - require 'sanitizer' include ChunkManager include Sanitizer