#!/usr/bin/env bash
set -euo pipefail
bundle exec bundler-audit check --update
npm audit --audit-level=high
pip-audit --strict
class Timer
def self.measure
start_time = Time.now
yield if block_given?
end_time = Time.now
end_time - start_time
# Gemfile
gem 'dry-types'
gem 'dry-struct'
require 'dry-types'
require 'dry-struct'
# Generate engine
# rails plugin new billing --mountable
# lib/billing/engine.rb
module Billing
class Engine < ::Rails::Engine
# app/policies/post_policy.rb
class PostPolicy < ApplicationPolicy
class Scope < Scope
def resolve
if user.admin?
scope.all
class UserSearchQuery
def initialize(relation = User.all)
@relation = relation
end
def call(params)
# Gemfile
gem 'draper'
# app/decorators/user_decorator.rb
class UserDecorator < Draper::Decorator
delegate_all
# Basic Ractor usage
ractor = Ractor.new do
# This runs in parallel, isolated from main thread
result = heavy_computation
result
end
# Gemfile
gem 'graphql'
# Installation
# rails generate graphql:install
# Gemfile
group :development do
gem 'rack-mini-profiler'
gem 'memory_profiler'
gem 'stackprof' # For flamegraphs
gem 'bullet' # N+1 detection
class UserNotificationJob < ApplicationJob
queue_as :default
# Retry up to 5 times with exponential backoff
retry_on StandardError, wait: :exponentially_longer, attempts: 5
require 'rails_helper'
RSpec.describe User, type: :model do
subject(:user) { build(:user) }
describe 'validations' do