Introducing Boring Generators
Boring Generators is a gem that aims to make your development faster by delegating boring setups to the gem. It provides a collection of Rails generators that automate common setup tasks, allowing you to focus on building features rather than configuring boilerplate.
What is Boring Generators?
Boring Generators is a Ruby gem that provides a set of Rails generators for common development tasks. Instead of manually setting up configurations, tests, and boilerplate code, you can use generators to automate these repetitive tasks.
Installation
Add Boring Generators to your Gemfile:
gem 'boring_generators'
Then run:
bundle install
Available Generators
Boring Generators provides several generators to speed up your workflow:
Setup Generators
Generate common setup configurations:
rails generate boring:setup:rspec
rails generate boring:setup:factory_bot
rails generate boring:setup:devise
Component Generators
Create common components with proper structure:
rails generate boring:component:service
rails generate boring:component:form_object
rails generate boring:component:query_object
Benefits
Using Boring Generators provides several advantages:
- Time-saving: Automates repetitive setup tasks
- Consistency: Ensures consistent structure across your application
- Best practices: Generates code following Rails conventions
- Focus on features: Lets you focus on building features instead of configuration
Example Usage
Here's an example of generating a service object:
rails generate boring:component:service User::Create
This creates a properly structured service object with:
# app/services/user/create.rb
module User
class Create
def initialize(params)
@params = params
end
def call
# Your implementation
end
private
attr_reader :params
end
end
Customization
You can customize the generators to match your team's preferences by creating your own generator templates or modifying the default ones.
Conclusion
Boring Generators helps streamline your Rails development workflow by automating common setup tasks. By delegating boring configurations to the gem, you can focus on what matters most: building great features.