pandoc-ruby 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,13 +19,13 @@ Next, install PandocRuby from gemcutter.
19
19
  @converter = PandocRuby.new('/some/file.md', :from => :markdown, :to => :rst)
20
20
  puts @converter.convert
21
21
 
22
- This takes the the Markdown formatted file and converts it to reStructuredText.
22
+ This takes the Markdown formatted file and converts it to reStructuredText.
23
23
 
24
- You can also use the `#convert` class method:
24
+ You can use the `#convert` class method:
25
25
 
26
26
  puts PandocRuby.convert('/some/file.md', :from => :markdown, :to => :html)
27
27
 
28
- Another also: you get a `#to_s`, for somewhat nicer use in Rails views.
28
+ Included is a `#to_s` method for somewhat nicer use in Rails views.
29
29
 
30
30
  ... helper file ...
31
31
  def format(text)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -10,7 +10,7 @@ class PandocRuby
10
10
  ]
11
11
 
12
12
  def self.bin_path=(path)
13
- @@bin_path = bin_path
13
+ @@bin_path = path
14
14
  end
15
15
 
16
16
  def self.convert(*args)
@@ -35,20 +35,17 @@ class PandocRuby
35
35
  end
36
36
 
37
37
  def convert
38
- if @@bin_path
39
- execute File.join(@@bin_path, @executable) + convert_options
40
- else
41
- execute @executable + convert_options
42
- end
38
+ executable = @@bin_path ? File.join(@@bin_path, @executable) : @executable
39
+ execute executable + convert_options
43
40
  end
44
41
  alias_method :to_s, :convert
45
42
 
46
43
  def convert_options
47
44
  @options.inject('') do |string, (flag, value)|
48
- if flag.to_s.length == 1
49
- string + " -#{flag} #{value}"
45
+ string + if flag.to_s.length == 1
46
+ " -#{flag} #{value}"
50
47
  else
51
- string + " --#{flag}=#{value}"
48
+ " --#{flag}=#{value}"
52
49
  end
53
50
  end
54
51
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{pandoc-ruby}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["William Melody"]
@@ -8,33 +8,45 @@ class PandocRubyTest < Test::Unit::TestCase
8
8
  @converter = PandocRuby.new(@file, :t => :rst)
9
9
  end
10
10
 
11
- should "convert mimic default behavior" do
11
+ def teardown
12
+ PandocRuby.bin_path = nil
13
+ end
14
+
15
+ should "call bare pandoc when passed no options" do
16
+ converter = PandocRuby.new(@file)
17
+ converter.expects(:execute).with('pandoc').returns(true)
18
+ assert converter.convert
19
+ end
20
+
21
+ should "convert with altered bin_path" do
22
+ path = %x[which pandoc].strip
23
+ PandocRuby.bin_path = path
12
24
  converter = PandocRuby.new(@file)
13
- assert converter.expects(:execute).with('pandoc').returns(true)
14
- converter.convert
25
+ converter.expects(:execute).with("#{path}/pandoc").returns(true)
26
+ assert converter.convert
15
27
  end
16
28
 
17
29
  should "accept short options" do
18
- assert @converter.expects(:execute).with('pandoc -t rst').returns(true)
19
- @converter.convert
30
+ @converter.expects(:execute).with('pandoc -t rst').returns(true)
31
+ assert @converter.convert
20
32
  end
21
33
 
22
34
  should "accept long options" do
23
35
  converter = PandocRuby.new(@file, :to => :rst)
24
- assert converter.expects(:execute).with('pandoc --to=rst').returns(true)
25
- converter.convert
36
+ converter.expects(:execute).with('pandoc --to=rst').returns(true)
37
+ assert converter.convert
26
38
  end
27
39
 
28
40
  should "accept optional executable" do
29
41
  converter = PandocRuby.new(@file, 'html2markdown')
30
- assert converter.expects(:execute).with('html2markdown').returns(true)
31
- converter.convert
42
+ converter.expects(:execute).with('html2markdown').returns(true)
43
+ assert converter.convert
32
44
  end
33
45
 
34
46
  should "not accept non-pandoc optional executable" do
35
47
  converter = PandocRuby.new(@file, 'ls')
36
- assert converter.expects(:execute).with('pandoc').returns(true)
37
- converter.convert
48
+ converter.expects(:execute).with('pandoc').returns(true)
49
+ assert converter.convert
38
50
  end
39
51
 
40
52
  should "work with strings" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pandoc-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Melody