Drop the missing-directory guard in Contact.all
Errno::ENOENT from Pathname#children says it plainly enough.
Assisted-by: GLM-5.3 via pi
diff --git a/lib/pro_tacts/contact.rb b/lib/pro_tacts/contact.rb
index 8b816f7..1998f3e 100644
--- a/lib/pro_tacts/contact.rb
+++ b/lib/pro_tacts/contact.rb
@@ -17,12 +17,10 @@ module ProTacts
# directory is a valid empty address book, and dotfiles are skipped
# (Finder drops .DS_Store into any directory it opens). Anything
# else raises: a bad file 500s the request and lands in Sentry
- # rather than quietly serving a partial address book.
+ # rather than quietly serving a partial address book. A missing
+ # directory surfaces as Errno::ENOENT from Pathname#children.
def self.all(directory = ProTacts.config.contacts_dir)
- directory = Pathname.new(directory)
- raise ArgumentError, "contacts directory not found: #{directory}" unless directory.directory?
-
- directory.children
+ Pathname.new(directory).children
.reject { it.basename.to_s.start_with?(".") }
.map { parse(it) }
end
diff --git a/test/pro_tacts/test_contact.rb b/test/pro_tacts/test_contact.rb
index f9c10b2..bca93a5 100644
--- a/test/pro_tacts/test_contact.rb
+++ b/test/pro_tacts/test_contact.rb
@@ -48,11 +48,11 @@ class ContactTest < Minitest::Test
end
def test_a_missing_directory_raises
- error = assert_raises(ArgumentError) do
+ error = assert_raises(Errno::ENOENT) do
ProTacts::Contact.all(Pathname.new(Dir.mktmpdir) / "nonexistent")
end
- assert_match(/contacts directory not found/, error.message)
+ assert_match(/nonexistent/, error.message)
end
def test_non_kdl_files_raise