nanoc-tidy.rb 0.5.4 → 0.6.0

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: 3ee1c621a476f2b819882dbc0cab4d36250c1713e38998753a75a469a2900a2a
4
- data.tar.gz: 96393304705494770cf4a823ba8f63c897b73c771543abc386f872464703ab13
3
+ metadata.gz: f2a117a2fa83b551326ed6ba05761c1744f182144b2980cd8246757853c67ecc
4
+ data.tar.gz: 362656c6f68fe0791665ecffaa9606cebeb2950eabe08db6f98f3fe8c1f32d84
5
5
  SHA512:
6
- metadata.gz: 7591af36641a8b2be6959fd0e265e66b7a416738324897d8d495bfa4c8a0db0d71d8269116c02eedfebb40cd0fa843092b5bc2d502f10e32745a51228786cd97
7
- data.tar.gz: 831e6095cbfdc4f12a6f18159e00ada75ee97ee930691bbce9a4b64743c221658b9ef9b1fe7f74ecbb2ea0b6293dd945bb70edaf05d9b5e1fd101479c1d5e800
6
+ metadata.gz: 8c19227fa2c5b0386bfeb148b6ecbc664d42847dc1267370228e68139318749ad53c3ec0b6429f175eb77c04540caa388510ecb4920c50e6846c82c40921389d
7
+ data.tar.gz: aa0327d39187dee54a4cc3dd356345b2ebaafd4167e46a83698b275c2e0eaffb4cb6d406dba49ec07490a89f6bc7c6b7c76a63a3609b7762a5f351f76f8bcdb3
@@ -26,7 +26,8 @@ module Nanoc::Tidy
26
26
  path = temporary_file(content).path
27
27
  spawn tidy,
28
28
  [*default_argv, *(options[:argv] || []), "-modify", path],
29
- log: File.join(tmpdir, "tidy-html5.log")
29
+ err: File.join(tmpdir, "stderr"),
30
+ out: File.join(tmpdir, "stdout")
30
31
  File.read(path).tap { rm(path) }
31
32
  end
32
33
 
@@ -1,9 +1,31 @@
1
1
  module Nanoc::Tidy
2
2
  module Spawn
3
+ require "securerandom"
4
+ require "fileutils"
3
5
  Error = Class.new(RuntimeError)
4
- def spawn(exe, argv, log:)
6
+
7
+ ##
8
+ # Spawns a process
9
+ #
10
+ # @param [String] exe
11
+ # The path to an executable
12
+ #
13
+ # @param [Array<String>] argv
14
+ # An array of command line arguments
15
+ #
16
+ # @param [String] err
17
+ # A path where stderr is redirected to
18
+ #
19
+ # @param [String] out
20
+ # A path where stdout is redirected to
21
+ #
22
+ # @return [void]
23
+ def spawn(exe, argv, err:, out:)
24
+ hex = SecureRandom.hex
25
+ err = "#{err}-ID#{hex}"
26
+ out = "#{out}-ID#{hex}"
5
27
  Kernel.spawn(
6
- exe, *argv, { STDOUT => log, STDERR => log }
28
+ exe, *argv, { STDERR => err, STDOUT => out }
7
29
  )
8
30
  Process.wait
9
31
  status = $?
@@ -14,15 +36,19 @@ module Nanoc::Tidy
14
36
  # * 2: has errors
15
37
  return if [0, 1].include?(status.exitstatus)
16
38
 
39
+ msgs = [err, out].map do
40
+ FileUtils.touch(_1)
41
+ [_1.gsub(Dir.getwd, ''), ":", File.binread(_1)].join
42
+ ensure
43
+ FileUtils.rm(_1)
44
+ end.join("\n")
17
45
  raise Error,
18
46
  "#{File.basename(exe)} exited unsuccessfully " \
19
47
  "(" \
20
48
  "exit code: #{status.exitstatus}, " \
21
49
  "item: #{item.identifier}" \
22
50
  ")" \
23
- "\n" \
24
- "#{log.gsub(Dir.getwd, '')[1..]}:" \
25
- "#{File.binread(log)}" \
51
+ "\n#{msgs}",
26
52
  []
27
53
  end
28
54
  end
@@ -1,5 +1,5 @@
1
1
  module Nanoc
2
2
  module Tidy
3
- VERSION = "0.5.4"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
10
10
  gem.licenses = ["0BSD"]
11
11
  gem.files = `git ls-files`.split($/).reject { _1.start_with?(".") }
12
12
  gem.require_paths = ["lib"]
13
- gem.summary = "nanoc-tidy.rb integrates tidy-html5 into nanoc."
13
+ gem.summary = "nanoc-tidy.rb integrates tidy-html5 into nanoc"
14
14
  gem.description = gem.summary
15
15
  gem.add_development_dependency "yard", "~> 0.9"
16
16
  gem.add_development_dependency "redcarpet", "~> 3.5"
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.5.4
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - '0x1eef'
@@ -122,7 +122,7 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0.6'
125
- description: nanoc-tidy.rb integrates tidy-html5 into nanoc.
125
+ description: nanoc-tidy.rb integrates tidy-html5 into nanoc
126
126
  email:
127
127
  - 0x1eef@protonmail.com
128
128
  executables: []
@@ -166,5 +166,5 @@ requirements: []
166
166
  rubygems_version: 3.5.9
167
167
  signing_key:
168
168
  specification_version: 4
169
- summary: nanoc-tidy.rb integrates tidy-html5 into nanoc.
169
+ summary: nanoc-tidy.rb integrates tidy-html5 into nanoc
170
170
  test_files: []