Module: GitHub::Markup

Extended by:
Markup
Included in:
Markup
Defined in:
lib/github-markup.rb,
lib/github/markup.rb,
lib/github/markup/rdoc.rb,
lib/github/markup/markdown.rb,
lib/github/markup/implementation.rb,
lib/github/markup/gem_implementation.rb,
lib/github/markup/command_implementation.rb

Defined Under Namespace

Classes: CommandError, CommandImplementation, GemImplementation, Implementation, Markdown, RDoc

Constant Summary collapse

VERSION =
'1.9.0'
Version =
VERSION
@@markups =
[]

Instance Method Summary collapse

Instance Method Details

#can_render?(filename) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/github/markup.rb', line 41

def can_render?(filename)
  !!renderer(filename)
end

#command(command, regexp, name, &block) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/github/markup.rb', line 33

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

#markup(file, pattern, opts = {}, &block) ⇒ Object



29
30
31
# File 'lib/github/markup.rb', line 29

def markup(file, pattern, opts = {}, &block)
  markups << GemImplementation.new(pattern, file, &block)
end

#markupsObject



9
10
11
# File 'lib/github/markup.rb', line 9

def markups
  @@markups
end

#preload!Object



13
14
15
16
17
# File 'lib/github/markup.rb', line 13

def preload!
  markups.each do |markup|
    markup.load
  end
end

#render(filename, content = nil) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/github/markup.rb', line 19

def render(filename, content = nil)
  content ||= File.read(filename)

  if impl = renderer(filename)
    impl.render(content)
  else
    content
  end
end

#renderer(filename) ⇒ Object



45
46
47
48
49
# File 'lib/github/markup.rb', line 45

def renderer(filename)
  markups.find { |impl|
    impl.match?(filename)
  }
end