module ActsAsMarkup

Constants

LIBRARY_EXTENSIONS
MARKDOWN_LIBS
VERSION

Public Class Methods

markup_class(markup_name) click to toggle source
# File lib/acts_as_markup.rb, line 38
def markup_class(markup_name)
  load_markup_class(markup_name)
end
version() click to toggle source
# File lib/acts_as_markup.rb, line 34
def version
  VERSION
end

Private Class Methods

get_markdown_class() click to toggle source
# File lib/acts_as_markup.rb, line 44
def get_markdown_class
  if ActsAsMarkup::MARKDOWN_LIBS.keys.include? ActsAsMarkup.markdown_library
    markdown_library_names = ActsAsMarkup::MARKDOWN_LIBS[ActsAsMarkup.markdown_library]
    require markdown_library_names[:lib_name]
    require_extensions(markdown_library_names[:lib_name])
    return markdown_library_names[:class_name].constantize
  else
    raise ActsAsMarkup::UnsportedMarkdownLibrary, "#{ActsAsMarkup.markdown_library} is not currently supported."
  end
end
load_markup_class(markup_name) click to toggle source
# File lib/acts_as_markup.rb, line 77
def load_markup_class(markup_name)
  if [:markdown, :textile, :rdoc].include?(markup_name.to_sym)
    require_library_and_get_class(markup_name.to_sym)
  else
    raise ActsAsMarkup::UnsupportedMarkupLanguage, "#{markup_name} is not a currently supported markup language."
  end
end
require_library_and_get_class(language) click to toggle source
# File lib/acts_as_markup.rb, line 61
def require_library_and_get_class(language)
  case language
  when :markdown
    return get_markdown_class
  when :textile
    require 'redcloth'
    return RedCloth
  when :rdoc
    require 'rdoc'
    require_extensions 'rdoc'
    return RDocText
  else
    return String
  end
end