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 +4 -4
- data/lib/nanoc/tidy/filter.rb +14 -1
- data/lib/nanoc/tidy/spawn.rb +4 -4
- data/lib/nanoc/tidy/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc9b28f3f15fbbf7cfa46c1111b7d8c5a0b6c31f6363a7c90d74e08ce6894d8b
|
4
|
+
data.tar.gz: b57bd052f6d65a3c04edf7f145ee53ec60594df0caa8cd3c4f1b8f0259fd7449
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26938031e1f797cbdcdc7ccada9b57c516c80c5ef9250c23dd36d4791b68e01e3f9f9262b37345f5cf76c89092c43730efd15f1546028b185e6a7d5e34ef36fd
|
7
|
+
data.tar.gz: 4e64a7be6793e07884f54455a3a447793ec1eb35852ffb2e96e058f345156a902107472aeeb1b852b3d12ecf4c303c3bf54639b8fe02901dbe08e14c707f8973
|
data/lib/nanoc/tidy/filter.rb
CHANGED
@@ -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)
|
42
|
+
File.read(path)
|
43
|
+
ensure
|
44
|
+
rm(path) if File.exist?(path)
|
32
45
|
end
|
33
46
|
|
34
47
|
private
|
data/lib/nanoc/tidy/spawn.rb
CHANGED
@@ -21,9 +21,9 @@ module Nanoc::Tidy
|
|
21
21
|
#
|
22
22
|
# @return [void]
|
23
23
|
def spawn(exe, argv, err:, out:)
|
24
|
-
|
25
|
-
err = "#{err}
|
26
|
-
out = "#{out}
|
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 " \
|
data/lib/nanoc/tidy/version.rb
CHANGED