github_markup 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,8 @@
1
+ ## 0.1.1 (2009-11-02)
2
+
3
+ * Added `GitHub::Markup.can_render?` helper.
4
+ * Bugfix: Actually check file extensions
5
+
6
+ ## 0.1.0 (2009-11-02)
7
+
8
+ * First release
data/README.md CHANGED
@@ -54,6 +54,12 @@ Tests should be added in the same manner as described under the
54
54
  `Commands` section.
55
55
 
56
56
 
57
+ Installation
58
+ -----------
59
+
60
+ gem install github_markup --source=http://gemcutter.org
61
+
62
+
57
63
  Usage
58
64
  -----
59
65
 
data/Rakefile CHANGED
@@ -34,6 +34,9 @@ rescue LoadError
34
34
  puts "sdoc support not enabled. Please gem install sdoc-helpers."
35
35
  end
36
36
 
37
+ desc "Build a gem"
38
+ task :gem => [ :gemspec, :build ]
39
+
37
40
  desc "Push a new version to Gemcutter"
38
41
  task :publish => [ :test, :gemspec, :build ] do
39
42
  system "git tag v#{GitHub::Markup::Version}"
@@ -10,7 +10,11 @@ module GitHub
10
10
  @@markups = {}
11
11
 
12
12
  def render(filename, content)
13
- renderer(filename)[content] || content
13
+ if proc = renderer(filename)
14
+ proc[content]
15
+ else
16
+ content
17
+ end
14
18
  end
15
19
 
16
20
  def markup(file, pattern, &block)
@@ -36,12 +40,17 @@ module GitHub
36
40
  @@markups[regexp] = block
37
41
  end
38
42
 
43
+ def can_render?(filename)
44
+ !!renderer(filename)
45
+ end
46
+
39
47
  def renderer(filename)
40
48
  @@markups.each do |key, value|
41
- if Regexp.compile("(#{key})$") =~ filename
49
+ if Regexp.compile("\\.(#{key})$") =~ filename
42
50
  return value
43
51
  end
44
52
  end
53
+ nil
45
54
  end
46
55
 
47
56
  def execute(command, target)
@@ -1,5 +1,5 @@
1
1
  module GitHub
2
2
  module Markup
3
- Version = '0.1.0'
3
+ Version = '0.1.1'
4
4
  end
5
5
  end
@@ -1,28 +1,29 @@
1
1
  $LOAD_PATH.unshift File.dirname(__FILE__) + "/../lib"
2
2
 
3
3
  require 'github/markup'
4
+ require 'test/unit'
4
5
 
5
- def test_markup
6
- passed = true
6
+ class MarkupTest < Test::Unit::TestCase
7
7
  Dir['test/markups/README.*'].each do |readme|
8
8
  next if readme =~ /html$/
9
9
  markup = readme.split('.').last
10
10
 
11
- expected = File.read("#{readme}.html")
12
- actual = GitHub::Markup.render(readme, File.read(readme))
11
+ define_method "test_#{markup}" do
12
+ expected = File.read("#{readme}.html")
13
+ actual = GitHub::Markup.render(readme, File.read(readme))
13
14
 
14
- if expected == actual
15
- puts "- #{markup}: OK"
16
- else
17
- passed = false
18
- puts "- #{markup}: FAIL"
19
- puts "#{markup} expected:", expected
20
- puts "#{markup} actual:", actual
15
+ assert expected == actual, <<-message
16
+ #{markup} expected:
17
+ #{expected}
18
+ #{markup} actual:
19
+ #{actual}
20
+ message
21
21
  end
22
22
  end
23
- passed
24
- end
25
23
 
26
- at_exit do
27
- exit test_markup ? 0 : 1
24
+ def test_knows_what_it_can_and_cannot_render
25
+ assert_equal false, GitHub::Markup.can_render?('README.html')
26
+ assert_equal true, GitHub::Markup.can_render?('README.markdown')
27
+ assert_equal false, GitHub::Markup.can_render?('README.cmd')
28
+ end
28
29
  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.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Wanstrath
@@ -25,6 +25,7 @@ extra_rdoc_files:
25
25
  files:
26
26
  - .gitignore
27
27
  - .kick
28
+ - HISTORY.md
28
29
  - LICENSE
29
30
  - README.md
30
31
  - Rakefile