did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

We're the #1 textbook rental company. Let us show you why.

9780596523008

Ruby Best Practices

by
  • ISBN13:

    9780596523008

  • ISBN10:

    0596523009

  • Edition: 1st
  • Format: Paperback
  • Copyright: 2009-06-25
  • Publisher: Oreilly & Associates Inc
  • Purchase Benefits
  • Free Shipping Icon Free Shipping On Orders Over $35!
    Your order must be $35 or more to qualify for free economy shipping. Bulk sales, PO's, Marketplace items, eBooks and apparel do not qualify for this offer.
  • eCampus.com Logo Get Rewarded for Ordering Your Textbooks! Enroll Now
List Price: $34.99 Save up to $3.50
  • Buy New
    $33.94

    USUALLY SHIPS IN 2-3 BUSINESS DAYS

Supplemental Materials

What is included with this book?

Summary

With this concise book, Ruby programmers learn how to design beautiful APIs and domain-specific languages, write code that's readable and expressive, and work with functional programming ideas and techniques that can simplify code and make them more productive.

Author Biography

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.

Table of Contents

Forewordp. ix
Prefacep. xi
Driving Code Through Testsp. 1
A Quick Note on Testing Frameworksp. 2
Designing for Testabilityp. 2
Testing Fundamentalsp. 10
Well-Focused Examplesp. 10
Testing Exceptionsp. 11
Run the Whole Suite at Oncep. 13
Advanced Testing Techniquesp. 14
Using Mocks and Stubsp. 14
Testing Complex Outputp. 22
Keeping Things Organizedp. 26
Embedding Tests in Library Filesp. 27
Test Helpersp. 27
Custom Assertionsp. 29
Conclusionsp. 30
Designing Beautiful APIsp. 31
Designing for Convenience: Ruport's Table() featurep. 31
Ruby's Secret Power: Flexible Argument Processingp. 35
Standard Ordinal Argumentsp. 36
Ordinal Arguments with Optional Parametersp. 36
Pseudo-Keyword Argumentsp. 37
Treating Arguments As an Arrayp. 38
Ruby's Other Secret Power: Code Blocksp. 40
Working with Enumerablep. 41
Using Blocks to Abstract Pre- and Postprocessingp. 43
Blocks As Dynamic Callbacksp. 45
Blocks for Interface Simplificationp. 47
Avoiding Surprisesp. 48
Use attr_reader, attr_writer, and attr_accessorp. 48
Understand What method? and method! Meanp. 50
Make Use of Custom Operatorsp. 53
Conclusionsp. 55
Mastering the Dynamic Toolkitp. 57
BlankSlate: A BasicObject on Steroidsp. 57
Building Flexible Interfacesp. 62
Making instance_eval() Optionalp. 63
Handling Messages with method_missing() and send()p. 65
Dual-Purpose Accessorsp. 69
Implementing Per-Object Behaviorp. 70
Extending and Modifying Preexisting Codep. 74
Adding New Functionalityp. 75
Modification via Aliasingp. 79
Per-Object Modificationp. 81
Building Classes and Modules Programmaticallyp. 84
Registering Hooks and Callbacksp. 88
Detecting Newly Added Functionalityp. 89
Tracking Inheritancep. 91
Tracking Mixinsp. 93
Conclusionsp. 96
Text Processing and File Managementp. 99
Line-Based File Processing with State Trackingp. 99
Regular Expressionsp. 103
Don't Work Too Hardp. 105
Anchors Are Your Friendsp. 105
Use Caution When Working with Quantifiersp. 106
Working with Filesp. 109
Using Pathname and FileUtilsp. 109
The tempfile Standard Libraryp. 112
Automatic Temporary Directory Handlingp. 113
Collision Avoidancep. 113
Same Old I/O Operationsp. 114
Automatic Unlinkingp. 114
Text-Processing Strategiesp. 115
Advanced Line Processingp. 116
Atomic Savesp. 118
Conclusionsp. 120
Functional Programming Techniquesp. 121
Laziness Can Be a Virtue (A Look at lazy.rb)p. 121
Minimizing Mutable State and Reducing Side Effectsp. 129
Modular Code Organizationp. 133
Memoizationp. 138
Infinite Listsp. 145
Higher-Order Proceduresp. 149
Conclusionsp. 152
When Things Go Wrongp. 153
A Process for Debugging Ruby Codep. 153
Capturing the Essence of a Defectp. 157
Scrutinizing Your Codep. 160
Utilizing Reflectionp. 160
Improving inspect Outputp. 162
Finding Needles in a Haystackp. 166
Working with Loggerp. 168
Conclusionsp. 176
Reducing Cultural Barriersp. 177
m17n by Example: A Look at Ruby's CSV Standard Libraryp. 178
Portable m17n Through UTF-8 Transcodingp. 182
Source Encodingsp. 183
Working with Filesp. 183
Transcoding User Input in an Organized Fashionp. 185
m17n in Standalone Scriptsp. 188
Inferring Encodings from Localep. 189
Customizing Encoding Defaultsp. 191
m17n-Safe Low-Level Text Processingp. 193
Localizing Your Codep. 195
Conclusionsp. 204
Skillful Project Maintenancep. 205
Exploring a Well-Organized Ruby Project (Haml)p. 205
Conventions to Know Aboutp. 210
What Goes in a READMEp. 211
Laying Out Your Libraryp. 213
Executablesp. 216
Testsp. 216
Examplesp. 217
API Documentation via RDocp. 219
Basic Documentation Techniques and Guidelinesp. 220
Controlling Output with RDoc Directivesp. 222
The RubyGems Package Managerp. 227
Writing a Gem::Specificationp. 228
Working with Dependenciesp. 231
Rake: Ruby's Built-in Build Utilityp. 234
Conclusionsp. 237
Writing Backward-Compatible Codep. 239
Leveraging Ruby's Standard Libraryp. 251
Ruby Worst Practicesp. 283
Indexp. 299
Table of Contents provided by Ingram. All Rights Reserved.

Supplemental Materials

What is included with this book?

The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.

The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.

Rewards Program