pandoc-ruby 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -6
- data/Rakefile +31 -0
- data/lib/pandoc-ruby.rb +14 -16
- data/pandoc-ruby.gemspec +2 -2
- data/test/test_pandoc_ruby.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02f0af2a61483032f01e2d07de58a08bb63625a9
|
4
|
+
data.tar.gz: 84fcc719beb7c3ec49ec3d5b6411ab8e74a2ff84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9c155e6003414f32e8eeaf1922b4aec59afb301e7b5055619a539ab8e7a7588928acb0cc2a4a8bd8a9ca66a88c41c2ffed3854ba77cfa3da0db3a1872c943aa
|
7
|
+
data.tar.gz: c605f036e0f8dd80fad8b6a58468e6f8b17535d12b0fa4518c5d7724909cebec3dd432ed929f42c588631a706572e71384bed40e6a95c0b8e3430f11818e2a0a
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
json (1.8.3)
|
5
4
|
metaclass (0.0.4)
|
6
|
-
minitest (5.8.
|
5
|
+
minitest (5.8.5)
|
7
6
|
mocha (1.1.0)
|
8
7
|
metaclass (~> 0.0.1)
|
9
|
-
rake (
|
10
|
-
rdoc (
|
11
|
-
json (~> 1.4)
|
8
|
+
rake (12.1.0)
|
9
|
+
rdoc (5.1.0)
|
12
10
|
|
13
11
|
PLATFORMS
|
14
12
|
ruby
|
@@ -20,4 +18,4 @@ DEPENDENCIES
|
|
20
18
|
rdoc
|
21
19
|
|
22
20
|
BUNDLED WITH
|
23
|
-
1.
|
21
|
+
1.14.3
|
data/Rakefile
CHANGED
@@ -29,3 +29,34 @@ Rake::RDocTask.new do |rdoc|
|
|
29
29
|
rdoc.rdoc_files.include('README*')
|
30
30
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
31
31
|
end
|
32
|
+
|
33
|
+
require './lib/pandoc-ruby.rb'
|
34
|
+
desc <<HEREDOC
|
35
|
+
Regenerate test files in existing formats.
|
36
|
+
HEREDOC
|
37
|
+
task :regenerate_files do
|
38
|
+
extensions = []
|
39
|
+
files_dir = File.join(File.dirname(__FILE__), 'test', 'files')
|
40
|
+
|
41
|
+
Dir.glob(File.join(files_dir, 'format*')) do |f|
|
42
|
+
extensions << f.match(/format\.(\w+)\Z/)[1]
|
43
|
+
end
|
44
|
+
|
45
|
+
from_content = File.read(File.join(files_dir, 'format.markdown'))
|
46
|
+
|
47
|
+
extensions.each do |to|
|
48
|
+
next if to == 'markdown'
|
49
|
+
|
50
|
+
to_file = File.join(files_dir, "format.#{to}")
|
51
|
+
|
52
|
+
converted_content = PandocRuby.convert(
|
53
|
+
from_content,
|
54
|
+
:from => 'markdown',
|
55
|
+
:to => to
|
56
|
+
)
|
57
|
+
|
58
|
+
File.open(to_file, 'w') do |file|
|
59
|
+
file.write(converted_content)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/pandoc-ruby.rb
CHANGED
@@ -71,6 +71,11 @@ class PandocRuby
|
|
71
71
|
new(*args).convert
|
72
72
|
end
|
73
73
|
|
74
|
+
attr_writer :binary_output
|
75
|
+
def binary_output
|
76
|
+
@binary_output ||= false
|
77
|
+
end
|
78
|
+
|
74
79
|
attr_writer :options
|
75
80
|
def options
|
76
81
|
@options ||= []
|
@@ -81,16 +86,14 @@ class PandocRuby
|
|
81
86
|
@option_string ||= ''
|
82
87
|
end
|
83
88
|
|
84
|
-
attr_writer :binary_output
|
85
|
-
def binary_output
|
86
|
-
@binary_output ||= false
|
87
|
-
end
|
88
|
-
|
89
89
|
attr_writer :writer
|
90
90
|
def writer
|
91
91
|
@writer ||= 'html'
|
92
92
|
end
|
93
93
|
|
94
|
+
attr_accessor :input_files
|
95
|
+
attr_accessor :input_string
|
96
|
+
|
94
97
|
# Create a new PandocRuby converter object. The first argument contains the
|
95
98
|
# input either as string or as an array of filenames.
|
96
99
|
#
|
@@ -101,13 +104,10 @@ class PandocRuby
|
|
101
104
|
# new(["/path/to/file.md"], :option1 => :value, :option2)
|
102
105
|
# new(["/to/file1.html", "/to/file2.html"], :option1 => :value)
|
103
106
|
def initialize(*args)
|
104
|
-
@input_string = nil
|
105
|
-
@input_files = nil
|
106
|
-
|
107
107
|
if args[0].is_a?(String)
|
108
|
-
|
108
|
+
self.input_string = args.shift
|
109
109
|
elsif args[0].is_a?(Array)
|
110
|
-
|
110
|
+
self.input_files = args.shift.join(' ')
|
111
111
|
end
|
112
112
|
self.options = args
|
113
113
|
end
|
@@ -192,8 +192,8 @@ class PandocRuby
|
|
192
192
|
|
193
193
|
# Wrapper to run pandoc in a consistent, DRY way
|
194
194
|
def execute_pandoc
|
195
|
-
if !
|
196
|
-
execute("#{@@pandoc_path} #{
|
195
|
+
if !self.input_files.nil?
|
196
|
+
execute("#{@@pandoc_path} #{self.input_files}#{self.option_string}")
|
197
197
|
else
|
198
198
|
execute("#{@@pandoc_path}#{self.option_string}")
|
199
199
|
end
|
@@ -206,10 +206,8 @@ class PandocRuby
|
|
206
206
|
Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|
|
207
207
|
begin
|
208
208
|
Timeout.timeout(@timeout) do
|
209
|
-
|
210
|
-
|
211
|
-
stdin.close
|
212
|
-
end
|
209
|
+
stdin.puts self.input_string
|
210
|
+
stdin.close
|
213
211
|
output = stdout.read
|
214
212
|
error = stderr.read
|
215
213
|
exit_status = wait_thr.value
|
data/pandoc-ruby.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = 'pandoc-ruby'
|
8
|
-
s.version = '2.0.
|
8
|
+
s.version = '2.0.2'
|
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']
|
12
|
-
s.date = '
|
12
|
+
s.date = '2017-09-17'
|
13
13
|
s.description = 'Ruby wrapper for Pandoc'
|
14
14
|
s.email = 'hi@williammelody.com'
|
15
15
|
s.extra_rdoc_files = [
|
data/test/test_pandoc_ruby.rb
CHANGED
@@ -133,6 +133,16 @@ describe PandocRuby do
|
|
133
133
|
assert_match(/h2/, converter.convert)
|
134
134
|
end
|
135
135
|
|
136
|
+
it 'accepts blank strings' do
|
137
|
+
converter = PandocRuby.new('')
|
138
|
+
assert_match("\n", converter.convert)
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'accepts nil and treats like a blank string' do
|
142
|
+
converter = PandocRuby.new(nil)
|
143
|
+
assert_match("\n", converter.convert)
|
144
|
+
end
|
145
|
+
|
136
146
|
it 'aliases to_s' do
|
137
147
|
assert_equal @converter.convert, @converter.to_s
|
138
148
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pandoc-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Melody
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mocha
|