nanoc-tidy.rb 0.8.2 → 0.8.3

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: 8d6e154d29de034dfe0b684d5e95473021844c209b99fcd5660e7bf9a9f68fd6
4
- data.tar.gz: e03bc5eaa2bc6ce7d3b24fd449bc72ad4dd0e31b0aec5af5f4419ae4c298fc1d
3
+ metadata.gz: a795c8b72d5a01390d1fc1207f591907122770a381b87ce678e07536176e1b84
4
+ data.tar.gz: 334ae45c5f9d92401b5277a72eab418cd520b7b9cc0f867a6f22b944221ccefb
5
5
  SHA512:
6
- metadata.gz: 8a92d50b08bdd9bbd65ab664c55a867404a9755ddf3c2f0dd4f40c8fecf48c00e84bfd824e5281cda17083b2963b4b7ccfb8614d3b40c308815570b7b53b8e00
7
- data.tar.gz: 840a2eca0b0cbbeec99fa022d13f0674fb0eca061310b070e58d3d99c916cb14b43d249f6234b8c78217834f9ceadcac3dd1907a57692f4d3dfea2f73c505265
6
+ metadata.gz: e9dcc2d5a72046d5250db9483057e6b64e2ead1ea5ceaea0a4e262cd54612698cd2314a19a5bd1ca52c8c1a22c947f1feddef9fe9fb5aa654b32d56ba169610e
7
+ data.tar.gz: b4d645c500657c30390a4c7cca1f75c73642cc45ef2e0bc88dc05a65bb7b2de58cdca362b848036b959c040a8f5d464638adcbcd3de0b5ff5d1802a6744be6f8
@@ -19,11 +19,17 @@ module Nanoc::Tidy
19
19
  def spawn(exe, argv)
20
20
  r = cmd(exe, *argv)
21
21
  ##
22
- # exit codes
22
+ # tidy-html5 exit codes
23
23
  # * 0: no warnings, no errors
24
24
  # * 1: has warnings
25
25
  # * 2: has errors
26
- if [0, 1].include?(r.exit_status)
26
+ if r.exit_status == 1
27
+ if r.stderr =~ /No such file or directory/
28
+ raise Nanoc::Tidy::Error, "The #{exe} executable was not found"
29
+ else
30
+ r.exit_status
31
+ end
32
+ elsif r.exit_status == 0
27
33
  r.exit_status
28
34
  else
29
35
  raise Nanoc::Tidy::Error,
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Nanoc
4
4
  module Tidy
5
- VERSION = "0.8.2"
5
+ VERSION = "0.8.3"
6
6
  end
7
7
  end
@@ -4,17 +4,25 @@ require_relative "setup"
4
4
 
5
5
  class FilterTest < Test::Unit::TestCase
6
6
  def test_default_options
7
- options = {argv: ["--tidy-mark", "false"]}
7
+ options = {exe:, argv: ["--tidy-mark", "false"]}
8
8
  assert_equal read_result("default_options.html"),
9
9
  filter_for("fixture.html").run(html, options)
10
10
  end
11
11
 
12
12
  def test_upper_option
13
- options = {argv: ["-upper", "--tidy-mark", "false"]}
13
+ options = {exe:, argv: ["-upper", "--tidy-mark", "false"]}
14
14
  assert_equal read_result("upper_option.html"),
15
15
  filter_for("fixture.html").run(html, options)
16
16
  end
17
17
 
18
+ def test_exe_not_found
19
+ options = {exe: "/path/not/found", argv: ["-upper", "--tidy-mark", "false"]}
20
+ assert_raises(
21
+ Nanoc::Tidy::Error,
22
+ "The /path/not/found executable was not found"
23
+ ) { filter_for("fixture.html").run(html, options) }
24
+ end
25
+
18
26
  private
19
27
 
20
28
  def filter_for(basename)
@@ -39,4 +47,8 @@ class FilterTest < Test::Unit::TestCase
39
47
  def html
40
48
  File.binread "./test/fixtures/fixture.html"
41
49
  end
50
+
51
+ def exe
52
+ `which tidy || which tidy5`.chomp
53
+ end
42
54
  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.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - '0x1eef'