nanoc-tidy.rb 0.6.0 → 0.6.2

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
  SHA256:
3
- metadata.gz: f2a117a2fa83b551326ed6ba05761c1744f182144b2980cd8246757853c67ecc
4
- data.tar.gz: 362656c6f68fe0791665ecffaa9606cebeb2950eabe08db6f98f3fe8c1f32d84
3
+ metadata.gz: fc9b28f3f15fbbf7cfa46c1111b7d8c5a0b6c31f6363a7c90d74e08ce6894d8b
4
+ data.tar.gz: b57bd052f6d65a3c04edf7f145ee53ec60594df0caa8cd3c4f1b8f0259fd7449
5
5
  SHA512:
6
- metadata.gz: 8c19227fa2c5b0386bfeb148b6ecbc664d42847dc1267370228e68139318749ad53c3ec0b6429f175eb77c04540caa388510ecb4920c50e6846c82c40921389d
7
- data.tar.gz: aa0327d39187dee54a4cc3dd356345b2ebaafd4167e46a83698b275c2e0eaffb4cb6d406dba49ec07490a89f6bc7c6b7c76a63a3609b7762a5f351f76f8bcdb3
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,9 +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
42
- ensure
43
- FileUtils.rm(_1)
41
+ [_1.gsub(Dir.getwd, ''), ":", "\n", File.binread(_1)].join
44
42
  end.join("\n")
45
43
  raise Error,
46
44
  "#{File.basename(exe)} exited unsuccessfully " \
@@ -50,6 +48,10 @@ module Nanoc::Tidy
50
48
  ")" \
51
49
  "\n#{msgs}",
52
50
  []
51
+ ensure
52
+ [err, out]
53
+ .select { File.exist?(_1) }
54
+ .each { FileUtils.rm(_1) }
53
55
  end
54
56
  end
55
57
  end
@@ -1,5 +1,5 @@
1
1
  module Nanoc
2
2
  module Tidy
3
- VERSION = "0.6.0"
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.0
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - '0x1eef'