Ruby Developer''''s Guide

721 298 0
Ruby Developer''''s Guide

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

1 YEAR UPGRADE BUYER PROTECTION PLAN Everything You Need to Develop and Deliver Ruby Applications • Complete Case Studies with Ready-to-Run Source Code and Full Explanations • Hundreds of Developing & Deploying Sidebars, Ruby FAQs, and Ruby Sample Applications • Complete Coverage of Ruby GUI Toolkits:Tk, GTK+, FOX, SWin/Vruby Extensions, and Others Robert Feldt Lyle Johnson Michael Neumann Technical Editor RUBY Developer’s Guide solutions@syngress.com With more than 1,500,000 copies of our MCSE, MCSD, CompTIA, and Cisco study guides in print, we continue to look for ways we can better serve the information needs of our readers. One way we do that is by listening. Readers like yourself have been telling us they want an Internet-based ser- vice that would extend and enhance the value of our books. Based on reader feedback and our own strategic plan, we have created a Web site that we hope will exceed your expectations. Solutions@syngress.com is an interactive treasure trove of useful infor- mation focusing on our book topics and related technologies. The site offers the following features: ■ One-year warranty against content obsolescence due to vendor product upgrades. You can access online updates for any affected chapters. ■ “Ask the Author” customer query forms that enable you to post questions to our authors and editors. ■ Exclusive monthly mailings in which our experts provide answers to reader queries and clear explanations of complex material. ■ Regularly updated links to sites specially selected by our editors for readers desiring additional reliable information on key topics. Best of all, the book you’re now holding is your key to this amazing site. Just go to www.syngress.com/solutions, and keep this book handy when you register to verify your purchase. Thank you for giving us the opportunity to serve your needs. And be sure to let us know if there’s anything else we can do to help you get the maximum value from your investment. We’re listening. www.syngress.com/solutions 183_Ruby_FM.qxd 1/7/02 4:04 PM Page i 183_Ruby_FM.qxd 1/7/02 4:04 PM Page ii 1 YEAR UPGRADE BUYER PROTECTION PLAN Robert Feldt Lyle Johnson Michael Neumann Technical Editor Ruby Developer’s Guide 183_Ruby_FM.qxd 1/7/02 4:04 PM Page iii Syngress Publishing, Inc., the author(s), and any person or firm involved in the writing, editing, or production (collectively “Makers”) of this book (“the Work”) do not guarantee or warrant the results to be obtained from the Work. There is no guarantee of any kind, expressed or implied, regarding the Work or its contents.The Work is sold AS IS and WITHOUT WARRANTY. You may have other legal rights, which vary from state to state. In no event will Makers be liable to you for damages, including any loss of profits, lost savings, or other incidental or consequential damages arising out from the Work or its contents. Because some states do not allow the exclusion or limitation of liability for consequential or incidental damages, the above limitation may not apply to you. You should always use reasonable care, including backup and other appropriate precautions, when working with computers, networks, data, and files. Syngress Media®, Syngress®,“Career Advancement Through Skill Enhancement®,” and “Ask the Author UPDATE®,” are registered trademarks of Syngress Publishing, Inc. “Mission Critical™,”“Hack Proofing™,” and “The Only Way to Stop a Hacker is to Think Like One™” are trademarks of Syngress Publishing, Inc. Brands and product names mentioned in this book are trademarks or service marks of their respective companies. KEY SERIAL NUMBER 001 UJG4TFR2T5 002 AKJ7T4MAS4 003 VMERF3854N 004 SGD34BK9HN 005 85DFMU6N7H 006 NFG438GEM4 007 BAQ2HTR46T 008 CV5TR56KMR 009 83N5M4BT6Y 010 GT67FRWFEC PUBLISHED BY Syngress Publishing, Inc. 800 Hingham Street Rockland, MA 02370 The Ruby Developer’s Guide Copyright © 2002 by Syngress Publishing, Inc. All rights reserved. Printed in the United States of America. Except as permitted under the Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written permission of the publisher, with the exception that the program listings may be entered, stored, and executed in a computer system, but they may not be reproduced for publication. Printed in the United States of America 1 2 3 4 5 6 7 8 9 0 ISBN: 1-928994-64-4 Technical Editor: Michael Neumann Cover Designer: Michael Kavish Acquisitions Editor: Catherine B. Nolan Page Layout and Art by: Reuben Kantor and Shannon Tozier Developmental Editor: Kate Glennon Copy Editor: Jesse Corbeil Indexer: Robert Saigh Distributed by Publishers Group West in the United States and Jaguar Book Group in Canada. 183_Ruby_FM.qxd 1/7/02 4:04 PM Page iv v Acknowledgments v We would like to acknowledge the following people for their kindness and support in making this book possible. Richard Kristof and Duncan Anderson of Global Knowledge, for their generous access to the IT industry’s best courses, instructors, and training facilities. Ralph Troupe, Rhonda St. John, and the team at Callisma for their invaluable insight into the challenges of designing, deploying and supporting world-class enterprise networks. Karen Cross, Lance Tilford, Meaghan Cunningham, Kim Wylie, Harry Kirchner, Kevin Votel, Kent Anderson, and Frida Yara of Publishers Group West for sharing their incredible marketing experience and expertise. Mary Ging, Caroline Hird, Simon Beale, Caroline Wheeler,Victoria Fuller, Jonathan Bunkell, and Klaus Beran of Harcourt International for making certain that our vision remains worldwide in scope. Annabel Dent of Harcourt Australia for all her help. David Buckland,Wendi Wong, Marie Chieng, Lucy Chong, Leslie Lim, Audrey Gan, and Joseph Chan of Transquest Publishers for the enthusiasm with which they receive our books. Kwon Sung June at Acorn Publishing for his support. Ethan Atkin at Cranbury International for his help in expanding the Syngress program. Jackie Gross, Gayle Vocey, Alexia Penny, Anik Robitaille, Craig Siddall, Darlene Morrow, Iolanda Miller, Jane Mackay, and Marie Skelly at Jackie Gross & Associates for all their help and enthusiasm representing our product in Canada. Lois Fraser, Connie McMenemy, and the rest of the great folks at Jaguar Book Group for their help with distribution of Syngress books in Canada. 183_Ruby_FM.qxd 1/7/02 4:04 PM Page v Technical Editor’s Acknowledgements I’d like to thank the Syngress staff for their support, and John Small, who encouraged me in overseeing the writing of this book. I’d like to thank Matz for creating such a wonderful language; Dave and Andy for two really great books about programming in general, and Ruby; Kentaro Goto for his tutorial that directed me three years ago to Ruby; and Hiroshi Nakamura for many valuable comments and explanations about SOAP4R. Finally, thank you to the team of Merlin.zwo for being patient with me, as well as to the whole Ruby community for letting me partici- pate in such a great development. vi 183_Ruby_FM.qxd 1/7/02 4:04 PM Page vi vii Contributors Jason Wong is the Chief Executive Officer of ionami design, a Web development and design firm headquartered in Berkeley, CA. His respon- sibilities include developing and maintaining client relationships, project management, application development and support, and operations man- agement. Previously, he managed all aspects of 3dfxgamers.com, the 3dfx interactive community Web site. Jason holds a bachelor’s degree from the University of California at Berkeley. He would like to thank Joyce,Ted and Tim, and his parents for all their support. Lyle Johnson is a Software Team Leader at ResGen, Invitrogen Corporation in Huntsville, AL. Prior to his employment at ResGen, Lyle served as Group Leader for Graphical User Interface Development at CFD Research Corporation. Lyle has worked primarily in commercial software development for computational fluid dynamics and bioinfor- matics applications, but has also managed and contributed to a number of open-source software projects. Lyle holds a bachelor’s degree in Aerospace Engineering from Auburn University and a master’s of Science degree in Aerospace Engineering from the Georgia Institute of Technology. He currently lives in Madison, AL with his wife, Denise. Jonothon Ortiz is Vice President of Xnext, Inc. in Winter Haven, FL. Xnext, Inc. is a small, privately owned company that develops Web sites and applications for prestigious companies such as the New York Times Company. Jonothon is the head of the programming department and works together with the CEO on all company projects to ensure the best possible solution. Jonothon lives with his wife, Carla, in Lakeland, FL. Robert Feldt is a Software Engineering Researcher at Chalmers University of Technology in Gothenburg, Sweden. His professional interest is in how to produce robust, reliable software. Robert’s research 183_Ruby_FM.qxd 1/7/02 4:04 PM Page vii viii focuses on what can be learned from applying the complex but robust systems found in nature to tools and methods for developing and testing software. Robert also teaches courses on software engineering to students in the Computer Science and Computer Engineering programs at Chalmers University. Robert holds a master’s degree from Chalmers University and is a member of the IEEE. He has previously worked as a consultant software engineer. He programs mostly in C, Haskell, and Ruby and uses Ruby frequently in his research since its dynamic nature allows him to easily test new ideas. He is working on a number of larger Ruby projects, including the Rockit compiler construction toolkit and the RubyVM project, to build a set of plug-and-play components for assembling Ruby virtual machines. Robert currently resides in Gothenburg, Sweden with his wife, Mirjana, and daughter, Ebba. He wants to acknowledge them for their support and love. Stephen Legrand (Ph.D.) has both an academic and commercial back- ground. He was a post-doctoral fellow at MIT and has lectured both mathematical and computer science related subjects at the university level. He has taught graduate and undergraduate courses in such diverse areas as assembly language, automata theory, computability, discrete mathematics, computer graphics, and in mathematical subjects such as differential equa- tions, advanced calculus, financial mathematics, and model theory. In addi- tion, Stephen has over 10 years of software development expertise in such areas as fixed income derivatives, interest rate modeling, artificial intelli- gence, and telecommunications. He has authored computer graphics engines, computer chess games, option pricing engines, cellular propaga- tion models, and workflow management systems. He is currently con- sulting on the IRROS project and on J2EE-related technologies in the Washington, DC area. 183_Ruby_FM.qxd 1/7/02 4:04 PM Page viii ix Technical Editor and Contributor Michael Neumann is a Database and Software Developer for Merlin.zwo InfoDesign GmbH in Germany (near Stuttgart). He is also studying computer science at the University of Karlsruhe. Merlin.zwo develops large-scale database applications based on Oracle products. With more than 10 years of experience in software development, Michael has specialized in many different domains, from system-near programming, administration of Unix systems, and database develop- ment with several RDBMSs, to OOA/OOD techniques, and design and implementation of distributed and parallel applications. One of his greatest interests lies is the design principles of programming languages. Before he was employed at Merlin.zwo, he was a Database/Web Developer and Principal of Page-Store. 183_Ruby_FM.qxd 1/7/02 4:04 PM Page ix [...]... Chapter 1 Booting Ruby Introduction An Overview of Ruby Installing Ruby and its Tools Installing Ruby on Unix Installing Ruby from Source Code Installing from Packages Installing Ruby on a Windows System Installing Applications and Libraries from RAA IDE and Editor Support in Ruby Emacs VIM Other Editors RubyWin Ruby Development Environment (RDE) Additional Tools a Rubyist Must Have Ruby Interactive... Using the SWin/VRuby Extensions Obtaining SWin and VRuby VRuby Library Basics Layout Managers Event Handling VRuby Sample Application Other GUI Toolkits Choosing a GUI Toolkit Summary Solutions Fast Track Frequently Asked Questions Chapter 3 Accessing Databases with Ruby Introduction Accessing Databases with Ruby/ DBI Obtaining and Installing Ruby/ DBI Programming with Ruby/ DBI Understanding Ruby/ DBI Architecture... maintain www.rubycentral.com (Figure 1.2).This site contains the binary installation of Ruby, various articles, links, an FAQ and an online version of their book, Programming Ruby: A Pragmatic Programmer’s Guide www.syngress.com 3 183RubyC01.qxd 4 1/4/02 3:50 PM Page 4 Chapter 1 • Booting Ruby Figure 1.1 The Ruby Language Home Page Figure 1.2 The RubyCentral Home Page www.syngress.com 183RubyC01.qxd... such as the Ruby Application Archive, from which you can obtain updates to the very latest versions Look for this icon to locate the code files that will be included on our Web site www.syngress.com 183RubyC01.qxd 1/4/02 3:50 PM Page 1 Chapter 1 Booting Ruby Solutions in this chapter: s An Overview of Ruby s Installing Ruby and its Tools s A Short Syntax Style Guide s Dangerous Ruby s Comparing Ruby s Convincing... Not many browsers support this; in fact only Microsoft’s Internet Explorer can do this for certain Using Ruby on the Web Generating HTML with Ruby Ruby HTML Code Generation Ruby CGI HTML Generation Scripting With Ruby Using eruby and ERb Templating With Ruby Using the HTML/Template Extension Using Ruby- tmpl Putting It All Together Implementing an Online Shopping Application Designing the Data Model The... protocols (XML-RPC and SOAP) from Ruby as well as how to connect two or more Ruby applications across a network using Distributed Ruby (DRb) Chapter 6: WWW and Networking with Ruby develops a Web-based, database-driven online-shop application, comparing a CGI/FastCGI approach with the utilization of mod _ruby and eruby, and using Interpreted Objects for Web Applications (IOWA), Ruby s powerful application... Extensions:Tix and BLT 68 Using the GTK+ Toolkit 68 Obtaining Ruby/ GTK 69 Ruby/ GTK Basics 70 Programming Signals and Signal Handlers 71 Working with Ruby/ GTK’s Layout Managers 72 Ruby/ GTK Sample Application 76 183RubyToC.qxd 1/7/02 4:31 PM Page xiii Contents Master the Grid Layout Manager Using the Glade GUI Builder Using the FOX Toolkit Obtaining FOX and FXRuby FXRuby Basics Targets and Messages Working with FOX’s... evolution Chapter 1: Booting Ruby provides the basics of getting started by explaining Ruby syntax, and about working with applications and editors Chapter 2: GUI Toolkits for Ruby develops a sample application (a XML viewer) with four different GUI toolkits available for Ruby: Tk, Gtk, Fox, and VRuby Chapter 3: Accessing Databases with Ruby introduces you to programming with Ruby/ DBI, a unique database-independent... version using the following two commands: cvs -d :pserver:anonymous@cvs .ruby- lang.org:/src login www.syngress.com 183RubyC01.qxd 1/4/02 3:50 PM Page 7 Booting Ruby • Chapter 1 (Logging in to anonymous@cvs .ruby- lang.org) CVS password: anonymous cvs -z4 -d :pserver:anonymous@cvs .ruby- lang.org:/src co ruby After that, change into the ruby directory in which CVS downloaded all files, and issue the autoconf... hard drive tar –xvzf rubyunit-x.x.x.tar.gz 3 Install the application, in this case, the following: cd rubyunit-x.x.x ruby install.rb Other Ruby packages may use a Ruby configuration script to grab parameters before installing.The extconf.rb installation procedure is fairly straightforward After untarring your package, do the following: ruby extconf.rb make make install Figure 1.4 The Ruby Application Archive . Generating HTML with Ruby 356 Ruby HTML Code Generation 356 Ruby CGI HTML Generation 357 Scripting With Ruby Using eruby and ERb 358 Templating With Ruby 359 Using. mod _ruby and eruby 383 Installing and Configuring mod _ruby 384 Using mod _ruby and eruby in the Online Shop Example 386 Dynamically Generating XML with eruby

Ngày đăng: 26/10/2013, 23:15

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan