Frictionless Generators
by Garrett Dimon
Did you know that you can effortlessly create well-tested, reliable, and
easy-to-use generators that save time? And when you create a custom
generator, it doesn’t just save time for you but for your entire team.
Over. And over. And over again. Every single Rails project already
provides all of the tools to build custom generators. With a little
guidance, you can use them just as effortlessly as every other part of
Rails.
This work was written and produced entirely by the author. We are proud to be distributing it.
eBook Formats:
Get all eBook formats here for $29.00 (USD)
Add to Cart
Frictionless Generators takes a holistic approach to help you see how
to efficiently create and test custom Rails Generators so you and your
team can save time. Think of it as a guide for saving time that just
happens to use custom Rails Generators as the methodology.
It provides over 150 pages of pragmatic tips, tactics, and code samples
to help you avoid speed bumps and get right into creating your own
generators. It covers all of the key APIs and tools for creating
generators while also avoiding getting stuck in the weeds or creating
generators nobody will ever use.
But it’s not just about learning how to create them. It’s about learning
when to not create one. It’s about recognizing when and how to customize
an existing generator so you don’t reinvent the wheel.
Set aside any preconceived notions you may have about creating custom
generators in Rails, and you’ll add one more powerful tool to that tool
belt of yours. And you’ll waste less time on the tedious stuff so you
can spend it on the high-value work you do.
What You Need
You’ll need a working development environment to run Ruby on Rails. The
book was written with Ruby 3.2 and Rails 7.1, however you should be able
to follow along and use any supported version of Ruby or Rails.
Resources
Releases:
Overview
Values
- A (Brief)
Introduction
- 1. Save Time and Reduce
Tedium
- 2. Generate the Big Picture
- 2.1 The Generator & Templates Folder
- 2.2 The Tests
- 2.3 The Command Line & Help
- 2.4 Actions
- 2.5 Templates, Sources, and Destinations
- 2.6 Arguments, Options, and Interactivity
- 2.7 Parent Class Options
- 2.8 Naming Considerations
- 2.9 Summary & Review: The Big Picture
- 3. Arguments & Options
- 3.1 What’s the difference?
- 3.2 Arguments
- 3.3 Options
- 3.4 Judicious Arguments and Options
- 3.5 Our Generator: Arguments & Options
- 3.6 Summary & Review: Arguments & Options
- 4. Usability & Interactivity
- 4.1 Providing Helpful Documentation
- 4.2 Argument Banner Enhancements
- 4.3 Our Generator: Better Banners & Docs
- 4.4 Usage File & Descriptions
- 4.5 Our Generator: Writing the Usage
- 4.6 Communicating Status
- 4.7 Argument & Option Error Handling
- 4.8 Our Generator: Custom Error Handling
- 4.9 Interactive Prompts
- 4.10 Our Generator: Graceful Custom Error Handling
- 4.11 Respecting Quiet Time
- 4.12 Summary & Review: Usability & Interactivity
- 5. Leveraging Templates & Testing
excerpt
- 5.1 Templates
- 5.2 Testing Generators
- 5.3 Take Care with Locations
- 5.4 Our Generator: Adding Templates & Tests
- 5.5 Summary & Review: Templates & Testing
- 6. Creating & Modifying Files
- 6.1 Creating without Templates
- 6.2 Modifying Existing Files
- 6.3 Deleting Files & Directories
- 6.4 Summary & Review: Creating & Modifying
- 7. Utility & System Actions
- 7.1 The Basics
- 7.2 Version Control with Git
- 7.3 Doing more with Ruby
- 7.4 Additional Utilities
- 7.5 Finding Files in Source Paths
- 7.6 Summary & Review: Utilities
- 8. Extending & Customizing
- 8.1 Leverage Rails & Introspection
- 8.2 Re-configure at the System Level
- 8.3 Overriding Individual Generators
- 8.4 Calling a Generator from a Generator
- 8.5 Hooking into Generators
- 8.6 Inheritance
- 8.7 Taking it Further
- 8.8 Summary & Review: Extending & Customizing
- Afterword
- Acknowledgments
- Appendix
Author
Garrett Dimon has been designing and building on the web since 1998
and has been using Ruby and Rails since 2008 when he built his first
SaaS application as a sole founder. After eight years of running it, he
sold it to focus on recovering from health issues. Since then, he’s
played key roles in the design and development of a wide variety of
Rails applications and Ruby gems.