github-markup 0.1.3 → 0.1.4

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.4 (2009-11-17)
2
+
3
+ * Bugfix: Missing commands return the input (instead of nothing)
4
+
1
5
  ## 0.1.3 (2009-11-02)
2
6
 
3
7
  * Strip the INDEX comments from POD
@@ -26,6 +26,7 @@ module GitHub
26
26
 
27
27
  def command(command, regexp, &block)
28
28
  command = command.to_s
29
+
29
30
  if !File.exists?(command) && !command.include?('/')
30
31
  command = File.dirname(__FILE__) + '/commands/' + command.to_s
31
32
  end
@@ -54,6 +55,8 @@ module GitHub
54
55
  end
55
56
 
56
57
  def execute(command, target)
58
+ return target if !system("which #{command} > /dev/null")
59
+
57
60
  out = ''
58
61
  Open3.popen3(command) do |stdin, stdout, _|
59
62
  stdin.puts target
@@ -1,5 +1,5 @@
1
1
  module GitHub
2
2
  module Markup
3
- Version = '0.1.3'
3
+ Version = '0.1.4'
4
4
  end
5
5
  end
@@ -20,9 +20,10 @@ command(:asciidoc2html, /asciidoc/)
20
20
  # Any block passed to `command` will be handed the command's STDOUT for
21
21
  # post processing.
22
22
  command("/usr/bin/env pod2html", /pod/) do |rendered|
23
+ require 'fileutils'
23
24
  if rendered =~ /<body.+?>\s*(.+)\s*<\/body>/mi
24
- `rm pod2htmd.tmp` if File.exists?('pod2htmd.tmp') rescue nil
25
- `rm pod2htmi.tmp` if File.exists?('pod2htmi.tmp') rescue nil
25
+ FileUtils.rm("pod2htmd.tmp") if File.exists?('pod2htmd.tmp') rescue nil
26
+ FileUtils.rm("pod2htmi.tmp") if File.exists?('pod2htmi.tmp') rescue nil
26
27
  $1.sub('<!-- INDEX BEGIN -->', '').sub('<!-- INDEX END -->', '')
27
28
  end
28
29
  end
@@ -26,4 +26,12 @@ message
26
26
  assert_equal true, GitHub::Markup.can_render?('README.markdown')
27
27
  assert_equal false, GitHub::Markup.can_render?('README.cmd')
28
28
  end
29
+
30
+ def test_fails_gracefully_on_missing_commands
31
+ GitHub::Markup.command(:i_made_it_up, /mde/)
32
+ text = 'hi there'
33
+ assert_equal true, GitHub::Markup.can_render?('README.mde')
34
+ actual = GitHub::Markup.render('README.mde', text)
35
+ assert_equal text, actual
36
+ end
29
37
  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.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Wanstrath
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-02 00:00:00 -08:00
12
+ date: 2009-11-17 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15