Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs for DepShield #237

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion packages/dep_shield/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,26 @@ With DepShield, developers can stay ahead of the curve by receiving real-time al

## Usage

TODO: Write usage instructions here
`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:

```ruby
# components/books/lib/books.rb

def self.category
NitroErrors.deprecate!(name: "books_default_category", message: "please use '.default_category' instead")
"Science Fiction"
end
```

This is used in conjuction with NitroConfig to define how different environment should react:

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`:

```ruby
# components/authors/lib/book_information.rb

book_category = Books.category
```
Loading