From 3b492d16e351f1d6be6c64e922c2008e2437c038 Mon Sep 17 00:00:00 2001
From: Jill Klang <jill.klang@powerhrg.com>
Date: Thu, 1 Feb 2024 17:51:57 -0500
Subject: [PATCH] Dynamically load files

---
 packages/dep_shield/docs/README.md            | 19 ++++++++++++++++++-
 .../spec/dep_shield/deprecation_spec.rb       |  3 +++
 ...n_todo.yml => .empty_deprecation_todo.yml} |  0
 3 files changed, 21 insertions(+), 1 deletion(-)
 rename packages/dep_shield/spec/internal/config/{extra/.deprecation_todo.yml => .empty_deprecation_todo.yml} (100%)

diff --git a/packages/dep_shield/docs/README.md b/packages/dep_shield/docs/README.md
index b6acf138..653dfab5 100644
--- a/packages/dep_shield/docs/README.md
+++ b/packages/dep_shield/docs/README.md
@@ -4,6 +4,12 @@ Introducing DepShield, your go-to Ruby gem for proactive deprecation management
 
 With DepShield, developers can stay ahead of the curve by receiving real-time alerts about deprecated code, ensuring a smoother transition to future updates. Tailor your development and demo environments to raise alarms, preventing the introduction of new deprecations. In addition, DepShield offers the flexibility to configure self-reporting mechanisms, allowing seamless issue notifications, configurable by environment Say goodbye to unexpected deprecation surprises and embrace a more streamlined and informed coding experience with DepShield!
 
+## Setup
+
+After installing DepShield, load any todo lists in your application with:
+
+`DepShield.todos.load("path-to-deprecation_todos.yml")`
+
 ## Usage
 
 `DepShield#raise_or_capture!` is used to mark methods as deprecated. When called, it will intelligently warn or raise exceptions to alert developers to the deprecated activity. The method expects two arguments, a `name` (ie, the name of the deprecation you're introducing), and a `message` (usually information about what is deprecated and how to fix it). Marking something as deprecated is pretty simple:
@@ -22,10 +28,21 @@ This is used in conjuction with NitroConfig to define how different environment
 Option A: the result of this is a logged warning every time the method is called.
 Option B: this will raise and notify our error catcher (Sentry).
 
-If a developer needs to bypass this/defer fixing the deprecation to a future date, the call can be "grandfathered" by adding this information to the allowlist in `.deprecation_todo.yml` in the application/component that hosts the deprecated reference. For example, if you have a method in the `authors` component that references `Books.category`:
+If a developer needs to bypass this/defer fixing the deprecation to a future date, the call can be "grandfathered" by adding this information to the allowlist in a `.deprecation_todo.yml` file in the application/component that hosts the deprecated reference. For example, if you have a method in the `authors` component that references `Books.category`:
 
 ```ruby
 # components/authors/lib/book_information.rb
 
 book_category = Books.category
 ```
+
+You could disable this with:
+
+```yml
+# components/authors/.deprecation_todo.yml
+
+books_default_category:
+  - components/authors/lib/book_information.rb
+```
+
+More details and another example can be found [here](https://github.com/powerhome/power-tools/blob/main/packages/dep_shield/spec/internal/config/.deprecation_todo.yml)
diff --git a/packages/dep_shield/spec/dep_shield/deprecation_spec.rb b/packages/dep_shield/spec/dep_shield/deprecation_spec.rb
index 040ebb99..77235e87 100644
--- a/packages/dep_shield/spec/dep_shield/deprecation_spec.rb
+++ b/packages/dep_shield/spec/dep_shield/deprecation_spec.rb
@@ -6,6 +6,9 @@
   context "#raise_or_capture!" do
     describe "configured to capture_deprecation" do
       before do
+        DepShield.todos.load(Rails.root.join("config", ".deprecation_todo.yml"))
+        DepShield.todos.load(Rails.root.join("config", ".empty_deprecation_todo.yml"))
+
         allow(NitroConfig).to receive(:get).with("nitro_errors/capture_deprecation").and_return true
       end
 
diff --git a/packages/dep_shield/spec/internal/config/extra/.deprecation_todo.yml b/packages/dep_shield/spec/internal/config/.empty_deprecation_todo.yml
similarity index 100%
rename from packages/dep_shield/spec/internal/config/extra/.deprecation_todo.yml
rename to packages/dep_shield/spec/internal/config/.empty_deprecation_todo.yml