Maik Schmidt — «Enterprise Recipes with Ruby and Rails

Total Page:16

File Type:pdf, Size:1020Kb

Maik Schmidt — «Enterprise Recipes with Ruby and Rails What readers are saying about Enterprise Recipes with Ruby and Rails Enterprise Recipes with Ruby and Rails covers most of the tasks you need to accomplish in the enterprise, including integration with other systems, databases, and security measures. I wish I’d had this book three years ago. Ola Bini JRuby Core Developer, ThoughtWorks Studios This book is full of practical, relevant advice instead of theoretical background or “Hello, World” samples. Once you move beyond the basic skills of using Ruby and Rails, this is exactly what you need— real-world recipes that you can put to use immediately. It’s like getting condensed experience on paper, giving you a two-year head start on those who have to acquire this knowledge by making their own mis- takes. Stefan Tilkov CEO and Principal Consultant, innoQ If you’re responsible for developing enterprise software, after reading this book you’ll want to review all your projects to see where you can save time and money with Ruby and Rails. Maik Schmidt shows us once again that enterprise software doesn’t have to be “enterprisey.” Steve Vinoski IEEE Internet Computing Columnist and Member of Technical Staff, Verivue, Inc. On exactly the right level, this book explains many interesting libraries and tools invaluable for enterprise developers. Even experi- enced Ruby and Rails developers will find new information. Thomas Baustert Rails Book Author, b-simple.de Enterprise Recipes with Ruby and Rails Maik Schmidt The Pragmatic Bookshelf Raleigh, North Carolina Dallas, Texas Many of the designations used by manufacturers and sellers to distinguish their prod- ucts are claimed as trademarks. Where those designations appear in this book, and The Pragmatic Programmers, LLC was aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf and the linking g device are trademarks of The Pragmatic Programmers, LLC. Every precaution was taken in the preparation of this book. However, the publisher assumes no responsibility for errors or omissions, or for damages that may result from the use of information (including program listings) contained herein. Our Pragmatic courses, workshops, and other products can help you and your team create better software and have more fun. For more information, as well as the latest Pragmatic titles, please visit us at http://www.pragprog.com Copyright © 2008 Maik Schmidt. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmit- ted, in any form, or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior consent of the publisher. Printed in the United States of America. ISBN-10: 1-934356-23-9 ISBN-13: 978-1-934356-23-4 Printed on acid-free paper. P1.0 printing, November 2008 Version: 2009-4-20 For my girls: Mia, Henriette, and Caro. Contents Foreword 9 Acknowledgments 12 Preface 13 Part I—Security & E-commerce Recipes 20 1 Implement Enterprise-wide Security 21 1. Protect Information with Symmetric Ciphers . 23 2. Protect Secrets with Asymmetric Ciphers . 28 3. Verify Data Integrity with Signatures ........... 31 4. Generate Real Random Numbers ............. 35 5. Create Strong and Convenient Passwords . 38 6. Store Passwords Securely ................. 44 7. Reanimate Good Old Basic Authentication . 48 8. Implement a Single Sign-on System with OpenID . 51 9. Authenticate with LDAP .................. 58 2 Process E-commerce Payments 62 10. Charge Credit Cards with ActiveMerchant . 64 11. Integrate ActiveMerchant with Rails ........... 70 12. Transfer Money with PayPal ................ 78 Part II—Databases & XML Recipes 88 3 Get the Most Out of Databases 89 13. Execute Stored Procedures ................ 91 14. Feed Rails Databases from the Outside ......... 98 15. Access Databases from Different Vendors Simultane- ously ............................. 105 16. Manage Data with Subversion ............... 110 CONTENTS 7 4 Tame File and Data Formats 116 17. Manipulate CSV with Ruby ................ 118 18. Read and Write Fixed-Length Records .......... 123 19. Harness JSON in Ruby ................... 130 20. Master Binary Data ..................... 134 5 Process XML Documents the Ruby Way 140 21. XML Data Binding on Steroids .............. 142 22. Use XML Files as Models .................. 146 23. Handle Large XML Documents .............. 154 24. High-Performance Parsing ................. 159 25. Work with HTML and Microformats ............ 165 26. Build Plain-Vanilla XML Documents ........... 172 27. Build Arbitrary XML Documents ............. 174 Part III—Networking & Messaging Recipes 178 6 Perform Basic Networking Tasks with Ease 179 28. Harness the Power of Sockets ............... 180 29. Find Solutions Quickly with open-uri .......... 186 30. Get the Most Out of HTTP ................. 190 31. Scrape Screens with WWW::Mechanize ......... 196 7 Use and Build Web Services 202 32. Publish Resources with REST ............... 203 33. Use REST Services ..................... 211 34. Build Your Own SOAP Services .............. 217 35. Use SOAP Services with WSDL .............. 221 8 Talk to Message Brokers 224 36. Transfer Messages with Files ............... 226 37. Create a Messaging Infrastructure ............ 233 38. Integrate with JMS ..................... 242 39. Connect to Message Queues with ActiveMessaging . 248 Report erratum this copy is (P1.0 printing, November 2008) CONTENTS 8 Part IV—Integration & Administration Recipes 256 9 Speak Foreign Languages 257 40. Embed C and C++ ...................... 258 41. Mix Java and Ruby Code .................. 265 42. Use RMI Services ...................... 271 43. Mix Ruby and .NET with IronRuby ............ 275 10 Maintain and Administer Your Applications 284 44. Turn Your Code into Daemons and Services . 286 45. Monitor Your Applications with Monit .......... 295 46. Let god Take Care of Your System ............ 301 47. Create Plug-ins for Common Tasks ............ 306 48. Avoid Code Duplication with Generators ......... 311 11 Test the Easy Way 315 49. Improve Your Testing with RSpec ............. 316 50. Integrate RSpec with Rails ................. 323 51. Create Mock Objects with RSpec ............. 326 52. Prototype Services with Sinatra .............. 334 12 Get Documentation Nearly for Free 343 53. Generate Documentation Automatically ......... 345 54. Annotate Your Models Automatically ........... 352 55. Create Great Reports .................... 356 Bibliography 365 Index 366 Report erratum this copy is (P1.0 printing, November 2008) Foreword I’m glad someone finally wrote this book. Let me explain. I’ve been bullish on Ruby in the enterprise for a long time now, both with and without Rails. And, the company for which I work, ThoughtWorks, has also been a strong advocate for enterprise Rails. It happened for me shortly after I fully understood what sets Rails apart from other web frameworks. At the time, the last thing I wanted to see was another web framework, recently having completed a book comparing the dizzying array of web frameworks in the Java space (the now very outdated Art of Java Web Development [For03]). Once you’ve spent that much time looking at frameworks, a new one is not high on your list of priorities. But when Rails came along, I could tell that it was completely different and that it had lots of compelling, obvious- in-hindsight ideas embedded inside it. I remember thinking “Wow, this is going to be a really cool thing when all the libraries catch up.” For something to be “enterprise ready,” you have to have tons of libraries to support all the interactions with the outside world and repositories of reusable code, so I estimated at the time that it would take five or six years for Ruby to even sit at the table in the enterprise world. But I was wrong in two ways. First, I greatly underestimated the pas- sion and fire in the Ruby community to roll up their sleeves and create all the libraries needed to let Rails play in any space it wants. The sec- ond way I was wrong reflects the first: it’s just plain easier to write stuff in Ruby. I was carrying all the prejudices from my experience with other languages, where it takes a lot of work to write reusable libraries of code. And the reason for that comes from what I call the “Lockdown Experiment.” Back in the mid-90s, an experiment started as a way to make average developers more effective, because the demand continued (as it does today) to outstrip the supply of good developers. If the software industry can figure out a way to make mediocre developers productive, software FOREWORD 10 development can expand to enterprise scales. Thus, we saw the rise of languages like Visual Basic and Java and later C#. These languages were specifically made less powerful than alternatives (like Smalltalk). The goal of the Lockdown Experiment: make tools to keep average devel- opers out of trouble while still being able to write code. But then a cou- ple of interesting things happened. First, creating restrictive tools and languages didn’t really keep average developers out of trouble, because average developers sometimes apply great ingenuity to coming up with ridiculously complex solutions to problems. But while this didn’t really make the average developers better, it put a serious governor on the best developers. The whole industry seemed to be optimizing for the wrong thing: safety at the expense of power, with the stated goal of creating
Recommended publications
  • Systemd – Easy As 1, 2, 3
    Systemd – Easy as 1, 2, 3 Ben Breard, RHCA Solutions Architect, Red Hat [email protected] Agenda ● Systemd functionality ● Coming to terms ● Learning the basics ● More advanced topics ● Learning the journal ● Available resources 2 Systemd is more than a SysVinit replacement 3 Systemd is a system and service manager 4 Systemd Overview ● Controls “units” rather than just daemons ● Handles dependency between units. ● Tracks processes with service information ● Services are owned by a cgroup. ● Simple to configure “SLAs” based on CPU, Memory, and IO. ● Properly kill daemons ● Minimal boot times ● Debuggability – no early boot messages are lost ● Easy to learn and backwards compatible. 5 Closer look at Units 6 Systemd - Units ● Naming convention is: name.type ● httpd.service, sshd.socket, or dev-hugepages.mount ● Service – Describe a daemon's type, execution, environment, and how it's monitored. ● Socket – Endpoint for interprocess communication. File, network, or Unix sockets. ● Target – Logical grouping of units. Replacement for runlevels. ● Device – Automatically created by the kernel. Can be provided to services as dependents. ● Mounts, automounts, swap – Monitor the mounting/unmounting of file systems. 7 Systemd – Units Continued ● Snapshots – save the state of units – useful for testing ● Timers – Timer-based activation ● Paths – Uses inotify to monitor a path ● Slices – For resource management. ● system.slice – services started by systemd ● user.slice – user processes ● machine.slice – VMs or containers registered with systemd 8 Systemd – Dependency Resolution ● Example: ● Wait for block device ● Check file system for device ● Mount file system ● nfs-lock.service: ● Requires=rpcbind.service network.target ● After=network.target named.service rpcbind.service ● Before=remote-fs-pre.target 9 That's all great .......but 10 Replace Init scripts!? Are you crazy?! 11 We're not crazy, I promise ● SysVinit had a good run, but leaves a lot to be desired.
    [Show full text]
  • Cisco Virtualized Infrastructure Manager Installation Guide, 2.4.9
    Cisco Virtualized Infrastructure Manager Installation Guide, 2.4.9 First Published: 2019-01-09 Last Modified: 2019-05-20 Americas Headquarters Cisco Systems, Inc. 170 West Tasman Drive San Jose, CA 95134-1706 USA http://www.cisco.com Tel: 408 526-4000 800 553-NETS (6387) Fax: 408 527-0883 THE SPECIFICATIONS AND INFORMATION REGARDING THE PRODUCTS IN THIS MANUAL ARE SUBJECT TO CHANGE WITHOUT NOTICE. ALL STATEMENTS, INFORMATION, AND RECOMMENDATIONS IN THIS MANUAL ARE BELIEVED TO BE ACCURATE BUT ARE PRESENTED WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. USERS MUST TAKE FULL RESPONSIBILITY FOR THEIR APPLICATION OF ANY PRODUCTS. THE SOFTWARE LICENSE AND LIMITED WARRANTY FOR THE ACCOMPANYING PRODUCT ARE SET FORTH IN THE INFORMATION PACKET THAT SHIPPED WITH THE PRODUCT AND ARE INCORPORATED HEREIN BY THIS REFERENCE. IF YOU ARE UNABLE TO LOCATE THE SOFTWARE LICENSE OR LIMITED WARRANTY, CONTACT YOUR CISCO REPRESENTATIVE FOR A COPY. The Cisco implementation of TCP header compression is an adaptation of a program developed by the University of California, Berkeley (UCB) as part of UCB's public domain version of the UNIX operating system. All rights reserved. Copyright © 1981, Regents of the University of California. NOTWITHSTANDING ANY OTHER WARRANTY HEREIN, ALL DOCUMENT FILES AND SOFTWARE OF THESE SUPPLIERS ARE PROVIDED “AS IS" WITH ALL FAULTS. CISCO AND THE ABOVE-NAMED SUPPLIERS DISCLAIM ALL WARRANTIES, EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, THOSE OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OR ARISING FROM A COURSE OF DEALING, USAGE, OR TRADE PRACTICE. IN NO EVENT SHALL CISCO OR ITS SUPPLIERS BE LIABLE FOR ANY INDIRECT, SPECIAL, CONSEQUENTIAL, OR INCIDENTAL DAMAGES, INCLUDING, WITHOUT LIMITATION, LOST PROFITS OR LOSS OR DAMAGE TO DATA ARISING OUT OF THE USE OR INABILITY TO USE THIS MANUAL, EVEN IF CISCO OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
    [Show full text]
  • Product End User License Agreement
    END USER LICENSE AGREEMENT If you have another valid, signed agreement with Licensor or a Licensor authorized reseller which applies to the specific Licensor Software, Software Services, Maintenance or Consulting Services you are downloading, accessing or otherwise receiving, that other agreement shall control; otherwise by using, downloading, installing, copying, or accessing Licensor Software, Software Services, Maintenance or Consulting Services, or by clicking on "I accept" on or adjacent to the screen where these Master Terms may be displayed, you hereby agree to be bound by and accept these Master Terms. These Master Terms shall also apply to any Maintenance or Consulting Services you later acquire from Licensor relating to the Software or Software Services. You may place orders under these Master Terms by submitting separate Order Form(s). Capitalized terms used in these Master Terms and not otherwise defined, are defined at https://terms.tibco.com/posts/845635-definitions. 1. License Models, License Grant, Rights and Restrictions. Licensor provides Software on a Perpetual, or Term basis, embedded and delivered as part of Equipment, as Software Services and on a Subscription basis. The Supplemental Terms, include, but are not limited to, the license grant, rights and restrictions for each of the foregoing (including for evaluation purposes) which are located at https://terms.tibco.com. The availability of Software in one or more of the foregoing license models is at Licensor's sole discretion. Additional license requirements and notices, if any, if not included at https://terms.tibco.com, shall be contained in the Documentation that is delivered with the applicable Software.
    [Show full text]
  • Rails 4 En Windows Y Linux Ubuntu – V 1.0.5 Beta – Pag 1/200 - Actualizado Al 7/10/ 2016 Sergio A
    Sergio A. Alonso - Rails 4 en Windows y Linux Ubuntu – v 1.0.5 Beta – pag 1"#00 - a$tuali%ado al &"10" 201' Sergio A. Alonso - Rails 4 en Windows y Linux Ubuntu – v 1.0.5 Beta – pag #"#00 - a$tuali%ado al &"10" 201' ¡Ud podría estar leyendo una copia vieja! ()equee la versión en el en$abe%ado de las )o,as- $ontra la última en el sitio o.$ial- )tt!/""r0uw.)ero1u.$o2 3esde allí en$ontrará el vín$ulo )acia la versión 2as actual- y un listado 2uy útil de erratas- $orrec$iones- e in$luso una sec$ión donde !ostear errores y sugeren$ias. Este libro es tan gratis como una cerveza (free-as-a-beer) (uente sie2!re con la 6ltima versión dis!onible en P38. Mi ob,etivo es que lo lea la mayor cantidad posible de personas, y que éstas me retornen sus im!resiones, errores encontrados y sugerencias en general. De he$ho, ne$esito de estos re!ortes para obtener un nivel a!re$iable de $alidad, tal *ue el libro sea digno de ser llevado a una im!renta. Una ve% que el libro este listo, pretendo seguir de,5ndolo libre, publicarlo en la editorial Bubok ;i2!resión a de2anda<- y *uedar2e como mu$ho con u=s 5 de regalías por libro... al menos para ha$erle creer a mi es!osa que hago dinero con esto. Creo que si el libro lo mere$e, la gente se cansar5 de leerlo en !antalla- y querr5 tener un e,e2!lar en pa!el.
    [Show full text]
  • Roles in a Networked Software Development Ecosystem: a Case Study in Github Patrick Wagstrom IBM TJ Watson Research Center Hawthorne, NY, [email protected]
    University of Nebraska - Lincoln DigitalCommons@University of Nebraska - Lincoln CSE Technical reports Computer Science and Engineering, Department of 2012 Roles in a Networked Software Development Ecosystem: A Case Study in GitHub Patrick Wagstrom IBM TJ Watson Research Center Hawthorne, NY, [email protected] Corey Jergensen University of Nebraska-Lincoln, [email protected] Anita Sarma University of Nebraska-Lincoln, [email protected] Follow this and additional works at: http://digitalcommons.unl.edu/csetechreports Wagstrom, Patrick; Jergensen, Corey; and Sarma, Anita, "Roles in a Networked Software Development Ecosystem: A Case Study in GitHub" (2012). CSE Technical reports. 149. http://digitalcommons.unl.edu/csetechreports/149 This Article is brought to you for free and open access by the Computer Science and Engineering, Department of at DigitalCommons@University of Nebraska - Lincoln. It has been accepted for inclusion in CSE Technical reports by an authorized administrator of DigitalCommons@University of Nebraska - Lincoln. Roles in a Networked Software Development Ecosystem: A Case Study in GitHub Patrick Wagstrom Corey Jergensen, Anita Sarma IBM TJ Watson Research Center Computer Science and Engineering Department 19 Skyline Dr University of Nebraska, Lincoln Hawthorne, NY, USA 10532 Lincoln, NE, USA 68588 [email protected] {cjergens,asarma}@cse.unl.edu ABSTRACT tiple languages and utilizing multiple different development Open source software development has evolved beyond single frameworks and libraries, For example, development of a web projects into complex networked ecosystems of projects that application may use the JavaScript library jQuery for the user share portions of their code, social norms, and developer commu- interaction, Ruby on Rails for the backend processing, and Rack nities.
    [Show full text]
  • Extending Facter and Puppet
    Pro Puppet James Turnbull Jeffrey McCune Pro Puppet Copyright © 2011 by James Turnbull and Jeffrey McCune 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 978-1-4302-3057-1 ISBN 978-1-4302-3058-8 (eBook) Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. President and Publisher: Paul Manning Lead Editor: Frank Pohlmann Technical Reviewer: Jessica Fraser Editorial Board: Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Jeff Olson, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Coordinating Editor: Anita Castro Copy Editor: Seth Kline Compositor: Bytheway Publishing Services Indexer: John Collin Artist: April Milne Cover Designer: Anna Ishchenko Distributed to the book trade worldwide by Springer Science+Business Media, LLC., 233 Spring Street, 6th Floor, New York, NY 10013.
    [Show full text]
  • Continuous Integration with Jenkins
    Automated Deployment … of Debian & Ubuntu Michael Prokop About Me Debian Developer Project lead of Grml.org ounder of Grml-Forensic.org #nvolved in A#$ initramf"-tools$ etc. Member in Debian orensic Team Author of &ook $$Open Source Projektmanagement) #T *on"ultant Disclaimer" Deployment focuses on Linux (everal tools mentioned$ but there exist even more :. We'll cover some sections in more detail than others %here's no one-size-fits-all solution – identify what works for you Sy"tems Management Provisioning 4 Documentation &oot"trapping #nfrastructure 'rche"tration 4 Development Dev'ps Automation 6isualization/Trends *onfiguration 4Metric" + Logs Management Monitoring + *loud Service Updates Deployment Systems Management Remote Acce"" ipmi, HP i+'$ IBM RSA,... irm3are Management 9Vendor Tools Provisioning / Bootstrapping :ully) A(utomatic) I(n"tallation) Debian, Ubuntu$ Cent'( + Scientific +inu, http://fai-project.org/ ;uju Ubuntu <Charms= https-44juju.ubuntu.com/ grml-debootstrap netscript=http://example.org/net"cript.sh http-44grml.org4 d-i preseeding auto url>http-44debian.org/releases4\ "queeze/example-preseed.txt http-443iki.debian.org/DebianInstaller/Preseed Kickstart Cobbler Foreman AutoYa(%$ openQRM, (pace3alk,... Orche"tration / Automation Fabric (Python) % cat fabfile.py from fabric.api import run def host_type(): run('uname -s') % fab -H host1, host2,host3 host_type Capistrano (Ruby) % cat Capfile role :hosts, "host1", "host2", "host3" task :host_type, :roles => :hosts do run "uname -s" end % cap host_type 7undeck apt-dater % cat .config/apt-dater/hosts.conf [example.org] [email protected];mika@ mail.example.org;... *ontrolTier, Func$ MCollective$... *luster((8$ dsh, TakTuk,... *obbler$ Foreman$ openQRM, Spacewalk,... *onfiguration Management Puppet Environment" :production4"taging/development.
    [Show full text]
  • Rubywrite: a Ruby-Embedded Domain-Specific Language for High-Level Transformations
    RubyWrite: A Ruby-Embedded Domain-Specific Language for High-Level Transformations Andrew Keep, Arun Chauhan, Chun-Yu Shei, and Pushkar Ratnalikar Indiana University, Bloomington, IN 47405, USA fakeep,achauhan,cshei,[email protected] Abstract. We introduce a Domain Specific Language (DSL), called RubyWrite, embedded within Ruby, with the goal of providing an ex- tensible, effective, portable, and easy to use framework for encoding source-level transformations. Embedding within Ruby provides access to the powerful features of Ruby, including its purely object-oriented design and meta-programming capabilities. The syntactic flexibility and advanced language features of Ruby drove our choice of it as the host lan- guage. Easy integration of external C interfaces seamlessly within Ruby lets us move performance critical operations to C, or link with external libraries. RubyWrite was developed to aid our compiler research where it provides the core of three compiler infrastructure development projects, and is used as a teaching aid in a graduate-level compilers course. We expect RubyWrite to be widely applicable and a proof of concept in leveraging an existing modern language to write a portable compiler in- frastructure core. 1 Introduction We describe a Domain Specific Language (DSL), embedded within Ruby, aimed at simplifying the task of source-level transformations through term-rewriting. The DSL, called RubyWrite, is motivated by the need for a compiler development environment that allows easy integration of source-level transformations with program analysis. After spending frustrating months trying to develop a compiler for matlab in C++ a few years ago, we made the decision to move to a domain-specific lan- guage for compiler development.
    [Show full text]
  • Ruby on Rails
    Ruby.learn{ |stuff| } ● What is Ruby? ● What features make it interesting to me (and maybe you)? ● A quick, idiosyncratic tour of the Ruby ecosphere. Tuesday Software Lunch Talk: March 4, 2008 What is it? ● a dynamic, object-oriented, open source programming language... ● with a uniquely (but not too uniquely), expressive syntax ● dynamically or “duck” typed ● influenced by Perl, Smalltalk, Eiffel, Ada and Lisp ● has aspects of functional and imperative programming styles History ● created by Yukihiro “Matz” Matsumoto on Feb 24 1993, released to public in 1995 ● “Ruby” coined in comparison to “Perl” Philosophy (the “Ruby Way”) ● emphasize programmer needs over computer needs ● encourage good design, good APIs ● Principle of Least Surprise (POLS) – the language should behave in such a way as to minimize confusion for experienced users ● “Everything should be a simple as possible, but no simpler.” - Einstein ● orthogonality ● change at runtime is not to be feared Interesting Stuff... ● Is Not a Ruby tutorial – http://tryruby.hobix.com/ – Programming Ruby: The Pragmatic Programmer's Guide – our just google it – you want something totally different? ● http://poignantguide.net/ruby/ ● Is what I find interesting/different/well done about Ruby. Everything's an Object ● no exceptions Falsiness ● only false and nil are falsey. Not 0. Symbols ● labels ● lightweight strings with no behaviour ● often used as hash keys Blocks ● another name for a Ruby block is a “closure” ● clo-sure [kloh-zher] – noun. A function that is evaluated in an environment containing one or more bound variables. Procs ● anonymous subroutines or closures with a life of their own Adding Methods to Classes ● You can add methods to an object at runtime in several ways..
    [Show full text]
  • Ruby Programming
    Ruby Programming Wikibooks.org December 1, 2012 On the 28th of April 2012 the contents of the English as well as German Wikibooks and Wikipedia projects were licensed under Creative Commons Attribution-ShareAlike 3.0 Unported license. An URI to this license is given in the list of figures on page 249. If this document is a derived work from the contents of one of these projects and the content was still licensed by the project under this license at the time of derivation this document has to be licensed under the same, a similar or a compatible license, as stated in section 4b of the license. The list of contributors is included in chapter Contributors on page 243. The licenses GPL, LGPL and GFDL are included in chapter Licenses on page 253, since this book and/or parts of it may or may not be licensed under one or more of these licenses, and thus require inclusion of these licenses. The licenses of the figures are given in the list of figures on page 249. This PDF was generated by the LATEX typesetting software. The LATEX source code is included as an attachment (source.7z.txt) in this PDF file. To extract the source from the PDF file, we recommend the use of http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/ utility or clicking the paper clip attachment symbol on the lower left of your PDF Viewer, selecting Save Attachment. After extracting it from the PDF file you have to rename it to source.7z. To uncompress the resulting archive we recommend the use of http://www.7-zip.org/.
    [Show full text]
  • Power State Management in Automotive Linux
    Power State Management in Automotive Linux Table of Contents Terminology As automotive, consumer electronics, and embedded Executive Summary ............................................................1 software and hardware engineering intersect, technical Vehicle Power States and Device Energy traditions and vocabulary for in-car systems design begin Management ......................................................................1 to overlap. The following terms are defined for use in this Key Linux/Open Source Software Technologies document. for Automotive ...................................................................2 Power state management: Automakers and their supply CAN and MOST Drivers and Protocols ..........................2 chains use power management to describe the state of D-Bus ..............................................................................3 vehicles and in-vehicle systems relative to their policies for and use of electric power flowing from a vehicle’s Energy Management ......................................................3 alternator and battery. To minimize confusion between Initng: Next-Generation Init System ..............................3 familiar automotive terms and current embedded and System Health Monitoring – Monit ................................4 mobile terms, in this document power state management Conclusion ..........................................................................4 is used to describe the software infrastructure to support vehicle power states and transitions. Energy
    [Show full text]
  • The Ruby Intermediate Language ∗
    The Ruby Intermediate Language ∗ Michael Furr Jong-hoon (David) An Jeffrey S. Foster Michael Hicks University of Maryland, College Park ffurr,davidan,jfoster,[email protected] Abstract syntax that is almost ambiguous, and a semantics that includes Ruby is a popular, dynamic scripting language that aims to “feel a significant amount of special case, implicit behavior. While the natural to programmers” and give users the “freedom to choose” resulting language is arguably easy to use, its complex syntax and among many different ways of doing the same thing. While this ar- semantics make it hard to write tools that work with Ruby source guably makes programming in Ruby easier, it makes it hard to build code. analysis and transformation tools that operate on Ruby source code. In this paper, we describe the Ruby Intermediate Language In this paper, we present the Ruby Intermediate Language (RIL), (RIL), an intermediate language designed to make it easy to ex- a Ruby front-end and intermediate representation that addresses tend, analyze, and transform Ruby source code. As far as we are these challenges. RIL includes an extensible GLR parser for Ruby, aware, RIL is the only Ruby front-end designed with these goals in and an automatic translation into an easy-to-analyze intermediate mind. RIL provides four main advantages for working with Ruby form. This translation eliminates redundant language constructs, code. First, RIL’s parser is completely separated from the Ruby in- unravels the often subtle ordering among side effecting operations, terpreter, and is defined using a Generalized LR (GLR) grammar, and makes implicit interpreter operations explicit.
    [Show full text]