Practical Ruby Gems

Practical Ruby Gems

8113Ch00CMP2 3/28/07 5:27 PM Page i Practical Ruby Gems David Berube 8113Ch00CMP2 3/28/07 5:27 PM Page ii Practical Ruby Gems Copyright © 2007 by David Berube All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-59059-811-5 ISBN-10 (pbk): 1-59059-811-3 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Lead Editor: Jason Gilmore Technical Reviewer: Yan Pritzker Editorial Board: Steve Anglin, Ewan Buckingham, Gary Cornell, Jason Gilmore, Jonathan Gennick, Jonathan Hassell, James Huddleston, Chris Mills, Matthew Moodie, Jeff Pepper, Paul Sarknas, Dominic Shakeshaft, Jim Sumser, Matt Wade Project Manager: Richard Dal Porto Copy Edit Manager: Nicole Flores Copy Editor: Candace English Assistant Production Director: Kari Brooks-Copony Production Editor: Kelly Winquist Compositor: Diana Van Winkle, Van Winkle Design Proofreader: Liz Welch Indexer: Julie Grady Cover Designer: Kurt Krames Manufacturing Director: Tom Debolski Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail [email protected], or visit http://www.springeronline.com. For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA 94710. Phone 510-549-5930, fax 510-549-5939, e-mail [email protected], or visit http://www.apress.com. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.com in the Source Code/ Download section. 8113Ch00CMP2 3/28/07 5:27 PM Page iii Dedicated to my parents 8113Ch00CMP2 3/28/07 5:27 PM Page iv Contents at a Glance About the Author . xiii Acknowledgments . xv PART 1 ■ ■ ■ Using RubyGems ■CHAPTER 1 What Is RubyGems? . 3 ■CHAPTER 2 Installing RubyGems . 7 ■CHAPTER 3 Using RubyGems in Your Code . 13 ■CHAPTER 4 Managing Installed Gem Versions . 25 PART 2 ■ ■ ■ Using Particular Gems ■CHAPTER 5 Data Access with the ActiveRecord Gem . 35 ■CHAPTER 6 Easy Text Markup with the BlueCloth Gem . 45 ■CHAPTER 7 Creating Web Applications with Camping . 53 ■CHAPTER 8 Creating Command-Line Utilities with cmdparse . 69 ■CHAPTER 9 HTML Templating with erubis . 81 ■CHAPTER 10 Parsing Feeds with feedtools . 89 ■CHAPTER 11 Creating Graphical User Interfaces with fxruby . 95 ■CHAPTER 12 Retrieving Stock Quotes with YahooFinance . 103 ■CHAPTER 13 Parsing HTML with hpricot . 109 ■CHAPTER 14 Writing HTML as Ruby with Markaby . 115 ■CHAPTER 15 Parsing CSV with fastercsv . 121 ■CHAPTER 16 Multiple Dispatch with multi . 127 ■CHAPTER 17 Serving Web Applications with mongrel . 137 ■CHAPTER 18 Transferring Files Securely with net-sftp . 145 ■CHAPTER 19 Executing Commands on Remote Servers with net-ssh . 149 ■CHAPTER 20 Validating Credit Cards with creditcard . 155 ■CHAPTER 21 Writing PDFs with pdf-writer . 159 ■CHAPTER 22 Handling Recurring Events with runt . 167 iv 8113Ch00CMP2 3/28/07 5:27 PM Page v ■CHAPTER 23 Building Websites with Rails . 175 ■CHAPTER 24 Automating Development Tasks with rake . 183 ■CHAPTER 25 Manipulating Images with RMagick . 191 ■CHAPTER 26 Speeding Up Web Applications with memcache-client . 199 ■CHAPTER 27 Managing Zip Archives with rubyzip . 209 ■CHAPTER 28 Speeding Up Function Calls with memoize . 215 ■CHAPTER 29 Tagging MP3 Files with id3lib-ruby . 221 ■CHAPTER 30 Shortening URLs with shorturl . 227 ■CHAPTER 31 Creating Standalone Ruby Applications with rubyscript2exe . 231 ■CHAPTER 32 Cleaning Dirty HTML with tidy . 237 ■CHAPTER 33 Parsing XML with xml-simple . 245 PART 3 ■ ■ ■ Creating Gems ■CHAPTER 34 Creating Our Own Gems . 255 ■CHAPTER 35 Distributing Gems . 261 ■INDEX . 267 v 8113Ch00CMP2 3/28/07 5:27 PM Page vi 8113Ch00CMP2 3/28/07 5:27 PM Page vii Contents About the Author . xiii Acknowledgments . xv PART 1 ■ ■ ■ Using RubyGems ■CHAPTER 1 What Is RubyGems? . 3 Why Use RubyGems? . 3 How Does RubyGems Compare to Other Packaging Systems? . 6 ■CHAPTER 2 Installing RubyGems . 7 Installing Ruby . 7 Installing RubyGems Under Linux and Mac OS X . 10 Updating Your RubyGems System After You’ve Installed It . 11 ■CHAPTER 3 Using RubyGems in Your Code . 13 Getting Started with a Ruby Gem . 13 Working with Source Gems . 20 Debugging RubyGems . 23 ■CHAPTER 4 Managing Installed Gem Versions . 25 What Is Gem Versioning? . 25 Installing an Older Gem Version . 26 Updating Gems . 27 Uninstalling Gems . 28 Specifying Gem Versions . 29 vii 8113Ch00CMP2 3/28/07 5:27 PM Page viii viii ■CONTENTS PART 2 ■ ■ ■ Using Particular Gems ■CHAPTER 5 Data Access with the ActiveRecord Gem . 35 How Does It Work? . 36 Archiving RSS News with ActiveRecord . 39 Conclusion . 44 ■CHAPTER 6 Easy Text Markup with the BlueCloth Gem . 45 How Does It Work? . 45 BlueCloth-to-HTML Converter . 46 bluecloth2pdf BlueCloth-to-PDF Converter . 48 Conclusion . 51 ■CHAPTER 7 Creating Web Applications with Camping . 53 How Does It Work? . 53 Tracking Time with Camping . 56 Conclusion . 68 ■CHAPTER 8 Creating Command-Line Utilities with cmdparse . 69 How Does It Work? . 69 A Job-Search Tool Built with cmdparse . 71 Conclusion . 79 ■CHAPTER 9 HTML Templating with erubis . 81 How Does It Work? . 81 HTML MySQL Table Viewer with erubis . 83 Conclusion . 88 ■CHAPTER 10 Parsing Feeds with feedtools . ..

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    16 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us