Skip to content

Commit 6900a6f

Browse files
zkoppertCopilot
andcommitted
Use explicit module references in lib/github/markups.rb
Replaces the bare DSL (markup, command, markup_impl) with fully-qualified GitHub::Markup.* calls so the file can be loaded via require_relative instead of instance_eval. This lets SimpleCov track coverage of the registration logic. Co-authored-by: Copilot <[email protected]> Signed-off-by: Zack Koppert <[email protected]>
1 parent b86a513 commit 6900a6f

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

lib/github/markup.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ def language(filename, content, symlink: false)
9797
end
9898

9999
# Define markups
100-
markups_rb = File.dirname(__FILE__) + '/markups.rb'
101-
instance_eval File.read(markups_rb), markups_rb
100+
require_relative 'markups'
102101
end
103102
end

lib/github/markups.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,32 @@
22
require "github/markup/rdoc"
33
require "shellwords"
44

5-
markup_impl(::GitHub::Markups::MARKUP_MARKDOWN, ::GitHub::Markup::Markdown.new)
5+
GitHub::Markup.markup_impl(::GitHub::Markups::MARKUP_MARKDOWN, ::GitHub::Markup::Markdown.new)
66

7-
markup(::GitHub::Markups::MARKUP_TEXTILE, :redcloth, /textile/, ["Textile"]) do |filename, content, options: {}|
7+
GitHub::Markup.markup(::GitHub::Markups::MARKUP_TEXTILE, :redcloth, /textile/, ["Textile"]) do |filename, content, options: {}|
88
RedCloth.new(content).to_html
99
end
1010

11-
markup_impl(::GitHub::Markups::MARKUP_RDOC, GitHub::Markup::RDoc.new)
11+
GitHub::Markup.markup_impl(::GitHub::Markups::MARKUP_RDOC, GitHub::Markup::RDoc.new)
1212

13-
markup(::GitHub::Markups::MARKUP_ORG, 'org-ruby', /org/, ["Org"]) do |filename, content, options: {}|
13+
GitHub::Markup.markup(::GitHub::Markups::MARKUP_ORG, 'org-ruby', /org/, ["Org"]) do |filename, content, options: {}|
1414
Orgmode::Parser.new(content, {
1515
:allow_include_files => false,
1616
:skip_syntax_highlight => true
1717
}).to_html
1818
end
1919

20-
markup(::GitHub::Markups::MARKUP_CREOLE, :creole, /creole/, ["Creole"]) do |filename, content, options: {}|
20+
GitHub::Markup.markup(::GitHub::Markups::MARKUP_CREOLE, :creole, /creole/, ["Creole"]) do |filename, content, options: {}|
2121
Creole.creolize(content)
2222
end
2323

24-
markup(::GitHub::Markups::MARKUP_MEDIAWIKI, :wikicloth, /mediawiki|wiki/, ["MediaWiki"]) do |filename, content, options: {}|
24+
GitHub::Markup.markup(::GitHub::Markups::MARKUP_MEDIAWIKI, :wikicloth, /mediawiki|wiki/, ["MediaWiki"]) do |filename, content, options: {}|
2525
wikicloth = WikiCloth::WikiCloth.new(:data => content)
2626
WikiCloth::WikiBuffer::HTMLElement::ESCAPED_TAGS << 'tt' unless WikiCloth::WikiBuffer::HTMLElement::ESCAPED_TAGS.include?('tt')
2727
wikicloth.to_html(:noedit => true)
2828
end
2929

30-
markup(::GitHub::Markups::MARKUP_ASCIIDOC, :asciidoctor, /adoc|asc(iidoc)?/, ["AsciiDoc"]) do |filename, content, options: {}|
30+
GitHub::Markup.markup(::GitHub::Markups::MARKUP_ASCIIDOC, :asciidoctor, /adoc|asc(iidoc)?/, ["AsciiDoc"]) do |filename, content, options: {}|
3131
attributes = {
3232
'showtitle' => '@',
3333
'idprefix' => '',
@@ -47,13 +47,13 @@
4747
Asciidoctor.convert(content, :safe => :secure, :attributes => attributes)
4848
end
4949

50-
command(
50+
GitHub::Markup.command(
5151
::GitHub::Markups::MARKUP_RST,
5252
"python3 #{Shellwords.escape(File.dirname(__FILE__))}/commands/rest2html",
5353
/re?st(\.txt)?/,
5454
["reStructuredText"],
5555
"restructuredtext"
5656
)
5757

58-
command(::GitHub::Markups::MARKUP_POD6, :pod62html, /pod6/, ["Pod 6"], "pod6")
59-
command(::GitHub::Markups::MARKUP_POD, :pod2html, /pod/, ["Pod"], "pod")
58+
GitHub::Markup.command(::GitHub::Markups::MARKUP_POD6, :pod62html, /pod6/, ["Pod 6"], "pod6")
59+
GitHub::Markup.command(::GitHub::Markups::MARKUP_POD, :pod2html, /pod/, ["Pod"], "pod")

0 commit comments

Comments
 (0)