Sha256: af74ea85e489dbc4db77df8b15eafd1d0998a1a2cfae83d7a32c1617f9fa3d62
Contents?: true
Size: 1.12 KB
Versions: 21
Compression:
Stored size: 1.12 KB
Contents
require "github/markup/command_implementation" require "github/markup/gem_implementation" module GitHub module Markup extend self @@markups = [] def markups @@markups end def preload! markups.each do |markup| markup.load end end def render(filename, content = nil) content ||= File.read(filename) if impl = renderer(filename) impl.render(content) else content end end def markup(file, pattern, opts = {}, &block) markups << GemImplementation.new(pattern, file, &block) end def command(command, regexp, name, &block) if File.exist?(file = File.dirname(__FILE__) + "/commands/#{command}") command = file end markups << CommandImplementation.new(regexp, command, name, &block) end def can_render?(filename) !!renderer(filename) end def renderer(filename) markups.find { |impl| impl.match?(filename) } end # Define markups markups_rb = File.dirname(__FILE__) + '/markups.rb' instance_eval File.read(markups_rb), markups_rb end end
Version data entries
21 entries across 21 versions & 2 rubygems