-
Chapter 1 Driving Code Through Tests
-
A Quick Note on Testing Frameworks
-
Designing for Testability
-
Testing Fundamentals
-
Advanced Testing Techniques
-
Keeping Things Organized
-
Conclusions
-
-
Chapter 2 Designing Beautiful APIs
-
Designing for Convenience: Ruport’s Table( ) feature
-
Ruby’s Secret Power: Flexible Argument Processing
-
Ruby’s Other Secret Power: Code Blocks
-
Avoiding Surprises
-
Conclusions
-
-
Chapter 3 Mastering the Dynamic Toolkit
-
BlankSlate: A BasicObject on Steroids
-
Building Flexible Interfaces
-
Implementing Per-Object Behavior
-
Extending and Modifying Preexisting Code
-
Building Classes and Modules Programmatically
-
Registering Hooks and Callbacks
-
Conclusions
-
-
Chapter 4 Text Processing and File Management
-
Line-Based File Processing with State Tracking
-
Regular Expressions
-
Working with Files
-
The tempfile Standard Library
-
Text-Processing Strategies
-
Conclusions
-
-
Chapter 5 Functional Programming Techniques
-
Laziness Can Be a Virtue (A Look at lazy.rb)
-
Minimizing Mutable State and Reducing Side Effects
-
Modular Code Organization
-
Memoization
-
Infinite Lists
-
Higher-Order Procedures
-
Conclusions
-
-
Chapter 6 When Things Go Wrong
-
A Process for Debugging Ruby Code
-
Capturing the Essence of a Defect
-
Scrutinizing Your Code
-
Working with Logger
-
Conclusions
-
-
Chapter 7 Reducing Cultural Barriers
-
m17n by Example: A Look at Ruby’s CSV Standard Library
-
Portable m17n Through UTF-8 Transcoding
-
m17n in Standalone Scripts
-
m17n-Safe Low-Level Text Processing
-
Localizing Your Code
-
Conclusions
-
-
Chapter 8 Skillful Project Maintenance
-
Exploring a Well-Organized Ruby Project (Haml)
-
Conventions to Know About
-
API Documentation via RDoc
-
The RubyGems Package Manager
-
Rake: Ruby’s Built-in Build Utility
-
Conclusions
-
-
Appendix Writing Backward-Compatible Code
-
Avoiding a Mess
-
Nonportable Features in Ruby 1.9
-
Workarounds for Common Issues
-
Conclusions
-
-
Appendix Leveraging Ruby’s Standard Library
-
Why Do We Need a Standard Library?
-
Pretty-Printer for Ruby Objects (pp)
-
Working with HTTP and FTP (open-uri)
-
Working with Dates and Times (date)
-
Lexical Parsing with Regular Expressions (strscan)
-
Cryptographic Hash Functions (digest)
-
Mathematical Ruby Scripts (mathn)
-
Working with Tabular Data (csv)
-
Transactional Filesystem-Based Data Storage (pstore)
-
Human-Readable Data Serialization (json)
-
Embedded Ruby for Code Generation (erb)
-
Conclusions
-
-
Appendix Ruby Worst Practices
-
Not-So-Intelligent Design
-
The Downside of Cleverness
-
Conclusions
-
-
Colophon
- Title:
- Ruby Best Practices
- By:
- Gregory T Brown
- Publisher:
- O'Reilly Media
- Formats:
-
- Ebook
- Safari Books Online
- Print Release:
- June 2009
- Ebook Release:
- June 2009
- Pages:
- 336
- Print ISBN:
- 978-0-596-52300-8
- | ISBN 10:
- 0-596-52300-9
- Ebook ISBN:
- 978-0-596-80365-0
- | ISBN 10:
- 0-596-80365-6
The animal on the cover of Ruby Best Practices is a green crab (Carcinus maenas). Also known as a European shore crab, it is native to the coasts of the North and Baltic Seas. Although relatively small--adults measure three inches across--an adult green crab can consume up to 40 clams each day and can eat other crabs as large as itself. A voracious predator, the green crab also preys on oysters, mussels, and snails, competing for food with many fish and bird species.
Despite its name, the green crab's shell color can vary from dark green to orange or red, sometimes with yellow patches on its underside. The abdomen of the male is triangular in shape, whereas the female's is broader and rounder. Males and females also react differently upon being picked up: males typically stretch out their legs, whereas females fold them in, a behavior known as the egg-protection reflex.
A natural colonizer, the green crab is potentially destructive to any ecosystem it invades. It has already invaded many coastal communities outside of its native range, including Australia, South Africa, and North America, where it is blamed for the collapse of the softshell clam industry in Maine. It is ranked number 18 on the list of the 100 world's worst invasive types of species. Numerous efforts around the world have been made to control invading populations, to varying degrees of success. One of the more effective experiments has been on Martha's Vineyard, Massachusetts, where the town of Edgartown pays bounty hunters 40 cents per pound of green crab; more than 10 tons have been caught and destroyed as a result.
The cover image is from the Dover Pictorial Archive. The cover font is Adobe ITC Garamond. The text font is Linotype Birka; the heading font is Adobe Myriad Condensed; and the code font is LucasFont's TheSansMonoCondensed.
