nanoc-tidy.rb 0.6.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee29f7af6d3dbaf443aa2e35e52e696f184481641a493a29292d110760776c07
4
- data.tar.gz: c42f3696900ea751574072d35a0005ed4dd2442cde77640e7a56a23f9794a500
3
+ metadata.gz: fc9b28f3f15fbbf7cfa46c1111b7d8c5a0b6c31f6363a7c90d74e08ce6894d8b
4
+ data.tar.gz: b57bd052f6d65a3c04edf7f145ee53ec60594df0caa8cd3c4f1b8f0259fd7449
5
5
  SHA512:
6
- metadata.gz: bb1ad99a6c41a010f04d96483aac6cec646b153aeaaa0f827e2c2f176e5d0890435021a301e434600ab37623e5b824db75ce41826bde6b864a2da76a8e5be4ee
7
- data.tar.gz: 648fa0abae522cf95225adc508991a7f5698cc4573e3d1cafd56a211fec6376a460c800142521bfe1ca4d400657b2b48fd96cf0074fdcaf2999a35d88259479f
6
+ metadata.gz: 26938031e1f797cbdcdc7ccada9b57c516c80c5ef9250c23dd36d4791b68e01e3f9f9262b37345f5cf76c89092c43730efd15f1546028b185e6a7d5e34ef36fd
7
+ data.tar.gz: 4e64a7be6793e07884f54455a3a447793ec1eb35852ffb2e96e058f345156a902107472aeeb1b852b3d12ecf4c303c3bf54639b8fe02901dbe08e14c707f8973
@@ -22,13 +22,26 @@ module Nanoc::Tidy
22
22
  @default_argv ||= ["-wrap", "120", "-indent"]
23
23
  end
24
24
 
25
+ ##
26
+ # Runs the filter
27
+ #
28
+ # @param [String] content
29
+ # HTML content
30
+ #
31
+ # @param [Hash] options
32
+ # Filter options
33
+ #
34
+ # @return [String]
35
+ # Returns HTML content (modified)
25
36
  def run(content, options = {})
26
37
  path = temporary_file(content).path
27
38
  spawn tidy,
28
39
  [*default_argv, *(options[:argv] || []), "-modify", path],
29
40
  err: File.join(tmpdir, "stderr"),
30
41
  out: File.join(tmpdir, "stdout")
31
- File.read(path).tap { rm(path) }
42
+ File.read(path)
43
+ ensure
44
+ rm(path) if File.exist?(path)
32
45
  end
33
46
 
34
47
  private
@@ -21,9 +21,9 @@ module Nanoc::Tidy
21
21
  #
22
22
  # @return [void]
23
23
  def spawn(exe, argv, err:, out:)
24
- hex = SecureRandom.hex
25
- err = "#{err}-ID#{hex}"
26
- out = "#{out}-ID#{hex}"
24
+ id = SecureRandom.hex
25
+ err = "#{err}+#{id}"
26
+ out = "#{out}+#{id}"
27
27
  Kernel.spawn(
28
28
  exe, *argv, { STDERR => err, STDOUT => out }
29
29
  )
@@ -38,7 +38,7 @@ module Nanoc::Tidy
38
38
 
39
39
  msgs = [err, out].map do
40
40
  FileUtils.touch(_1)
41
- [_1.gsub(Dir.getwd, ''), ":", File.binread(_1)].join
41
+ [_1.gsub(Dir.getwd, ''), ":", "\n", File.binread(_1)].join
42
42
  end.join("\n")
43
43
  raise Error,
44
44
  "#{File.basename(exe)} exited unsuccessfully " \
@@ -1,5 +1,5 @@
1
1
  module Nanoc
2
2
  module Tidy
3
- VERSION = "0.6.1"
3
+ VERSION = "0.6.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc-tidy.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - '0x1eef'