How dbl-works/rubocop-dbl works
Project type and purpose
• This is an open‑source Ruby gem (“rubocop-dbl”) that provides a shared RuboCop configuration for Ruby on Rails projects.
• It bundles a set of Cop rules (in config/cops/*.yml and config/dbl.yml), a Rails generator to install those configs into a host app, and supporting scripts for release and CI.
File structure
• Top‑level components:
• bin/ – release helper script (bin/release)
• config/ – all the RuboCop configuration YAML files and subfolders for different rule categories
• lib/ – the generator code (lib/generators/rubocop_dbl/install_generator.rb) and version file
• rubocop-dbl.gemspec & Gemfile – gem metadata and dependencies
• .github/workflows/test.yml – CI configuration
• test/ – fixture RuboCop configs for internal testing
• Patterns & roles: it’s a library/plugin (no frontend/backend), with:
• “generator” submodule to scaffold config in host apps
• “config” module of static YAML definitions
• CI/build scripts to test & release the gem
README for additional insights
• Describes installation via Gemfile, setup via Rails generator or manual inherit_gem
• Publishes releases to RubyGems via bin/release
• CI runs tests across Ruby–Rails matrix (test.yml)
a. Main components
1. Developer workspace / GitHub repo
2. CI pipeline (GitHub Actions)
3. RubyGems Registry
4. Host Rails Application
5. Bundler & RuboCop Engine
6. rubocop-dbl gem internals (config files + generator + version)
b. Relationships & interactions
• Developer pushes to GitHub → CI workflow runs tests across Ruby/Rails versions
• On tagged release → bin/release publishes to RubyGems
• Host app adds gem to Gemfile → Bundler installs from RubyGems
• Host app runs “rails generate rubocop_dbl:install” → generator reads gem’s config files and writes into .rubocop.yml
• rubocop execution in host app loads .rubocop.yml → inherit_gem loads rule definitions from the gem’s config
c. Architectural patterns & principles
• Plugin/extension architecture: the gem “plugs in” to RuboCop via inherit_gem
• Convention over configuration: generator scaffolds a standard setup
• CI matrix testing ensures compatibility across Ruby/Rails versions
d. Key technologies/frameworks
• RubyGems & Bundler as package distribution
• RuboCop engine for static analysis
• Rails generator API for installation
• GitHub Actions for CI
• RSpec or Minitest under test/ for gem self‑tests
Elements
• Git push → CI
• CI → RubyGems (on release)
• Host App → Bundler → rubocop-dbl gem
• Generator → writes config → Host App .rubocop.yml
• RuboCop CLI → loads config from both Host .rubocop.yml and gem
• External services (GitHub Actions, RubyGems) in another
• Host app environment in a third