paru 0.2.5.5 → 0.2.5.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 387603a1b179250c37685c4095e17fcef016ce48
4
- data.tar.gz: 431ac92d161e735ad3cf9c70b2a5eda4acbc7618
3
+ metadata.gz: b314dd702e50bc29c3d5de54d00be79f76aeec99
4
+ data.tar.gz: c336ecb5371cfc4eeb23a36ec428cd59e939457e
5
5
  SHA512:
6
- metadata.gz: 3324360c90db6a4f85428fe9112daca4d0ee3010c10a3af24f27c5a0104fc8f28e86e2afbc5223eb889e21f78a3ef671d0c8a1e7d25ba9913e141a367af0df5e
7
- data.tar.gz: 50522a32e342f00eb75d98f8df0a4f76ae89e8e8c9196218c6ef823988c46957fd43d18c6f8d8fd8c7bc2fc37692e91a3fd388cf46a4f3ca4acb71e9150eab8c
6
+ metadata.gz: c72f808ac6e146ce331434edcad78293d4aaefea2bf657bd856cdbd3955f27b5ae133ae7bc3b2ff9a3bc8676ab54019cd9f53bd5a9c1050d8137af873d942b4c
7
+ data.tar.gz: 920e14f0aa27234ffaf1c6d0028c3ea4c93ee14708b5e07c9a8339d474f1def0aaca5d0375b9ed61a849dc777963f039421b280b82ec5a3a2cf468322a101644
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, 3]
21
+ VERSION = [0, 2, 5, 6]
22
22
  end
@@ -49,8 +49,8 @@ module Paru
49
49
  ]
50
50
  end
51
51
 
52
- undef_method :inner_markdown
53
- undef_method :inner_markdown=
52
+ #undef_method :inner_markdown
53
+ #undef_method :inner_markdown=
54
54
  end
55
55
  end
56
56
  end
data/lib/paru/pandoc.rb CHANGED
@@ -16,6 +16,7 @@
16
16
  # You should have received a copy of the GNU General Public License
17
17
  # along with Paru. If not, see <http://www.gnu.org/licenses/>.
18
18
  #++
19
+ require "open3"
19
20
  require "shellwords"
20
21
  require "yaml"
21
22
 
@@ -149,17 +150,7 @@ module Paru
149
150
  # @example Using <<
150
151
  # output = converter << 'this is a *strong* word'
151
152
  def convert(input)
152
- begin
153
- output = ''
154
- IO.popen(to_command, 'r+') do |p|
155
- p << input
156
- p.close_write
157
- output << p.read
158
- end
159
- output
160
- rescue StandardError => err
161
- throw Error.new "Error while running '#{to_command}' on input:\n\n#{input}\n\nPandoc responds: '#{err.message}'"
162
- end
153
+ run_converter to_command, input
163
154
  end
164
155
  alias << convert
165
156
 
@@ -175,17 +166,7 @@ module Paru
175
166
  # @example Using convert_file
176
167
  # output = converter.convert_file 'files/document.md'
177
168
  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
169
+ run_converter "#{to_command} #{input_file}"
189
170
  end
190
171
 
191
172
  # Create a string representation of this converter's pandoc command
@@ -295,6 +276,34 @@ module Paru
295
276
  end
296
277
  end
297
278
 
279
+ private
280
+
281
+ def run_converter(command, input = nil)
282
+ begin
283
+ output = ''
284
+ error = ''
285
+ status = 0
286
+
287
+ Open3.popen3(command) do |stdin, stdout, stderr, thread|
288
+ stdin << input unless input.nil?
289
+ stdin.close
290
+ output << stdout.read
291
+ error << stderr.read
292
+ status = thread.value.exitstatus
293
+ end
294
+
295
+ if 0 < status
296
+ # pandoc exited with an error
297
+ raise Paru::Error.new "error while running:\n\n#{command}\n\nPandoc responded with:\n\n#{error}\n"
298
+ end
299
+
300
+ output
301
+ rescue Paru::Error => err
302
+ raise err
303
+ rescue StandardError => err
304
+ throw Error.new "Unable to run pandoc via command '#{command}': #{err.message}"
305
+ end
306
+ end
298
307
  end
299
308
 
300
309
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paru
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5.5
4
+ version: 0.2.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Huub de Beer
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  requirements: []
109
109
  rubyforge_project:
110
- rubygems_version: 2.5.2
110
+ rubygems_version: 2.6.11
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: Paru is a ruby wrapper around pandoc