nanoc-tidy.rb 0.2.1 → 0.3.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: 9ef9ec4aa2d04e43d4caed4ba3e2eecf7c835d81156e5a2025c0f2990470754c
4
- data.tar.gz: d028d3cc3aaa355854fa3f1a234f85cba915c1b08b8e9d7b8f4e5865a293bd6e
3
+ metadata.gz: 377f965bc7630e3d0208011340dedea0c8e1463d17755d2ced834a5a2b10cec1
4
+ data.tar.gz: 2cac200122ecebbfcc9b0b28a8264bc83a0706ed8cdc4fdb4524e121aa977510
5
5
  SHA512:
6
- metadata.gz: 6dfaf3bc792c4c7d079408132087c20ba0aac896692764c79efb2b110aae09a11566fb9af1010df197cfd25af6a43e16f7b7de0823ab6db7132278dc3e05f9d8
7
- data.tar.gz: f94ce085f463bb1229f1d3e5b88b35d5c3a5e141d3ec5f5e20ce12d20e60e34da4e78751d51beb40b73a213e5a42a808f471b5239efb1d952f6f7d7e3ccd5df8
6
+ metadata.gz: '0159259928a18678becc9df9ada135133f8fbd917e15a479cc81d97d42cc8cb70ffc1df1a9aac1e5828dbb5af83e36163920c9ca288873185c14fc41eb541bb2'
7
+ data.tar.gz: 64592fabd2529dfa1b28f6c6f423702a0c38ae0dd72edcb029cd57818235533f4d750b78ad4667bf426a0560432c70e31193693c191133edc345d769150cf51b
data/README.md CHANGED
@@ -13,14 +13,14 @@ are often commonplace.
13
13
 
14
14
  __Defaults__
15
15
 
16
- The following is an example with the
17
- [default options](https://0x1eef.github.io/x/nanoc-tidy.rb/Nanoc/Tidy/Filter#default_options-class_method)
18
- being used:
16
+ The following is an example that uses the
17
+ [default options](https://0x1eef.github.io/x/nanoc-tidy.rb/Nanoc/Tidy/Filter#default_options-class_method):
19
18
 
20
19
  ``` ruby
21
20
  # Rules
22
21
  require "nanoc-tidy"
23
22
  compile "/index.html.erb" do
23
+ layout("/default.*")
24
24
  filter(:erb)
25
25
  filter(:tidy)
26
26
  write("/index.html")
@@ -29,13 +29,14 @@ end
29
29
 
30
30
  __Options__
31
31
 
32
- The following example forwards command-line options to
32
+ The following example forwards custom command-line options to
33
33
  [tidy-html5](https://github.com/htacg/tidy-html5):
34
34
 
35
35
  ```ruby
36
36
  # Rules
37
37
  require "nanoc-tidy"
38
38
  compile "/index.html.erb" do
39
+ layout("/default.*")
39
40
  filter(:erb)
40
41
  filter(:tidy, "-upper" => true)
41
42
  write("/index.html")
@@ -9,6 +9,11 @@ class Nanoc::Tidy::Filter < Nanoc::Filter
9
9
  type text: :text
10
10
 
11
11
  ##
12
+ # @example
13
+ # Nanoc::Tidy.default_options.merge!(
14
+ # "-upper" => true
15
+ # )
16
+ #
12
17
  # @return [{"-wrap" => 120, "-indent" => true}]
13
18
  # Returns the default options forwarded as command-line
14
19
  # arguments to tidy-html5.
@@ -24,7 +29,7 @@ class Nanoc::Tidy::Filter < Nanoc::Filter
24
29
  private
25
30
 
26
31
  def tidy(file, options)
27
- system "tidy", "-modify", "-quiet", *tidy_args(options), file.path
32
+ system tidy_exe, "-modify", "-quiet", *tidy_args(options), file.path
28
33
  if $?.success?
29
34
  File.read(file.path).tap { file.tap(&:unlink).close }
30
35
  else
@@ -42,6 +47,14 @@ class Nanoc::Tidy::Filter < Nanoc::Filter
42
47
  end
43
48
  end
44
49
 
50
+ def tidy_exe
51
+ case
52
+ when system("which tidy > /dev/null 2>&1") then "tidy"
53
+ when system("which tidy5 > /dev/null 2>&1") then "tidy5"
54
+ else raise Error, "unable to find a tidy executable on $PATH"
55
+ end
56
+ end
57
+
45
58
  def temporary_file_for(content)
46
59
  dir = File.join(Dir.getwd, "tmp", "nanoc-tidy.rb")
47
60
  mkdir_p(dir) unless Dir.exist?(dir)
@@ -1,5 +1,5 @@
1
1
  module Nanoc
2
2
  module Tidy
3
- VERSION = "0.2.1"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
data/lib/nanoc/tidy.rb CHANGED
@@ -4,4 +4,11 @@ require "nanoc"
4
4
  module Nanoc::Tidy
5
5
  require_relative "tidy/version"
6
6
  require_relative "tidy/filter"
7
+
8
+ ##
9
+ # @example (see Nanoc::Tidy::Filter.default_options)
10
+ # @return (see Nanoc::Tidy::Filter.default_options)
11
+ def self.default_options
12
+ Filter.default_options
13
+ end
7
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc-tidy.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - '0x1eef'
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-14 00:00:00.000000000 Z
11
+ date: 2024-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yard
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  - !ruby/object:Gem::Version
149
149
  version: '0'
150
150
  requirements: []
151
- rubygems_version: 3.4.10
151
+ rubygems_version: 3.5.3
152
152
  signing_key:
153
153
  specification_version: 4
154
154
  summary: nanoc-tidy.rb integrates tidy-html5 into nanoc.