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 CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.1.5 (2009-11-17)
2
+
3
+ * Actually, if we can't render a thing then don't. Not once, not never.
4
+
1
5
  ## 0.1.4 (2009-11-17)
2
6
 
3
7
  * Bugfix: Missing commands return the input (instead of nothing)
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 !File.exists?(command) && !command.include?('/')
31
- command = File.dirname(__FILE__) + '/commands/' + command.to_s
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
@@ -1,5 +1,5 @@
1
1
  module GitHub
2
2
  module Markup
3
- Version = '0.1.4'
3
+ Version = '0.1.5'
4
4
  end
5
5
  end
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 true, GitHub::Markup.can_render?('README.mde')
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-markup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Wanstrath