paru 0.2.5.2 → 0.2.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/paru.rb +1 -1
  3. data/lib/paru/pandoc.rb +28 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 123f1097edc329ac82a90778e260cc336e6b5bd3
4
- data.tar.gz: 0427bccc5044f30c371671be6ad347179a2f2428
3
+ metadata.gz: 2f4e0a6ab8839d2b19d005de0d8caacbd5c87244
4
+ data.tar.gz: 8d358a982f09cb62b309d3cced5183bf6ff16c89
5
5
  SHA512:
6
- metadata.gz: 9b46f6684ac0f14248396a58a473309259837718c92ee97a52ac61e8870aa78e7f04033e6e50e699938f6e07c0fb10d26fc57da69e116d60a9634fc8ae764519
7
- data.tar.gz: 408f1a79436fe4431e2c94cdb567718a27b77a37a17b96539bafb7a2646cb14cf271c2c9aff138ee08cd86fa7ed1eff78e229f8db38dfe652a451e75bcb1450e
6
+ metadata.gz: a86c52201e8e4451ee4b7175bb5fece4c23b451302db3f56e9b887498427b08a19465631eb7da68edf236e6d8a2368bd8fec8417a70d6b98f77e8fb26855d26c
7
+ data.tar.gz: 05a2a5b0c2d426d73b69c6d33203a64681096070f48e586c9f5f02bde453199a5426ef08a52597bfdab17ca0fb75e97da042086e668ad08fc4fcc7b099f35975
data/lib/paru.rb CHANGED
@@ -18,5 +18,5 @@
18
18
  #++
19
19
  module Paru
20
20
  # Paru's current version
21
- VERSION = [0, 2, 5, 2]
21
+ VERSION = [0, 2, 5, 3]
22
22
  end
data/lib/paru/pandoc.rb CHANGED
@@ -137,7 +137,9 @@ module Paru
137
137
  # configured in this Pandoc instance.
138
138
  #
139
139
  # @param input [String] the input string to convert
140
- # @return [String] the converted output string
140
+ # @return [String] the converted output as a string. Note. For some
141
+ # formats, output to STDOUT is not supported (see pandoc's manual) and
142
+ # the result string will be empty.
141
143
  #
142
144
  # The following two examples are the same:
143
145
  #
@@ -161,6 +163,31 @@ module Paru
161
163
  end
162
164
  alias << convert
163
165
 
166
+ # Converts an input file to output string using the pandoc invocation
167
+ # configured in this Pandoc instance. The path to the input file is
168
+ # appended to that invocation.
169
+ #
170
+ # @param input_file [String] the path to the input file to convert
171
+ # @return [String] the converted output as a string. Note. For some
172
+ # formats, output to STDOUT is not supported (see pandoc's manual) and
173
+ # the result string will be empty.
174
+ #
175
+ # @example Using convert_file
176
+ # output = converter.convert_file 'files/document.md'
177
+ def convert_file(input_file)
178
+ command = "#{to_command} #{input_file}"
179
+ begin
180
+ output = ''
181
+ IO.popen(command, 'r+') do |p|
182
+ p.close_write
183
+ output << p.read
184
+ end
185
+ output
186
+ rescue StandardError => err
187
+ throw Error.new "Error while running '#{command}' on input:\n\n#{input}\n\nPandoc responds: '#{err.message}'"
188
+ end
189
+ end
190
+
164
191
  # Create a string representation of this converter's pandoc command
165
192
  # line invocation. This is useful for debugging purposes.
166
193
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paru
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5.2
4
+ version: 0.2.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Huub de Beer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-04 00:00:00.000000000 Z
11
+ date: 2017-08-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Use Pandoc (http://www.pandoc.org) with ruby
14
14
  email: Huub@heerdebeer.org