class Bookbinder::Postprocessing::Redirection
Public Class Methods
new(fs, file_path)
click to toggle source
# File lib/bookbinder/postprocessing/redirection.rb, line 4 def initialize(fs, file_path) @redirect_regexes = {} @redirect_strings = {} load!(fs, file_path) end
Public Instance Methods
redirected?(url)
click to toggle source
# File lib/bookbinder/postprocessing/redirection.rb, line 10 def redirected?(url) @redirect_strings.has_key?(url) || @redirect_regexes.keys.detect {|regex| regex.match(url)} end
Private Instance Methods
load!(fs, file_path)
click to toggle source
# File lib/bookbinder/postprocessing/redirection.rb, line 17 def load!(fs, file_path) if fs.is_file?(file_path) contents = fs.read(file_path) instance_eval contents end end
r301(source, dest, options={})
click to toggle source
# File lib/bookbinder/postprocessing/redirection.rb, line 24 def r301(source, dest, options={}) return if options.has_key?(:if) case source when Regexp @redirect_regexes[source] = dest when String @redirect_strings[source] = dest end end