Practical object-oriented design for Ruby, drawn from Sandi Metz (Practical Object-Oriented Design in Ruby, 99 Bottles of OOP) and SOLID. Use it to keep change cheap, not to decorate code with patterns.
Pronounce POODR “pooder.”
These assume your setup: LazyVim with the Ruby extra, ruby-lsp, the Snacks picker, treesitter text objects and flash. You don't have vim-rails installed, so there's no :A or gf jumping between related Rails files.
LSP (ruby-lsp)
| Key | Jump |
|---|---|
gd |
Definition of the constant or method under the cursor |
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| mode="${1:?usage: git-guard.sh pre|stop}" | |
| input="$(cat)" | |
| project_dir="${CLAUDE_PROJECT_DIR:-$(jq -r '.cwd' <<<"$input")}" | |
| session_id="$(jq -r '.session_id // "default"' <<<"$input")" | |
| state="$(cat "$project_dir/.claude/.tdd/$session_id" 2>/dev/null || echo none)" |
We use Rails' native error reporter (Rails.error) as the single interface for all error and exception reporting. It replaces our previous Honeybadger-specific calls and routes through our RailsErrorSubscriber, which forwards to Rails.logger and the OTel pipeline.
| Method | When to use |
|---|
| require 'redcarpet' | |
| module MarkdownHandler | |
| def self.erb | |
| @erb ||= ActionView::Template.registered_template_handler(:erb) | |
| end | |
| def self.call(template, source) | |
| _frontmatter, markdown = Page.parse_frontmatter(source, raw: true) | |
| compiled_source = ActionView::OutputBuffer.new(erb.call(template, markdown)).to_s |
| require 'redcarpet' | |
| require 'redcarpet/render_strip' | |
| module MarkdownHelper | |
| def markdown(str) | |
| html_renderer.render(str).html_safe | |
| end | |
| def plain_text(str) | |
| strip_down_renderer.render(str).html_safe |
| desc 'Raise exception if used in production' | |
| task protect_prod: [:environment] do | |
| raise 'This task cannot be run in production' if Rails.env.production? | |
| end | |
| ['db:drop', 'db:reset', 'db:seed'].each do |t| | |
| Rake::Task[t].enhance ['protect_prod'] | |
| end |
To convert json to csv with headers using jq and the @csv filter.
jq -r '[first|keys_unsorted] + map([.[]]) | .[] | @csv' example.json > converted.csvThis would work on a simple json structured like:
[