Agile Web Development with Rails Fourth Edition

Total Page:16

File Type:pdf, Size:1020Kb

Agile Web Development with Rails Fourth Edition Prepared exclusively for Anton Fonarev Beta Book Agile publishing for agile developers Under Construction The book you’re reading is still under development. As part of our Beta book program, we’re releasing this copy well before a normal book would be released. That way you’re able to get this content a couple of months before it’s available in finished form, and we’ll get feedback to make the book even better. The idea is that everyone wins! Be warned. The book has not had a full technical edit, so it will contain errors. It has not been copyedited, so it will be full of typos and other weird- ness. And there’s been no effort spent doing layout, so you’ll find bad page breaks, over-long lines with little black rectangles, incorrect hyphenations, and all the other ugly things that you wouldn’t expect to see in a finished book. We can’t be held liable if you use this book to try to create a spiffy application and you somehow end up with a strangely shaped farm imple- ment instead. Despite all this, we think you’ll enjoy it! Download Updates Throughout this process you’ll be able to download updated ebooks from your account on http://pragprog.com. When the book is finally ready, you’ll get the final version (and subsequent updates) from the same address. Send us your feedback In the meantime, we’d appreciate you sending us your feedback on this book at http://pragprog.com/titles/rails4/errata, or by using the links at the bottom of each page. Thank you for being part of the Pragmatic community! Andy & Dave Prepared exclusively for Anton Fonarev Agile Web Development with Rails Fourth Edition Sam Ruby Dave Thomas David Heinemeier Hansson with Leon Breedt Mike Clark James Duncan Davidson Justin Gehtland Andreas Schwarz The Pragmatic Bookshelf Raleigh, North Carolina Dallas, Texas Prepared exclusively for Anton Fonarev Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and The Pragmatic Program- mers, 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 Program- ming, 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 © 2011 The Pragmatic Programmers LLC. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, 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-54-9 ISBN-13: 978-1-934356-54-8 Printed on acid-free paper. B13.0 printing, February 2, 2011 Version: 2011-2-2 Prepared exclusively for Anton Fonarev Contents Changes in the Beta Releases 10 Beta 13—February 2 ........................... 10 Beta 12—January 10 .......................... 10 Beta 11—November 24 ......................... 10 Beta 10—October 28 ........................... 10 Beta 9—October 6 ............................ 11 Beta 8—September 9 .......................... 11 Beta 7—August 25 ............................ 12 Beta 6—July 27 .............................. 12 Beta 5—June 28 ............................. 12 Beta 4—May 26 .............................. 13 Beta 3—May 11 .............................. 13 Beta 2—May 3 .............................. 13 Preface to the Fourth Edition 15 Acknowledgments 17 Introduction 19 Rails Simply Feels Right ......................... 19 Rails Is Agile ............................... 21 Who This Book Is For .......................... 22 How To Read This Book ......................... 22 Part I—Getting Started 26 1 Installing Rails 27 1.1 Installing on Windows ...................... 27 1.2 Installing on Mac OS X ..................... 29 1.3 Installing on Linux ........................ 30 1.4 Choosing a Rails Version .................... 31 1.5 Setting Up Your Development Environment . 32 1.6 Rails and Databases ....................... 36 1.7 What We Just Did ........................ 37 Prepared exclusively for Anton Fonarev CONTENTS 6 2 Instant Gratification 38 2.1 Creating a New Application ................... 38 2.2 Hello, Rails! ............................ 40 2.3 Linking Pages Together ..................... 47 2.4 What We Just Did ........................ 49 3 The Architecture of Rails Applications 51 3.1 Models, Views, and Controllers . 51 3.2 Rails Model Support ....................... 54 3.3 Action Pack: The View and Controller . 56 4 Introduction to Ruby 58 4.1 Ruby Is an Object-Oriented Language . 58 4.2 Data Types ............................ 60 4.3 Logic ................................ 63 4.4 Organizing Structures ...................... 66 4.5 Marshaling Objects ....................... 69 4.6 Pulling It All Together ...................... 69 4.7 Ruby Idioms ........................... 70 Part II—Building an Application 73 5 The Depot Application 74 5.1 Incremental Development .................... 74 5.2 What Depot Does ......................... 75 5.3 Let’s Code ............................. 79 6 Task A: Creating the Application 81 6.1 Iteration A1: Creating the Products Maintenance Applica- tion ................................. 81 6.2 Iteration A2: Making Prettier Listings . 88 7 Task B: Validation and Unit Testing 95 7.1 Iteration B1: Validating! ..................... 95 7.2 Iteration B2: Unit Testing of Models . 100 8 Task C: Catalog Display 109 8.1 Iteration C1: Creating the Catalog Listing . 109 8.2 Iteration C2: Adding a Page Layout . 112 8.3 Iteration C3: Using a Helper to Format the Price . 116 8.4 Iteration C4: Functional Testing of Controllers . 117 Report erratum Prepared exclusively for Anton Fonarev this copy is (B13.0 printing, February 2, 2011) CONTENTS 7 9 Task D: Cart Creation 121 9.1 Iteration D1: Finding a Cart . 121 9.2 Iteration D2: Connecting Products to Carts . 122 9.3 Iteration D3: Adding a Button . 124 10 Task E: A Smarter Cart 130 10.1 Iteration E1: Creating a Smarter Cart . 130 10.2 Iteration E2: Handling Errors . 135 10.3 Iteration E3: Finishing the Cart . 138 11 Task F: Add a Dash of Ajax 143 11.1 Iteration F1: Moving the Cart . 144 11.2 Iteration F2: Creating an Ajax-Based Cart . 149 11.3 Iteration F3: Highlighting Changes . 152 11.4 Iteration F4: Hiding an Empty Cart . 154 11.5 Testing Ajax Changes . 158 12 Task G: Check Out! 163 12.1 Iteration G1: Capturing an Order . 163 12.2 Iteration G2: Atom Feeds . 177 12.3 Iteration G3: Pagination . 181 13 Task H: Sending Mail 186 13.1 Iteration H1: Sending Confirmation Emails . 186 13.2 Iteration H2: Integration Testing of Applications . 193 14 Task I: Logging In 199 14.1 Iteration I1: Adding Users . 199 14.2 Iteration I2: Authenticating Users . 207 14.3 Iteration I3: Limiting Access . 213 14.4 Iteration I4: Adding a Sidebar, More Administration . 216 15 Task J: Internationalization 221 15.1 Iteration J1: Selecting the Locale . 222 15.2 Iteration J2: Translating the Storefront . 224 15.3 Iteration J3: Translating Checkout . 231 15.4 Iteration J4: Add a Locale Switcher . 237 16 Task K: Deployment and Production 241 16.1 Iteration K1: Deploying with Phusion Passenger and MySQL 243 16.2 Iteration K2: Deploying Remotely with Capistrano . 248 16.3 Iteration K3: Checking Up on a Deployed Application . 254 Report erratum Prepared exclusively for Anton Fonarev this copy is (B13.0 printing, February 2, 2011) CONTENTS 8 17 Depot Retrospective 258 17.1 Rails Concepts . 258 17.2 Documenting What We Have Done . 261 Part III—Rails in Depth 263 18 Finding Your Way Around Rails 264 18.1 Where Things Go . 264 18.2 Naming Conventions . 272 19 Active Record 277 19.1 Defining your Data . 277 19.2 Locating and Traversing Records . 282 19.3 Creating, Reading, Updating, and Deleting (CRUD) . 285 19.4 Participating in the Monitoring Process . 301 19.5 Transactions . 308 20 Action Dispatch and Action Controller 313 20.1 Dispatching Requests to Controllers . 313 20.2 Processing of Requests . 324 20.3 Objects and Operations That Span Requests . 335 21 Action View 345 21.1 Using Templates . 345 21.2 Generating Forms . 347 21.3 Processing Forms . 350 21.4 Uploading Files to Rails Applications . 352 21.5 Using Helpers . 355 21.6 Reducing Maintenance with Layouts and Partials . 362 22 Caching 371 22.1 Page Caching . 371 22.2 Expiring Pages . 374 22.3 Fragment Caching . 380 23 Migrations 386 23.1 Creating and Running Migrations . 386 23.2 Anatomy of a Migration . 389 23.3 Managing Tables . 393 23.4 Advanced Migrations . 397 23.5 When Migrations Go Bad . 401 23.6 Schema Manipulation Outside Migrations . 402 Report erratum Prepared exclusively for Anton Fonarev this copy is (B13.0 printing, February 2, 2011) CONTENTS 9 24 Nonbrowser Applications 404 24.1 A Stand-Alone Application Using Active Record . 404 24.2 A Library Function Using Active Support . 405 24.3 A Remote Application Using Active Resource . 410 25 Rails’ Dependencies 416 25.1 Generating XML with Builder . 416 25.2 Generating HTML with ERb . 418 25.3 Managing Dependencies with Bundler . 420 25.4 Interfacing with the Web Server with Rack . 422 25.5 Automating Tasks with Rake . 426 25.6 Survey of Rails’ Dependencies . 427 26 Rails Plugins 431 26.1 Credit Card Processing with Active Merchant . 431 26.2 Saving Bandwidth with Asset Packager . 433 26.3 Beautifying Our Markup with Haml . 435 26.4 Write Less and Do More with JQuery . 438 26.5 Finding More at RailsPlugins.org .
Recommended publications
  • Tsuru Documentation Release 1.6.2
    tsuru Documentation Release 1.6.2 tsuru Oct 04, 2018 Contents 1 Understanding 3 1.1 Overview.................................................3 1.2 Concepts.................................................4 1.3 Architecture...............................................5 2 Installing 7 2.1 tsuru Installer...............................................7 2.2 Installing tsuru components....................................... 12 3 Managing 21 3.1 Installing platforms............................................ 21 3.2 Creating a platform............................................ 22 3.3 Using Pools................................................ 23 3.4 Provisioners............................................... 25 3.5 Clusters.................................................. 26 3.6 Segregate Scheduler........................................... 27 3.7 Upgrading Docker............................................ 27 3.8 Managing Git repositories and SSH keys................................ 28 3.9 Managing users and permissions..................................... 28 3.10 Managing Application Logs....................................... 32 3.11 Debugging and Troubleshooting..................................... 33 3.12 Volumes................................................. 34 3.13 Event webhooks............................................. 35 4 Using 39 4.1 Installing tsuru client........................................... 39 4.2 Deploying................................................ 40 4.3 App-Deploy..............................................
    [Show full text]
  • Rmenu Raspberry PI 3B+ Rmenu 環境構築 Raspberry PI3B+ Rmenu
    RaspberryPi3-20190706 RaspberryPI3 Rmenu VPS Rmenu Raspberry PI 3B+ Rmenu 環境構築 Raspberry PI3B+ Rmenu development term 2019/07/06 1 目次 第1章 はじめに ................................................................................................................................... 4 第2章 構築作業、SD イメージ作成 ................................................................................................... 5 1. Raspbian Buster Lite を ダウンロード ......................................................................... 5 2. SD メモリカードフォーマッターを取得しインストール ................................................ 6 3. SD カードをフォーマットします ................................................................................... 8 4. img ファイルの書き込みプログラムのインストール...................................................... 9 5. img ファイルの書き込み ................................................................................................ 9 6. ssh ファイルの書き込み ............................................................................................... 10 7. SD カードを取り付け、電源を入れる .......................................................................... 11 第3章 最初のログイン ...................................................................................................................... 12 1. ルータが付与した IP アドレスへログイン ................................................................... 12 第4章 Linux raspberrypi 初期設定 ................................................................................................. 13 1. ログイン .....................................................................................................................
    [Show full text]
  • Building Blocks of a Scalable Web Crawler
    Building blocks of a scalable web crawler Marc Seeger Computer Science and Media Stuttgart Media University September 15, 2010 A Thesis Submitted in Fulfilment of the Requirements for a Degree of Master of Science in Computer Science and Media Primary thesis advisor: Prof. Walter Kriha Secondary thesis advisor: Dr. Dries Buytaert I I Abstract The purpose of this thesis was the investigation and implementation of a good architecture for collecting, analysing and managing website data on a scale of millions of domains. The final project is able to automatically collect data about websites and analyse the content management system they are using. To be able to do this efficiently, different possible storage back-ends were examined and a system was implemented that is able to gather and store data at a fast pace while still keeping it searchable. This thesis is a collection of the lessons learned while working on the project combined with the necessary knowledge that went into architectural decisions. It presents an overview of the different infrastructure possibilities and general approaches and as well as explaining the choices that have been made for the implemented system. II Acknowledgements I would like to thank Acquia and Dries Buytaert for allowing me to experience life in the USA while working on a great project. I would also like to thank Chris Brookins for showing me what agile project management is all about. Working at Acquia combined a great infrastructure and atmosphere with a pool of knowledgeable people. Both these things helped me immensely when trying to find and evaluate a matching architecture to this project.
    [Show full text]
  • Open Source Code Acknowledgements & Package List
    Open Source Code Acknowledgements & Package List Copyright © 2010 ‐ 2020 Spectra Logic Corporation. All rights reserved. This appendix contains the licenses and notices for open source software used in the product. If you have any questions or want to receive a copy of the free/open source software to which you are entitled under the applicable free/open source license(s) (such as the Common Development and Distribution License (CCDL)), contact Spectra Logic Technical Support. APACHE Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE‐2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “A S IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. FREEBSD Copyright © 1992‐2020 The FreeBSD Project. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE FREEBSD PROJECT ``AS ISʹʹ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    [Show full text]
  • Open Source Licenses 1. Apache-2.0 2. BSD-2-Clause 3
    Open source licenses 1. Apache-2.0 2. BSD-2-Clause 3. BSD-3-Clause 4. BSL-1.0 5. CCPL 6. ISC 7. JSON 8. MIT 9. Zlib Please note, this list may be modified at any time. ------------------------------------------------------------------------------------------------------------------------------------------ Apache License, Version 2.0 adal-node version 0.1.28, Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. adbkit-apkreader version 3.1.2, Copyright © 2013 CyberAgent, Inc., Copyright © 2016 The OpenSTF Project addressable version 2.7.0, Copyright © Bob Aman AWSAPIGateway version 2.6.35, Copyright 2017 - 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. gson version 2.3.1, Copyright 2008 Google Inc. libphonenumber version 7.0.5, Copyright 2014 The Chromium Authors. All rights reserved. dagger version 2.5, Copyright 2012 The Dagger Authors retrofit1-okhttp3-client version 1.0.2, Copyright 2016 Jake Wharton commons-io version 2.5, Copyright 2002-2021 The Apache Software Foundation okhttp version 3.2.0, Copyright 2019 Square, Inc. okio version 1.6.0, Copyright 2013 Square, Inc. retrofit version 1.9.0, Copyright 2013 Square, Inc. detect-libc version 1.0.3, Copyright 2017 Lovell Fuller ecdsa-sig-formatter versions 1.0.9 and 1.0.11, Copyright 2015 D2L Corporation ejs version 2.5.7, EJS Embedded JavaScript templates copyright 2112 [email protected]. FirebaseAuth version 5.0.1, FirebaseCore version 5.0.4, [email protected], FirebaseInstanceID version 3.1.1, [email protected], Copyright 2018 Google LLC rxjava-async-util version 0.21.0, Copyright 2012 Netflix, Inc. rxjava-debug version 1.0.1, Copyright (c) 2016-present, RxJava Contributors.
    [Show full text]
  • Getting Started with Appium
    E-BOOK Getting Started With Appium RUBY EDITION 2018.1 LEARN MORE AT SAUCELABS.COM BY JONATHAN LIPPS TABLE OF CONTENTS 3 Preface 20 Chapter 4: Writing Your First Test 4 Chapter 1: Introduction 25 Chapter 5: Introduction to Page Objects 4 The Appium Vision 30 Chapter 6: Android Joins the Party 5 The Appium Drivers 35 Chapter 7: Running Local Tests With Rake 6 The Appium Clients 36 Chapter 8: Running Tests in the Sauce Labs Cloud 7 Chapter 2: Getting Set Up 40 Annotating Tests on Sauce 7 Assumed Knowledge 41 Chapter 9: Automating Test Runs with a CI Server 7 iOS-specific System Setup 41 Setting Up Jenkins 7 Android-Specific System Setup 42 Creating an Android Build 8 Appium Setup 44 Creating an iOS Build 10 Ruby Client Setup 44 Running on Sauce 10 Project Setup 45 Jenkins for Production 11 Known Working Versions 46 Chapter 10: Heading Out on Your Own 12 Chapter 3: Exploring Your App 46 Resources 12 Using the Appium Ruby Console 47 Support 17 Using the Appium Desktop Inspector PREFACE This little e-book will help you get started with Appium using the Ruby programming language. It is a complete revision from the ground up of an earlier guide written by Dave Haeffner, who along with Matthew Edwards deserves a lot of thanks for all the work put into the first edition. Appium is an open source project that is always changing, and guides like this one will never be accurate forever. When possible I will indicate which versions of various software are being used, which might help in ensuring reproducibility of the code samples used here.
    [Show full text]
  • Bigfix Inventory Open Source Licenses and Notices
    ---------------------------------- BigFix Inventory 10.0 July 2021 ---------------------------------- ------------------------------------------------------------------------- ------------------------------------------------------------------------- The HCL license agreement and any applicable information on the web download page for HCL products refers Licensee to this file for details concerning notices applicable to code included in the products listed above ("the Program"). Notwithstanding the terms and conditions of any other agreement Licensee may have with HCL or any of its related or affiliated entities (collectively "HCL"), the third party code identified below is subject to the terms and conditions of the HCL license agreement for the Program and not the license terms that may be contained in the notices below. The notices are provided for informational purposes. Please note: This Notices file may identify information that is not used by, or that was not shipped with, the Program as Licensee installed it. IMPORTANT: HCL does not represent or warrant that the information in this NOTICES file is accurate. Third party websites are independent of HCL and HCL does not represent or warrant that the information on any third party website referenced in this NOTICES file is accurate. HCL disclaims any and all liability for errors and omissions or for any damages accruing from the use of this NOTICES file or its contents, including without limitation URLs or references to any third party websites. -------------------------------------------------------------------------
    [Show full text]
  • Chef Client Policy
    Dear Participants, • Chef Mailing List Welcome to the course DevOps with Chef on FreeBSD. In • Git website this course, we’ll cover lot of theory and practical aspects. • Ruby Website We’ll focus on the core topics as mentioned in the agenda, Hardware/Software Requirement and we assume that you already know the prerequisites. If • 2 FreeBSD 11 systems/machines (Virtual or Physical), with not, then you might have to learn additional topics such Internet access and bash as the default shell with root as Git, Ruby and FreeBSD first. login over ssh or a normal user with sudo access. • A free account on Hosted Chef. The learning curve for Chef is a little steep at times. There, fore, just be patient and keep working on it, and you’ll eventually be done with the course. We’ll certainly help you throughout the course. But, be prepared to do a lot of self-study as well. Bear in mind that the best way to learn Chef is to just use it. Prerequisites • Knowledge of how to use version control system, pref, erably Git. • Basic Knowledge of FreeBSD OS Administration. • Basic knowledge of any scripting language, preferably Ruby. • Working knowledge of any text/code editor. Resources • FreeBSD • FreeBSD Documentation • Download FreeBSD • Chef Website • Chef Documentation • Chef IRC Channel TABLE OF CONTENTS Module 1: Introduction to Chef.................................................................................................................................................................3 Module 2: Resources.................................................................................................................................................................................7
    [Show full text]
  • The Ruby Way: Solutions and Techniques in Ruby Programming
    Praise for The Ruby Way, Third Edition “Sticking to its tried and tested formula of cutting right to the techniques the modern day Rubyist needs to know, the latest edition of The Ruby Way keeps its strong reputation going for the latest generation of the Ruby language.” Peter Cooper Editor of Ruby Weekly “The authors’ excellent work and meticulous attention to detail continues in this lat- est update; this book remains an outstanding reference for the beginning Ruby pro- grammer—as well as the seasoned developer who needs a quick refresh on Ruby. Highly recommended for anyone interested in Ruby programming.” Kelvin Meeks Enterprise Architect Praise for Previous Editions of The Ruby Way “Among other things, this book excels at explaining metaprogramming, one of the most interesting aspects of Ruby. Many of the early ideas for Rails were inspired by the first edition, especially what is now Chapter 11. It puts you on a rollercoaster ride between ‘How could I use this?’ and ‘This is so cool!’ Once you get on that roller- coaster, there’s no turning back.” David Heinemeier Hansson Creator of Ruby on Rails, Founder at Basecamp “The appearance of the second edition of this classic book is an exciting event for Rubyists—and for lovers of superb technical writing in general. Hal Fulton brings a lively erudition and an engaging, lucid style to bear on a thorough and meticulously exact exposition of Ruby. You palpably feel the presence of a teacher who knows a tremendous amount and really wants to help you know it too.” David Alan Black Author of The Well-Grounded Rubyist “This is an excellent resource for gaining insight into how and why Ruby works.
    [Show full text]
  • Abusing XSLT for Practical Attacks White Paper
    WHITE PAPER Abusing XSLT for Practical Attacks White Paper Fernando Arnaboldi IOActive Senior Security Consultant Abstract Over the years, XML has been a rich target for attackers due to flaws in its design as well as implementations. It is a tempting target because it is used by other programming languages to interconnect applications and is supported by web browsers. In this talk, I will demonstrate how to use XSLT to produce documents that are vulnerable to new exploits. XSLT can be leveraged to affect the integrity of arithmetic operations, lead to code logic failure, or cause random values to use the same initialization vector. Error disclosure has always provided valuable information, but thanks to XSLT, it is possible to partially read system files that could disclose service or system passwords. Finally, XSLT can be used to compromise end-user confidentiality by abusing the same-origin policy concept present in web browsers. This document includes proof-of-concept attacks demonstrating XSLT potential to affect production systems, along with recommendations for safe development. © 2015 IOActive, Inc. All Rights Reserved Contents Abstract ......................................................................................................................... 1 Introduction ................................................................................................................... 3 Processors ............................................................................................................................. 3 Gathering
    [Show full text]
  • Imperative Vs. Object- Oriented Paradigms
    11/11/14 CSCI-2325 Object-Oriented Paradigm: Ruby Mohammad T. Irfan Imperative vs. object- oriented paradigms 1 11/11/14 Imperative vs. object-oriented u Imperative u Procedural decomposition u Procedures are all powerful u Data is helpless, at the mercy of procedures u Object-oriented (OO) u Data-centric: data governs the decomposition u Classes – templates/patterns, abstracts away data u Objects – actual things/instantiations of classes u Advantages of OO paradigm u Collaboration u Debugging u Reuse Roadmap u Learn the basics of Ruby today u Investigate Ruby’s object-oriented design principles u Ruby on Rails for web programming 2 11/11/14 Ruby Installation u Several ways to install, as described here: https://www.ruby-lang.org/en/downloads/ u Mac/Linux: Use RVM (https://rvm.io/rvm/install) u Command line$ \curl -sSL https://get.rvm.io | bash -s stable –ruby u Then, follow the instruction given in terminal u To test, commands are: u ruby –v u rvm –v u If you get errors, run the following commands (assuming 2.1.4 is the latest version—look up rvm website for it) u brew update && brew upgrade u rvm reinstall 2.1.4 --disable-binary u Windows: Install Ruby 2.0.0 from RubyInstaller.org http://rubyinstaller.org/downloads/ u Recommended IDE u Aptana Studio 3 http://www.aptana.com/ Ruby resources u Learning u English translation of the creator’s user guide (by Mark Slagell) u http://www.rubyist.net/~slagell/ruby/index.html u Go to reference u Documentation: http://ruby-doc.org/core-2.0.0/ u http://www.tutorialspoint.com/ruby/ u Interactive tutorial using only your web-browser u http://tryruby.org 3 11/11/14 Origin u Designed by Yukihiro Matsumoto (Matz) in early 1990s u Inspired by Perl and Python u Less scripting than Perl u More object-oriented than Python u Happy experience! Quotes u Bruce Stewart (2001): Did you have a guiding philosophy when designing Ruby? u Matz: Yes, it's called the "principle of least surprise." I believe people want to express themselves when they program.
    [Show full text]
  • Pagealyzer Installation and Configuration Manual
    Pagealyzer Installation and Configuration Manual Andrés Sanoja, LIP6 / Université Pierre et Marie Curie Responsables WP : Matthieu CORD/UPMC Stéphane GANÇARSKI/UPMC This work was partially supported by the SCAPE Project. The SCAPE project is co-funded by the European Union under FP7 ICT-2009.4.1 (Grant Agreement number 270137). Enviroment Verification and Configuration The tools pageanalyzer.rb, change_detection.rb and capture.rb are written in Ruby 1.9.1. In the other hand for the change detection process others tools are used that are written in Java, therefore this should be taken into account in the enviroment verification process. The development enviroment was Linux Ubuntu 11.40, the package description is done following its repositories, but in theory should be compatible with debien repos. Ruby Installation We need to be carefull with this step because the software won't work on the 1.8.x versions of Ruby. sudo apt-get install ruby1.9.1-full After that we should check that both, ruby and rubygems, are been properly installed. $ ruby -v 1.9.2p290 (2011-07-09 revision 32533) [i686-linux] It is enough to match the version number. Any doubts there are several tutorials to do this [1]. Now we check the rubygems package manager: $ gem -v 1.3.7 Installing Dependencies After the language and the package manager are properly configured and installed, we may proceed to install the dependencies: sudo gem install --version '= 0.8.6' hpricot sudo apt-get install libxslt-dev libxml2-dev sudo gem install --version '= 1.5.5' nokogiri sudo gem install --version '= 2.0.3' sanitize sudo gem install --version '= 2.25.0' selenium-webdriver sudo apt-get install openjdk-6-jdk sudo apt-get install imagemagick Note1: Installing the selenium-webdriver can cause some warnings in text encoding that should be fine, in almost all the cases.
    [Show full text]