github-markup 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.md +4 -0
- data/lib/github/markup.rb +4 -4
- data/lib/github/markup/version.rb +1 -1
- data/test/markup_test.rb +9 -1
- metadata +1 -1
data/HISTORY.md
CHANGED
data/lib/github/markup.rb
CHANGED
@@ -27,10 +27,12 @@ module GitHub
|
|
27
27
|
def command(command, regexp, &block)
|
28
28
|
command = command.to_s
|
29
29
|
|
30
|
-
if
|
31
|
-
command =
|
30
|
+
if File.exists?(file = File.dirname(__FILE__) + "/commands/#{command}")
|
31
|
+
command = file
|
32
32
|
end
|
33
33
|
|
34
|
+
return if !system("which #{command} > /dev/null")
|
35
|
+
|
34
36
|
add_markup(regexp) do |content|
|
35
37
|
rendered = execute(command, content)
|
36
38
|
block ? block.call(rendered) : rendered
|
@@ -55,8 +57,6 @@ module GitHub
|
|
55
57
|
end
|
56
58
|
|
57
59
|
def execute(command, target)
|
58
|
-
return target if !system("which #{command} > /dev/null")
|
59
|
-
|
60
60
|
out = ''
|
61
61
|
Open3.popen3(command) do |stdin, stdout, _|
|
62
62
|
stdin.puts target
|
data/test/markup_test.rb
CHANGED
@@ -30,8 +30,16 @@ message
|
|
30
30
|
def test_fails_gracefully_on_missing_commands
|
31
31
|
GitHub::Markup.command(:i_made_it_up, /mde/)
|
32
32
|
text = 'hi there'
|
33
|
-
assert_equal
|
33
|
+
assert_equal false, GitHub::Markup.can_render?('README.mde')
|
34
34
|
actual = GitHub::Markup.render('README.mde', text)
|
35
35
|
assert_equal text, actual
|
36
36
|
end
|
37
|
+
|
38
|
+
def test_fails_gracefully_on_missing_env_commands
|
39
|
+
GitHub::Markup.command('/usr/bin/env totally_fake', /tf/)
|
40
|
+
text = 'hey mang'
|
41
|
+
assert_equal false, GitHub::Markup.can_render?('README.tf')
|
42
|
+
actual = GitHub::Markup.render('README.tf', text)
|
43
|
+
assert_equal text, actual
|
44
|
+
end
|
37
45
|
end
|