From bf26ed2a3c3cfda4cbc2cc093fdc12119fc82e8d Mon Sep 17 00:00:00 2001 From: Ryan Davis Date: Mon, 22 Apr 2024 10:23:24 -0800 Subject: [PATCH] + Raise error if readme file is improperly structured. [git-p4: depot-paths = "//src/hoe/dev/": change = 14124] --- lib/hoe.rb | 2 ++ test/test_hoe.rb | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/hoe.rb b/lib/hoe.rb index 9059426..472c0ae 100644 --- a/lib/hoe.rb +++ b/lib/hoe.rb @@ -676,6 +676,8 @@ def intuit_values input .map(&:last) .each_slice(2) .to_h { |k, v| + raise "No body for %p section" % [k[0].strip] \ + unless v kp = k.map { |s| s.strip.chomp(":").sub(/(?:=+|#+)\s*/, '').downcase }.join("\n") diff --git a/test/test_hoe.rb b/test/test_hoe.rb index 7b996cd..4b81642 100644 --- a/test/test_hoe.rb +++ b/test/test_hoe.rb @@ -171,6 +171,20 @@ def test_initialize_intuit_ambiguous end end + def test_initialize_intuit__empty + Dir.mktmpdir do |path| + Dir.chdir path do + File.write "README.rdoc", "= blah\n" + + e = assert_raises RuntimeError do + hoe + end + + assert_equal "No body for \"= blah\" section", e.message + end + end + end + def test_file_read_utf Tempfile.open "BOM" do |io| io.write "\xEF\xBB\xBFBOM"