Buying Options
Ruby Best Practices
Print $34.99
Add to Cart
Print+Ebook $38.49
Add to Cart
Ebook $27.99
Add to Cart
Safari Books Online
Add to Cart
What is this?
Print £26.99
Add to Cart
What is this?
Description
Ruby Best Practices is for programmers who want to use Ruby the way Rubyists do. Written by the developer of the Ruby project Prawn (prawn.majesticseacreature.com), this concise book explains how to design beautiful APIs and domain-specific languages, work with functional programming ideas and techniques that can simplify your code and make you more productive, write code that's readable and expressive, and much more. It's the perfect companion to The Ruby Programming Language.
Full Description
Table of Contents
  1. Chapter 1 Driving Code Through Tests

    1. A Quick Note on Testing Frameworks

    2. Designing for Testability

    3. Testing Fundamentals

    4. Advanced Testing Techniques

    5. Keeping Things Organized

    6. Conclusions

  2. Chapter 2 Designing Beautiful APIs

    1. Designing for Convenience: Ruport’s Table( ) feature

    2. Ruby’s Secret Power: Flexible Argument Processing

    3. Ruby’s Other Secret Power: Code Blocks

    4. Avoiding Surprises

    5. Conclusions

  3. Chapter 3 Mastering the Dynamic Toolkit

    1. BlankSlate: A BasicObject on Steroids

    2. Building Flexible Interfaces

    3. Implementing Per-Object Behavior

    4. Extending and Modifying Preexisting Code

    5. Building Classes and Modules Programmatically

    6. Registering Hooks and Callbacks

    7. Conclusions

  4. Chapter 4 Text Processing and File Management

    1. Line-Based File Processing with State Tracking

    2. Regular Expressions

    3. Working with Files

    4. The tempfile Standard Library

    5. Text-Processing Strategies

    6. Conclusions

  5. Chapter 5 Functional Programming Techniques

    1. Laziness Can Be a Virtue (A Look at lazy.rb)

    2. Minimizing Mutable State and Reducing Side Effects

    3. Modular Code Organization

    4. Memoization

    5. Infinite Lists

    6. Higher-Order Procedures

    7. Conclusions

  6. Chapter 6 When Things Go Wrong

    1. A Process for Debugging Ruby Code

    2. Capturing the Essence of a Defect

    3. Scrutinizing Your Code

    4. Working with Logger

    5. Conclusions

  7. Chapter 7 Reducing Cultural Barriers

    1. m17n by Example: A Look at Ruby’s CSV Standard Library

    2. Portable m17n Through UTF-8 Transcoding

    3. m17n in Standalone Scripts

    4. m17n-Safe Low-Level Text Processing

    5. Localizing Your Code

    6. Conclusions

  8. Chapter 8 Skillful Project Maintenance

    1. Exploring a Well-Organized Ruby Project (Haml)

    2. Conventions to Know About

    3. API Documentation via RDoc

    4. The RubyGems Package Manager

    5. Rake: Ruby’s Built-in Build Utility

    6. Conclusions

  1. Appendix Writing Backward-Compatible Code

    1. Avoiding a Mess

    2. Nonportable Features in Ruby 1.9

    3. Workarounds for Common Issues

    4. Conclusions

  2. Appendix Leveraging Ruby’s Standard Library

    1. Why Do We Need a Standard Library?

    2. Pretty-Printer for Ruby Objects (pp)

    3. Working with HTTP and FTP (open-uri)

    4. Working with Dates and Times (date)

    5. Lexical Parsing with Regular Expressions (strscan)

    6. Cryptographic Hash Functions (digest)

    7. Mathematical Ruby Scripts (mathn)

    8. Working with Tabular Data (csv)

    9. Transactional Filesystem-Based Data Storage (pstore)

    10. Human-Readable Data Serialization (json)

    11. Embedded Ruby for Code Generation (erb)

    12. Conclusions

  3. Appendix Ruby Worst Practices

    1. Not-So-Intelligent Design

    2. The Downside of Cleverness

    3. Conclusions

  4. Colophon

View Full Table of Contents
Product Details
Title:
Ruby Best Practices
By:
Gregory T Brown
Publisher:
O'Reilly Media
Formats:
  • Print
  • 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
Customer Reviews
About the Author
  1. Gregory T Brown

    Gregory T. Brown is a New Haven, CT based Rubyist who spends most of his time on free software projects in Ruby. His main projects are Prawn and Ruport, and he is also the author of the upcoming book Ruby Best Practices. He also is in possession of a small bamboo plant that seems to be invincible, and he is quite proud of this accomplishment.

    View Gregory T Brown's full profile page.

Colophon

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.

  • Book cover of Ruby Best Practices