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.
- data/HISTORY.md +8 -0
- data/README.md +6 -0
- data/Rakefile +3 -0
- data/lib/github/markup.rb +11 -2
- data/lib/github/markup/version.rb +1 -1
- data/test/markup_test.rb +16 -15
- metadata +2 -1
data/HISTORY.md
ADDED
data/README.md
CHANGED
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}"
|
data/lib/github/markup.rb
CHANGED
@@ -10,7 +10,11 @@ module GitHub
|
|
10
10
|
@@markups = {}
|
11
11
|
|
12
12
|
def render(filename, content)
|
13
|
-
renderer(filename)
|
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)
|
data/test/markup_test.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
12
|
-
|
11
|
+
define_method "test_#{markup}" do
|
12
|
+
expected = File.read("#{readme}.html")
|
13
|
+
actual = GitHub::Markup.render(readme, File.read(readme))
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
27
|
-
|
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.
|
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
|