homebrew-core/Formula/vale.rb

36 lines
1 KiB
Ruby
Raw Normal View History

class Vale < Formula
desc "Syntax-aware linter for prose"
homepage "https://errata-ai.github.io/vale/"
url "https://github.com/errata-ai/vale/archive/v1.7.1.tar.gz"
sha256 "e1fee20d8fed7fc8819de310608b1ed584c0fad096cce95ecef727584ed9790f"
depends_on "go" => :build
def install
flags = "-X main.version=#{version} -s -w"
system "go", "build", "-ldflags=#{flags}", "-o", "#{bin}/#{name}"
end
test do
mkdir_p "styles/demo"
(testpath/"styles/demo/HeadingStartsWithCapital.yml").write <<~EOS
extends: capitalization
message: "'%s' should be in title case"
level: warning
scope: heading.h1
match: $title
EOS
(testpath/"vale.ini").write <<~EOS
StylesPath = styles
[*.md]
BasedOnStyles = demo
EOS
(testpath/"document.md").write("# heading is not capitalized")
output = shell_output("#{bin}/vale --config=#{testpath}/vale.ini #{testpath}/document.md 2>&1")
assert_match("✖ 0 errors, 1 warning and 0 suggestions in 1 file.", output)
end
end