├── .gitignore ├── snippets.yml ├── images └── ruby-compendium │ ├── ruby.png │ └── ruby.svg ├── lib ├── layouts │ ├── bookindex.glyph │ ├── bookpage.glyph │ └── project.glyph └── tasks │ └── tasks.rake ├── text ├── resources.glyph ├── notes.glyph ├── podcasts.glyph ├── language.glyph ├── ten-good-things.glyph ├── core-stdlib.glyph ├── intro.glyph ├── gems.glyph ├── features.glyph ├── books.glyph ├── web-sites.glyph ├── syntax.glyph ├── implementations.glyph ├── rubyists.glyph └── gem-tips.glyph ├── config.yml ├── README.textile ├── document.glyph └── styles ├── coderay.css ├── default.css └── pagination.css /.gitignore: -------------------------------------------------------------------------------- 1 | output/* 2 | -------------------------------------------------------------------------------- /snippets.yml: -------------------------------------------------------------------------------- 1 | --- 2 | :test: |- 3 | This is a 4 | Test snippet 5 | -------------------------------------------------------------------------------- /images/ruby-compendium/ruby.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h3rald/ruby-compendium/master/images/ruby-compendium/ruby.png -------------------------------------------------------------------------------- /lib/layouts/bookindex.glyph: -------------------------------------------------------------------------------- 1 | ----- 2 | permalink: index 3 | title: Ruby Compendium 4 | type: page 5 | ----- 6 | toc[] 7 | -------------------------------------------------------------------------------- /lib/layouts/bookpage.glyph: -------------------------------------------------------------------------------- 1 | ----- 2 | permalink: {{id}} 3 | title: Ruby Compendium – {{title}} 4 | type: page 5 | ----- 6 | navigation[{{id}}] 7 | {{contents}} 8 | navigation[{{id}}] 9 | -------------------------------------------------------------------------------- /text/resources.glyph: -------------------------------------------------------------------------------- 1 | textile[ 2 | There are a lot of resources out there to help you get started or stay up-to-date with Ruby. The Ruby community is active and supportive, as long as you ask nicely. 3 | 4 | The following section contains a small set of hand-picked web sites, books and podcasts which you should definitely have a look at. For even more community resources, check out the =>[http://www.ruby-lang.org/en/community/|Community Page] on the Official Ruby Web Site. 5 | ] 6 | def:[res| 7 | txt[ 8 | *\/=>[{{url}}|{{name}}]* – {{desc}} 9 | ] 10 | ] 11 | -------------------------------------------------------------------------------- /config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | :document: 3 | :source: document.glyph 4 | :author: Fabio Cevasco 5 | :title: Ruby Compendium 6 | :subtitle: An Essential Guide to the Ruby Ecosystem 7 | :filename: ruby-compendium 8 | :revision: Rev. 0.2.0 9 | :draft: false 10 | :output: pdf 11 | :styles: embed 12 | :output: 13 | :h3rald: 14 | :multifile: true 15 | :extension: .html 16 | :filter_target: html 17 | :base: /ruby-compendium/book/ 18 | :macro_reps: html5 19 | :layout_dir: web5 20 | :layouts: 21 | :topic: bookpage 22 | :index: bookindex 23 | :pdf: 24 | :generator: prince 25 | -------------------------------------------------------------------------------- /README.textile: -------------------------------------------------------------------------------- 1 | This book was written to help newcomers to learn about the Ruby programming language. It doesn't focus on learning the language, but rather on its vast ecosystem and freely available resources. 2 | 3 | h3. License 4 | 5 | This book was written by Fabio Cevasco and it is licensed under a "Creative Commons Attribution-ShareAlike 3.0 Unported License":http://creativecommons.org/licenses/by-sa/3.0/. 6 | 7 | h3. Contributing 8 | 9 | This book was authored using "Glyph":http://www.h3rald.com/glyph and its source code is hosted on "Github":http://github.com/h3rald/ruby-compendium. Contributions are very welcome! Feel free to contact the author and/or fork the repository. 10 | -------------------------------------------------------------------------------- /lib/layouts/project.glyph: -------------------------------------------------------------------------------- 1 | ----- 2 | permalink: ruby-compendium 3 | filters_pre: 4 | - erb 5 | title: "Project: Ruby Compendium" 6 | subtitle: "An Essential Guide to the Ruby Ecosystem" 7 | type: project 8 | github: ruby-compendium 9 | links: 10 | - "Download": https://github.com/h3rald/ruby-compendium/downloads 11 | - "Read Online": /ruby-compendium/book 12 | - "Source": https://github.com/h3rald/ruby-compendium 13 | - "Tracking": http://github.com/h3rald/ruby-compendium/issues 14 | status: On Hold 15 | version: 0.2.0 16 | ----- 17 | 18 | <%= render 'project_data', :tag => 'ruby-compendium' %> 19 | 20 | {{contents}} 21 | 22 | <%= render 'project_updates', :tag => 'ruby-compendium' %> 23 | -------------------------------------------------------------------------------- /text/notes.glyph: -------------------------------------------------------------------------------- 1 | textile[ 2 | This book was written by Fabio Cevasco and it is licensed under a =>[http://creativecommons.org/licenses/by-sa/3.0/|Creative Commons Attribution-ShareAlike 3.0 Unported License]. 3 | 4 | This book was authored using =>[http://www.h3rald.com/glyph|Glyph] and the PDF version was produced with =>[http://www.princexml.org|Prince XML]. 5 | 6 | The Ruby logo is copyright (c) 2006, Yukihiro Matsumoto, and used under the terms of the =>[http://creativecommons.org/licenses/by-sa/2.5/|Creative Commons Attribution-ShareAlike 2.5 License]. 7 | 8 | Special thanks to the following individuals who contributed to the project, in some ways: 9 | * "Akira Matsuda":http://blog.dio.jp/ 10 | * "Sven Schwyn":http://www.bitcetera.com/ 11 | ] 12 | -------------------------------------------------------------------------------- /text/podcasts.glyph: -------------------------------------------------------------------------------- 1 | res[ 2 | @url[http://5by5.tv/rubyshow] 3 | @name[The Ruby Show] 4 | @desc[_The_ Ruby podcast, with =>[#danbenjamin|Dan Benjamin] and =>[#jseifer|Jason Seifer].] 5 | ] 6 | res[ 7 | @url[http://ruby5.envylabs.com/] 8 | @name[Ruby5] 9 | @desc[Frequently-released short podcasts on what's new in the Ruby and Rails community. By =>[#greggpollack|Gregg Pollack].] 10 | ] 11 | res[ 12 | @url[http://rubyonrails.org/screencasts] 13 | @name[Ruby On Rails Screencasts] 14 | @desc[Free Ruby on Rails screencasts] 15 | ] 16 | res[ 17 | @url[http://sdruby.org/podcast] 18 | @name[SD Ruby Podcast] 19 | @desc[Ruby podcasts by the San Diego Ruby community.] 20 | ] 21 | res[ 22 | @url[http://www.rubypulse.com/] 23 | @name[Ruby Pulse] 24 | @desc[Free Ruby-related podcasts.] 25 | ] 26 | res[ 27 | @url[http://ruby-kickstart.com/] 28 | @name[Ruby Kickstart] 29 | @desc[Hours of free screencast to teach you how to program in Ruby, with loads of free material, quizzes, and goodies.] 30 | ] 31 | -------------------------------------------------------------------------------- /text/language.glyph: -------------------------------------------------------------------------------- 1 | txt[ 2 | Ruby is a relatively new programming language. It was created by =>[#matz|Yukihiro Matzumoto] (aka "Matz") in 1995, but it took another ten years to become popular outside Japan, thanks to the _Ruby on Rails_ web framework. 3 | ] 4 | box[Isn't Ruby em[slow?]| 5 | txt[ 6 | Being a high-level, interpreted language, Ruby is slower than compiled languages like C or C++ or even other interpreted languages like Perl 5. However, this may vary depending on the implementation. 7 | * If you are interested in Ruby benchmarks, check out Antonio Cangiano's =>[http://programmingzen.com/2010/07/19/the-great-ruby-shootout-july-2010/|Great Ruby Shootout], which also includes data on =>[http://www.rubyenterpriseedition.com/|Ruby Enterprise Edition] and =>[http://ruby.gemstone.com/|MagLev] implementations. 8 | * If you are interested in benchmarks between Ruby implementations and other languages, the =>[http://shootout.alioth.debian.org/|Computer Language Benchmark Game] is a good place to start. 9 | ] 10 | ] 11 | -------------------------------------------------------------------------------- /lib/tasks/tasks.rake: -------------------------------------------------------------------------------- 1 | namespace :generate do 2 | desc "Create output for h3rald.com integration" 3 | task :h3rald => [:web5] do 4 | dir = Glyph::PROJECT/'output/h3rald' 5 | (dir/"ruby-compendium/book").mkpath 6 | # Copy files in subdir 7 | (dir).find do |i| 8 | if i.file? then 9 | next if i.to_s.match(Regexp.escape(dir/'ruby-compendium')) 10 | dest = dir/"ruby-compendium/book/#{i.relative_path_from(Glyph::PROJECT/dir)}" 11 | src = i.to_s 12 | Pathname.new(dest).parent.mkpath 13 | file_copy src, dest 14 | end 15 | end 16 | # Remove files from output dir 17 | dir.children.each do |c| 18 | unless c == dir/'ruby-compendium' then 19 | c.directory? ? c.rmtree : c.unlink 20 | end 21 | end 22 | (dir/'ruby-compendium/book/images/').rmtree 23 | # Create project page 24 | project = Glyph.filter %{layout/project[ 25 | @contents[#{file_load(Glyph::PROJECT/'text/notes.glyph')}] 26 | ]} 27 | file_write dir/"ruby-compendium.erb", project 28 | 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /text/ten-good-things.glyph: -------------------------------------------------------------------------------- 1 | txt[ 2 | # It's free and open source. 3 | # It's high-level, no need to worry about memory allocation or similar. 4 | # It's fully cross platform, or at least most of its =>[#implementations|implementations] are. 5 | # It's elegant. Really, Ruby =>[#syntax|syntax] is truly beautiful, with no semicolons or braces, generally. 6 | # It has a large =>[#core-stdlib|core and Standard Library]. 7 | # It has over 1300 user-contributed =>[#gems|libraries] for almost anything you can think of. 8 | # It is multi-paradigm and offers many advanced language =>[#features|features]. 9 | # It has a friendly and supportive community and plenty of useful =>[#resources|resources]. 10 | # There are loads of =>[#websites|web sites] about it and free online learning material. 11 | # A lot of =>[#books|books] have been written about it. 12 | ] 13 | box[If you want to know more...| 14 | For general information on Ruby and more introductory material, head over to the =>[http://www.ruby-lang.org/|Official Ruby Web Site], in particular to the =>[http://www.ruby-lang.org/en/documentation/ruby-from-other-languages/|Ruby from Other Languages] articles, if you are already familiar with C, C++, Java, PHP, Perl, or Python. 15 | ] 16 | -------------------------------------------------------------------------------- /text/core-stdlib.glyph: -------------------------------------------------------------------------------- 1 | textile[ 2 | By default, Ruby always loads its core classes and modules when a script is executed. This means that in all Ruby programs you can always instantiate core objects like: 3 | * Numbers (integers, floats) 4 | * Strings 5 | * Arrays 6 | * Hashes 7 | * Files 8 | * Regular expressions 9 | * Symbols 10 | * Threads 11 | * Times and dates 12 | * ...and many more. 13 | 14 | Most likely, this is not going to be enough. That's when the Standard Library comes into play: it's a large collection of internal libraries that ships with every Ruby implementations. There are libraries to connect to the Internet, to read/write to various file formats such as CSV or YAML, to work with files and paths, access system features, and so on. 15 | 16 | Unlike core classes, standard libraries must be required specifically if needed, before they can be used. 17 | ] 18 | box[If you want to know more...| 19 | textile[ 20 | On core libraries and the Standard Library, checkout the official documentation: 21 | * =>[http://www.ruby-doc.org/core/|Core Reference] 22 | * =>[http://www.ruby-doc.org/stdlib/|Standard Library Reference] 23 | 24 | Overwhelmed? Don't know where to start? Familiarize yourself with the =>[http://www.ruby-doc.org/core/classes/Enumerable.html|Enumerable] module; you won't regret it! 25 | ] 26 | ] 27 | -------------------------------------------------------------------------------- /text/intro.glyph: -------------------------------------------------------------------------------- 1 | textile[ 2 | ...or maybe not. Maybe you're _thinking_ about it, but you're not entirely convinced it's a good idea. Maybe you have an annoying co-worker who constantly raves about it and made you curious. Whatever the case, this tiny book is about telling you all you need to know about the language before you actually start getting your hands dirty. 3 | 4 | There are many different ways to learn new programming languages. Typically, you'd start reading tutorials online, try a few example programs, maybe buy a book and start reading it. That's what most people do nowadays, and it works, in the end. The downside of this is that you may spend weeks or even months trying to get the hang of the language, spend a lot of time trying to find information about it, ask dumb questions in forums and mailing lists, re-invent the wheel only to find out —months later— that someone already made a library which does exactly the same thing as yours, but in a much better way. 5 | 6 | You can learn through mistakes, but there's no harm in starting with the right foot. 7 | 8 | This _Ruby Compendium_ gives you an overview of the Ruby Ecosystem from 10,000ft. It briefly describes the language, its libraries, and what resources you can find online. By the time you finish reading this, you will _not_ know how to write Ruby programs (yet) but you'll definitely know _how to learn_ this amazing and powerful language and where to look for information and help. 9 | 10 | Close your editor now, relax, and enjoy! 11 | ] 12 | -------------------------------------------------------------------------------- /text/gems.glyph: -------------------------------------------------------------------------------- 1 | textile[ 2 | Sure, the =>[#core-stdlib|Standard Library] is quite large but... no, it does not have everything you need. Luckily, it's full of gems out there! Rubygems is Ruby's packaging system, and the best way to distribute your own libraries and applications. 3 | 4 | The Rubygems packaging system is now included in most Ruby implementation and distributions. Installing a gem and all its dependencies is as easy as issuing @gem install @. So for example if you want to install the =>[https://rubygems.org/gems/rails|rails] gem, you can just run 5 | 6 | @gem install rails@ 7 | 8 | ...and it will be automatically downloaded and installed on your system, along with the other gems it depends on. 9 | ] 10 | section[ 11 | @title[RubyGems.org] 12 | There are over 1300 different gems publicly (and freely!) available. Luckily, the official gem host site, =>[http://www.rubygems.org|RubyGems.org] makes it very easy to find what you're looking for: just search for a particular gem or a functionality you're looking for, and browse through the results. You can also register and em[push] your own gems for other people to use. 13 | ] 14 | box[What happened to RubyForge?| 15 | textile[ 16 | If you started to learn Ruby a few years ago, the =>[http://www.rubyforge.org|RubyForge] was _the_ place to find user-created ruby code and gems. The site is still there, but nowadays Rubyists prefer using =>[http://www.github.com|GitHub] as host for their source code repositories and RubyGems.org as the home for their gems. 17 | ] 18 | ] 19 | -------------------------------------------------------------------------------- /text/features.glyph: -------------------------------------------------------------------------------- 1 | textile[ 2 | One of the best things about Ruby is that you're not stuck with a single programming paradigm. Even though everything in Ruby is an object (thereby making it a fully object-oriented language), nothing forbids you to program procedurally, or even use typical functional constructs. 3 | 4 | The beauty of this is that you can (and should) combine elements from different paradigms, resulting in very powerful and expressive code. What I really like about Ruby though is its inherent dynamic nature. 5 | 6 | You have a very few constraints when coding: 7 | * you can open and close class definitions at will, 8 | * you are not constrained by object types 9 | * you can mix-in methods in multiple classes at the same time 10 | * you can write code that _writes itself_ dynamically (this is commonly called _metaprogramming_) 11 | * you can easily create Domain-Specific Language to solve problems faster, with style 12 | * you can create and pass around blocks of code 13 | 14 | All these things make the language very flexible and powerful. Do not overuse Ruby's power: if your code starts to look like black magic, you're probably going too far. 15 | ] 16 | box[If you want to know more...| 17 | textile[ 18 | ...on specific and advanced Ruby features, check out these articles: 19 | * =>[http://olabini.com/blog/2006/09/ruby-metaprogramming-techniques/|Ruby Metaprogramming techniques] 20 | * =>[http://www.skorks.com/2010/05/ruby-procs-and-lambdas-and-the-difference-between-them/|Ruby Procs And Lambdas (And The Difference Between Them)] 21 | * =>[http://juixe.com/techknow/index.php/2006/06/15/mixins-in-ruby/|Ruby Mixin Tutorial] 22 | * =>[http://www.valibuk.net/2009/03/domain-specific-languages-in-ruby/|Domain Specific Languages in Ruby] 23 | ] 24 | ] 25 | 26 | 27 | -------------------------------------------------------------------------------- /text/books.glyph: -------------------------------------------------------------------------------- 1 | res[ 2 | @url[http://www.humblelittlerubybook.com/book/] 3 | @name[The Humble Little Ruby Book] 4 | @desc[A nicely-written free book on Ruby, by =>[#jm|Jeremy McAnally]] 5 | ] 6 | res[ 7 | @url[http://www.sapphiresteel.com/The-Little-Book-Of-Ruby] 8 | @name[The Little Book of Ruby] 9 | @desc[An 87-page free introduction covering Ruby basics.] 10 | ] 11 | res[ 12 | @url[http://www.sapphiresteel.com/Blog/The-Book-Of-Ruby-free-in-depth] 13 | @name[The Book of Ruby] 14 | @desc[A 400-page free Ruby bible by Huw Collingbourne.] 15 | ] 16 | res[ 17 | @url[http://ruby-doc.org/docs/ProgrammingRuby/] 18 | @name[Programming Ruby] 19 | @desc[The first edition of the so-called _Pickaxe_ book, available for free, by =>[#davethomas|Dave Thomas], =>[#chad|Chad Fowler] and =>[#andyhunt|Andy Hunt]] 20 | ] 21 | res[ 22 | @url[http://mislav.uniqpath.com/poignant-guide/] 23 | @name[Why's (poignant) guide to Ruby] 24 | @desc[The legendary book by =>[#_why|why the lucky stiff]. With foxes, little elves, and... chunky bacon!). Exquisitely weird and witty.] 25 | ] 26 | res[ 27 | @url[http://ruby.runpaint.org/] 28 | @name[Read Ruby 1.9] 29 | @desc[em["Very early draft of a book about version 1.9 of the Ruby programming language, released under a Creative Commons license."]] 30 | ] 31 | res[ 32 | @url[http://ruby.learncodethehardway.org/] 33 | @name[Learn Ruby The Hard Way] 34 | @desc[A Ruby translation of the popular book em[Learn Python The Hard Way], by Zed Shaw.] 35 | ] 36 | box[What about em[real] books?| 37 | textile[ 38 | All the books mentioned so far are free, but there's plenty of published books on Ruby. Check out the following titles: 39 | * =>[http://www.informit.com/imprint/series_detail.aspx?ser=2124042|Addison-Wesley Progessional Ruby Series] 40 | * =>[http://oreilly.com/pub/topic/ruby|Ruby books by O'Reilly] 41 | * =>[http://pragprog.com/categories/ruby_and_rails|Ruby books by Pragmatic Programmers] 42 | ] 43 | ] 44 | -------------------------------------------------------------------------------- /document.glyph: -------------------------------------------------------------------------------- 1 | book[ 2 | @head[ 3 | style[default.css] 4 | ?[output?[pdf]|style[pagination.css]] 5 | ?[eq[$[filters.highlighter]|coderay]|style[coderay.css]] 6 | ?[eq[$[filters.highlighter]|ultraviolet]|style[ultraviolet/lazy.css]] 7 | ] 8 | @pre-title[ 9 | ?[output?[pdf]| 10 | image[ruby-compendium/ruby.svg 11 | @width[15%] 12 | @height[15%] 13 | ] 14 | ] 15 | ] 16 | @frontmatter[ 17 | toc[] 18 | introduction[ 19 | @title[So you want to learn Ruby...] 20 | @src[intro] 21 | section[ 22 | @title[About this Book] 23 | @src[notes] 24 | ] 25 | ] 26 | ] 27 | @bodymatter[ 28 | chapter[ 29 | @title[Quick Tour] 30 | @src[language] 31 | section[ 32 | @title[10 Good Things about Ruby] 33 | @id[ten-good-things] 34 | @src[ten-good-things] 35 | ] 36 | section[ 37 | @title[Versions and Implementations] 38 | @id[implementations] 39 | @src[implementations] 40 | ] 41 | section[ 42 | @title[Syntax] 43 | @id[syntax] 44 | @src[syntax] 45 | ] 46 | section[ 47 | @title[The Core and the Standard Library] 48 | @id[core-stdlib] 49 | @src[core-stdlib] 50 | ] 51 | section[ 52 | @title[Advanced Language Features] 53 | @id[features] 54 | @src[features] 55 | ] 56 | ] 57 | chapter[ 58 | @title[Ruby Gems] 59 | @id[gems] 60 | @src[gems] 61 | section[ 62 | @title[What you can use for...] 63 | @src[gem-tips] 64 | ] 65 | ] 66 | chapter[ 67 | @title[Resources] 68 | @id[resources] 69 | @src[resources] 70 | section[ 71 | @title[Web Sites] 72 | @id[websites] 73 | @src[web-sites] 74 | ] 75 | section[ 76 | @title[Books] 77 | @id[books] 78 | @src[books] 79 | ] 80 | section[ 81 | @title[Podcasts and Screencasts] 82 | @id[podcasts] 83 | @src[podcasts] 84 | ] 85 | ] 86 | ] 87 | @backmatter[ 88 | appendix[ 89 | @title[Notable Rubyists] 90 | @src[rubyists] 91 | ] 92 | ] 93 | ] 94 | -------------------------------------------------------------------------------- /text/web-sites.glyph: -------------------------------------------------------------------------------- 1 | res[ 2 | @url[http://www.ruby-lang.org/] 3 | @name[Ruby-Lang.org] 4 | @desc[The official Ruby web site, completely maintained by members of the Ruby community and available in several languages.] 5 | ] 6 | res[ 7 | @url[https://rubygems.org/] 8 | @name[RubyGems.org] 9 | @desc[The home of all Ruby gems.] 10 | ] 11 | res[ 12 | @url[http://rubykoans.com/] 13 | @name[Ruby Koans] 14 | @desc[Learn Ruby (and testing) through Koans. Probably the coolest way to learn Ruby right now.] 15 | ] 16 | res[ 17 | @url[http://rubylearning.com/] 18 | @name[Ruby Learning] 19 | @desc[Ruby guru =>[#satish|Satish Talim]'s web site about learning the Ruby language. It contains tutorials, study notes, and even =>[http://rubylearning.org/class/|online classes].] 20 | ] 21 | res[ 22 | @url[http://rubycorner.com/] 23 | @name[Ruby Corner] 24 | @desc[The most comprehensive Ruby blog aggregator.] 25 | ] 26 | res[ 27 | @url[http://www.rubyinside.com/] 28 | @name[Ruby Inside] 29 | @desc[_The_ Ruby blog, by =>[#peterc|Peter Cooper].] 30 | ] 31 | res[ 32 | @url[http://www.ruby-forum.com/] 33 | @name[Ruby Forum] 34 | @desc[A mirror of the most important Ruby-related mailing lists.] 35 | ] 36 | res[ 37 | @url[http://rubydoc.info/] 38 | @name[RubyDoc.info] 39 | @desc[Your one-stop resource for reference documentation. Everything from Ruby core, Standard Library, gems, and even Github-hosted Ruby projects.] 40 | ] 41 | res[ 42 | @url[http://www.rubyflow.com/] 43 | @name[RubyFlow] 44 | @desc[Community-powered link blog. Created by =>[#peterc|Peter Cooper]] 45 | ] 46 | res[ 47 | @url[http://ruby-toolbox.com/] 48 | @name[The Ruby Toolbox] 49 | @desc[A collection of ruby resources and libraries, organized by category and popularity.] 50 | ] 51 | res[ 52 | @url[http://rubycommitters.org/] 53 | @name[RubyCommitters.org] 54 | @desc[List of all the Ruby core committers. Created by =>[#tenderlove|Aaron Petterson].] 55 | ] 56 | res[ 57 | @url[http://rubylang.info/] 58 | @name[RubyLang.info] 59 | @desc[em["RubyLang.info is a community driven web site, dedicated to helping both new and experienced Ruby developers."]] 60 | ] 61 | 62 | -------------------------------------------------------------------------------- /text/syntax.glyph: -------------------------------------------------------------------------------- 1 | p[ 2 | Teaching you how to program in Ruby goes beyond the scope of this book, however, this section will show you at least what Ruby code looks like. If you know another programming language already, some things may already be familiar to you. If you don't, hopefully the following code will not appear too intimidating. 3 | ] 4 | highlight[=ruby| 5 | # This is a comment and will not be executed 6 | # by the Ruby interpreter. 7 | # 8 | # This is not the usual 'Hello World' example, so 9 | # don't worry if you don't understand everything. 10 | # This example is meant to give you a general feeling 11 | # of what it is like to write Ruby programs. 12 | 13 | require 'pathname' # Here we're requiring an external library 14 | # which is part of the Ruby Standard Library. 15 | 16 | class FilePrinter 17 | 18 | # Constructor method 19 | def initialize(path) 20 | # This method expects a valid path, however Ruby is dynamically-typed 21 | # so anything can be passed to this method. 22 | # To check that the input value is valid, just check if if it behaves 23 | # like a path. This is called 'duck typing'. 24 | raise RuntimeError, "Invalid path: #{path}" unless path.respond_to? :basename 25 | @path = path 26 | @name = @path.basename 27 | end 28 | 29 | def show 30 | # Ruby objects and expressions can be interpolated in strings 31 | puts " #@name -- #{@path.stat.size} bytes" 32 | end 33 | 34 | end 35 | 36 | class DirPrinter < FilePrinter # Definition of a child class 37 | 38 | def initialize(path) 39 | super # Call to the parent's constructur 40 | @children = @path.children 41 | end 42 | 43 | def show 44 | puts " #@name/ -- #{@children.length} item(s)" 45 | end 46 | 47 | end 48 | 49 | # No parenthesis are required unless needed! 50 | pwd = Pathname.new Dir.pwd 51 | 52 | puts "Current Directory: #{pwd}" 53 | 54 | # Get the children items of the current directory, 55 | # select only directories, 56 | # sort them alphabetically, 57 | # and for each one of them... 58 | pwd.children.select{\|i\| i.directory? }.sort.each do \|item\| 59 | # Call the show method, printing the 60 | # directory name and the number of child items 61 | DirPrinter.new(item).show 62 | end 63 | 64 | pwd.children.select{\|i\| !i.directory? }.sort.each do \|item\| 65 | FilePrinter.new(item).show 66 | end 67 | =] 68 | box[Trying out Ruby...| 69 | If your hands are itching to try writing Ruby code, but you don't want to install it just yet, head over to =>[http://tryruby.org/|Try Ruby!], a unique way to try the language right in your browser. Or, if you already installed Ruby, follow the =>[http://www.ruby-lang.org/en/documentation/quickstart/|Ruby in 20 minutes] tutorial, using Interactive RuBy (IRB). 70 | ] 71 | -------------------------------------------------------------------------------- /text/implementations.glyph: -------------------------------------------------------------------------------- 1 | textile[ 2 | One thing that may appear unusual and even discouraging to newcomers is the different versions and implementations of the language. Ruby has two version branches: 3 | * *1.8* – The former stable version, which is still widely used in production and it is still updated. 4 | * *1.9* – As of release 1.9.2, this is considered the current stable and recommended version of the language. Although most third-party libraries work with it, some old and now unmaintained libraries may not. The good news is that there are normally newer and better libraries available instead. 5 | 6 | Different implementations of Ruby offer different degrees of support to one or the other version. Compared to 1.8, Ruby 1.9 has some additional syntax for certain expressions, improved character encoding support and a few new bundled libraries and features. 7 | 8 | If you're new to Ruby and you have no particular restrictions or needs, you should start learning Ruby using version 1.9 (either =>[#yarv|the official implementation], =>[#jruby|JRuby] or =>[#macruby|MacRuby])! 9 | ] 10 | box[If you want to know more...| 11 | txt[ 12 | There are many articles and presentations online outlining the changes in Ruby 1.9, for example: 13 | * =>[http://www.slideshare.net/komrade/piterrb-2-ruby-18-vs-ruby-19|Piter.rb #2 - Ruby 1.8 vs Ruby 1.9] 14 | * =>[http://eigenclass.org/hiki/Changes+in+Ruby+1.9|Changes in Ruby 1.9] 15 | * =>[http://slideshow.rubyforge.org/ruby19.html#1|Ruby 1.9: What to Expect] 16 | ] 17 | ] 18 | txt_section[ 19 | @title[Official Ruby 1.8 Implementation] 20 | @notoc[true] 21 | The official Ruby 1.8 implementation was written in C by Yukihiru Matsumoto, the creator of Ruby. 22 | * Current Version: *1.8.7-p352* 23 | * Download: =>[http://www.ruby-lang.org/en/downloads/|Official Ruby Web Site] 24 | ] 25 | txt_section[ 26 | @title[Official Ruby 1.9 Implementation] 27 | @id[yarv] 28 | @notoc[true] 29 | The official Ruby 1.9 implementation is based on a bytecode interpreter written Koichi Sasada. 30 | * Current Version: *1.9.2-p200* 31 | * Preview Version: *1.9.2-preview1* 32 | * Download: =>[http://www.ruby-lang.org/en/downloads/|Official Ruby Web Site] 33 | ] 34 | txt_section[ 35 | @title[JRuby] 36 | @id[jruby] 37 | @notoc[true] 38 | An implementation of the Ruby language running on the Java Virtual Machine, mature and usable in production. It offers real threading, performance improvements, and Java interoperability. Fully-compatible with both Ruby 1.8 and 1.9. 39 | * Current Version: *1.6.3* 40 | * Download: =>[http://jruby.org/|JRuby Web Site] 41 | ] 42 | txt_section[ 43 | @title[Rubinius] 44 | @notoc[true] 45 | A C++ and =>[http://llvm.org/|LLVM]-powered Ruby implementation. Although still not as mature as YARV or JRuby, it's getting there. It currently aims at being compatible with Ruby 1.8.7, although support for Ruby 1.9 is planned. 46 | * Current Version: *1.2.4* 47 | * Download: =>[http://rubini.us/|Rubinius Web Site] 48 | ] 49 | txt_section[ 50 | @title[MacRuby] 51 | @id[macruby] 52 | @notoc[true] 53 | A Mac-only Ruby implementation compatible with Ruby 1.9, specifically tuned for Mac OS X operating systems. 54 | * Current Version: *0.10* 55 | * Download: =>[http://www.macruby.org/|MacRuby Web Site] 56 | ] 57 | txt_section[ 58 | @title[IronRuby] 59 | @notoc[true] 60 | A .NET implementation of the Ruby Programming Language, compatible with Ruby 1.8.6 (IronRuby 1.0) and 1.9 (IronRuby 1.1.1 onwards). Not as mature as the other implementations. 61 | * Current Version: *1.1.3* 62 | * Download: =>[http://www.ironruby.net/|IronRuby Web Site] 63 | ] 64 | box[Try'em All!| 65 | txt[ 66 | Don't know which Ruby to choose? You don't have to! =>[#wayneeseguin] created =>[https://rvm.beginrescueend.com/|Ruby Version Manager] (RVM) to allow you to install, upgrade and manage several Ruby installation seamlessly on the same computer. If you're on OS X or Linux, that is. If you're on a Windows computer, =>[https://github.com/vertiginous/pik|Pik] provides something similar. 67 | ] 68 | ] 69 | -------------------------------------------------------------------------------- /text/rubyists.glyph: -------------------------------------------------------------------------------- 1 | def:[person| 2 | section[ 3 | span[ 4 | @style[padding-top: 20px;display: block;] 5 | #[{{id}}]strong[\/=>[{{url}}|{{name}}]] – =>[http://twitter.com/{{twitter}}|@{{twitter}}] 6 | ] 7 | div[ 8 | @style[margin-left: 30px;] 9 | {{desc}} 10 | ] 11 | ] 12 | ] 13 | person[ 14 | @name[Chad Fowler] 15 | @id[chad] 16 | @twitter[chadfowler] 17 | @url[http://chadfowler.com/] 18 | @desc[Pragmatic Programmer, published author, Ruby core committer.] 19 | ] 20 | person[ 21 | @name[Yukihiro Matsumoto] 22 | @id[matz] 23 | @twitter[yukihiro_matz] 24 | @url[http://www.rubyist.net/~matz/] 25 | @desc[The creator of the Ruby Programming Language.] 26 | ] 27 | person[ 28 | @name[Dave Thomas] 29 | @id[davethomas] 30 | @twitter[pragdave] 31 | @url[http://pragdave.pragprog.com/] 32 | @desc[Pragmatic Programmer, published author, Ruby core committer.] 33 | ] 34 | person[ 35 | @name[David Heinemeier Hansson] 36 | @id[dhh] 37 | @twitter[dhh] 38 | @url[http://www.loudthinking.com/] 39 | @desc[Creator of the Ruby on Rails framework.] 40 | ] 41 | person[ 42 | @name[why the lucky stiff] 43 | @id[_why] 44 | @twitter[_why] 45 | @url[http://viewsourcecode.org/why/] 46 | @desc[Semi-legendary, prolific Ruby developer, core committer, blogger, book author. Mysteriously disappeared in August 2009.] 47 | ] 48 | person[ 49 | @name[Yehuda Katz] 50 | @id[wycatz] 51 | @twitter[wycatz] 52 | @url[http://www.yehudakatz.com/] 53 | @desc[Rails core committer, lead developer of the Merb project.] 54 | ] 55 | person[ 56 | @name[Jeremy McAnally] 57 | @id[jm] 58 | @twitter[jm] 59 | @url[http://www.jeremymcanally.com/] 60 | @desc[Published author, blogger. Known for the Little Humble Ruby Book.] 61 | ] 62 | person[ 63 | @name[Obie Fernandez] 64 | @id[obie] 65 | @twitter[obie] 66 | @url[http://obiefernandez.com/] 67 | @desc[Published author, editor of Addison-Wesley's Professional Ruby Series, enterpreneur.] 68 | ] 69 | person[ 70 | @name[Ola Bini] 71 | @id[olabini] 72 | @twitter[olabini] 73 | @url[http://olabini.com/blog] 74 | @desc[JRuby core committer, published author, blogger.] 75 | ] 76 | person[ 77 | @name[Peter Cooper] 78 | @id[peterc] 79 | @twitter[peterc] 80 | @url[http://peterc.org/] 81 | @desc[Published author, blogger, enterpreneaur. Creator of Ruby Inside.] 82 | ] 83 | person[ 84 | @name[Antonio Cangiano] 85 | @id[acangiano] 86 | @twitter[acangiano] 87 | @url[http://antoniocangiano.com/] 88 | @desc[Technical Evangelist, blogger, published author, and Ruby's unofficial benchmarker.] 89 | ] 90 | person[ 91 | @name[Andy Hunt] 92 | @id[andyhunt] 93 | @twitter[pragmaticandy] 94 | @url[http://blog.toolshed.com/] 95 | @desc[Pragmatic Programmer, published author.] 96 | ] 97 | person[ 98 | @name[Satish Talim] 99 | @id[satish] 100 | @twitter[indianguru] 101 | @url[http://satishtalim.com/] 102 | @desc[Creator of RubyLearning.com, one of the best resources for learning Ruby.] 103 | ] 104 | person[ 105 | @name[David A. Black] 106 | @id[dablack] 107 | @twitter[david_a_black] 108 | @url[http://dablog.rubypal.com/] 109 | @desc[Ruby core committer, published.] 110 | ] 111 | person[ 112 | @name[James Edward Gray II] 113 | @id[jeg2] 114 | @twitter[jeg2] 115 | @url[http://blog.grayproductions.net/] 116 | @desc[Ruby core committer, conference organizer, published author and blogger.] 117 | ] 118 | person[ 119 | @name[Luis Lavena] 120 | @id[luislavena] 121 | @twitter[luislavena] 122 | @url[http://blog.mmediasys.com/] 123 | @desc[Ruby core committer, maintainer of RubyInstaller for Windows.] 124 | ] 125 | person[ 126 | @name[Aaron Petterson] 127 | @id[tenderlove] 128 | @twitter[tenderlove] 129 | @url[http://tenderlovemaking.com/] 130 | @desc[Ruby core committer, blogger.] 131 | ] 132 | person[ 133 | @name[Gregg Pollack] 134 | @id[greggpollack] 135 | @twitter[greggpollack] 136 | @url[http://envylabs.com/] 137 | @desc[Founder of EnvyLabs, creator of many Ruby and Rails-related podcasts, including Ruby5.] 138 | ] 139 | person[ 140 | @name[Dan Benjamin] 141 | @id[danbenjamin] 142 | @twitter[danbenjamin] 143 | @url[http://danbenjamin.com/] 144 | @desc[Founder of 5by5 Studios, creator and host of The Ruby Show podcast.] 145 | ] 146 | person[ 147 | @name[Jason Seifer] 148 | @id[jseifer] 149 | @twitter[jseifer] 150 | @url[http://jasonseifer.com/] 151 | @desc[Co-host of The Ruby Show podcast.] 152 | ] 153 | person[ 154 | @name[Wayne E. Seguin] 155 | @id[wayneeseguin] 156 | @twitter[wayneeseguin] 157 | @url[http://beginrescueend.com/] 158 | @desc[Creator of Ruby Version Manager (RVM).] 159 | ] 160 | person[ 161 | @name[Steve Klabnik] 162 | @id[steveklabnik] 163 | @twitter[steveklabnik] 164 | @url[http://www.steveklabnik.com/] 165 | @desc[Maintainer of Hackety Hack, creator of rstat.us.] 166 | ] 167 | -------------------------------------------------------------------------------- /styles/coderay.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Based on: https://github.com/pie4dan/CodeRay-GitHub-Theme/blob/master/coderay.css 3 | */ 4 | .CodeRay { 5 | background-color: #FFF; 6 | border: 1px solid #CCC; 7 | line-height: 1.3em; 8 | font-size: 12px; 9 | font-family: Monospace; 10 | color: #000; 11 | padding: 1em 0px 1em 1em; 12 | } 13 | .CodeRay pre, .CodeRay code { 14 | padding: 0; 15 | margin: 0; 16 | } 17 | 18 | div.CodeRay { 19 | padding: 0; 20 | } 21 | 22 | span.CodeRay { white-space: pre; border: 0px; padding: 2px } 23 | 24 | table.CodeRay { border-collapse: collapse; width: 100%; padding: 2px } 25 | table.CodeRay td { 26 | padding: 1em 0.5em; 27 | vertical-align: top; 28 | } 29 | 30 | .CodeRay .line_numbers, .CodeRay .no { 31 | border: 1px solid #ECECEC; 32 | margin: 0 inherit; 33 | background-color: #ECECEC; 34 | color: #AAA; 35 | text-align: right; 36 | } 37 | .CodeRay .line_numbers tt { font-weight: bold } 38 | .CodeRay .line_numbers .highlighted { color: red } 39 | .CodeRay .line { display: block; float: left; width: 100%; } 40 | .CodeRay .no { padding: 0px 4px } 41 | .CodeRay .code { width: 100% } 42 | 43 | ol.CodeRay { font-size: 10pt } 44 | ol.CodeRay li { white-space: pre } 45 | 46 | .CodeRay .code pre { overflow: auto } 47 | 48 | .CodeRay .debug { color:white ! important; background:blue ! important; } 49 | 50 | .CodeRay .af { color:#00C } 51 | .CodeRay .an { color:#007 } 52 | .CodeRay .at { color:#f08 } 53 | .CodeRay .av { color:#700 } 54 | .CodeRay .aw { color:#C00 } 55 | .CodeRay .bi { color:#509; font-weight:bold } 56 | .CodeRay .c { color:#998; font-style: italic;} 57 | 58 | .CodeRay .ch { color:#04D } 59 | .CodeRay .ch .k { color:#04D } 60 | .CodeRay .ch .dl { color:#039 } 61 | 62 | .CodeRay .cl { color:#458; font-weight:bold } 63 | .CodeRay .cm { color:#A08; font-weight:bold } 64 | .CodeRay .co { color:teal; } 65 | .CodeRay .cr { color:#0A0 } 66 | .CodeRay .cv { color:#369 } 67 | .CodeRay .de { color:#B0B; } 68 | .CodeRay .df { color:#099; font-weight:bold } 69 | .CodeRay .di { color:#088; font-weight:bold } 70 | .CodeRay .dl { color:black } 71 | .CodeRay .do { color:#970 } 72 | .CodeRay .dt { color:#34b } 73 | .CodeRay .ds { color:#D42; font-weight:bold } 74 | .CodeRay .e { color:#666; font-weight:bold } 75 | .CodeRay .en { color:#800; font-weight:bold } 76 | .CodeRay .er { color:#F00; background-color:#FAA } 77 | .CodeRay .ex { color:#C00; font-weight:bold } 78 | .CodeRay .fl { color:#099; } 79 | .CodeRay .fu { color:#900; font-weight:bold } 80 | .CodeRay .gv { color:teal; font-weight:bold } 81 | .CodeRay .hx { color:#058; font-weight:bold } 82 | .CodeRay .i { color:#099; } 83 | .CodeRay .ic { color:#B44; font-weight:bold } 84 | 85 | .CodeRay .il { color: black } 86 | .CodeRay .il .il { background: #ccc } 87 | .CodeRay .il .il .il { background: #bbb } 88 | .CodeRay .il .idl { color: #D14; } 89 | .CodeRay .idl { color: #D14; } 90 | 91 | .CodeRay .im { color:#f00; } 92 | .CodeRay .in { color:#B2B; font-weight:bold } 93 | .CodeRay .iv { color:teal } 94 | .CodeRay .la { color:#970; font-weight:bold } 95 | .CodeRay .lv { color:#963 } 96 | .CodeRay .oc { color:#40E; font-weight:bold } 97 | .CodeRay .of { color:#000; font-weight:bold } 98 | .CodeRay .op { } 99 | .CodeRay .pc { font-weight:bold } 100 | .CodeRay .pd { color:#369; font-weight:bold } 101 | .CodeRay .pp { color:#579; } 102 | .CodeRay .ps { color:#00C; font-weight:bold } 103 | .CodeRay .pt { color:#074; font-weight:bold } 104 | .CodeRay .r, .kw { color:#000; font-weight:bold } 105 | 106 | .CodeRay .ke { color: #808; } 107 | .CodeRay .ke .dl { color: #606; } 108 | .CodeRay .ke .ch { color: #80f; } 109 | .CodeRay .vl { color: #088; } 110 | 111 | .CodeRay .rx { background-color:#fff0ff } 112 | .CodeRay .rx .k { color:#808 } 113 | .CodeRay .rx .dl { color:#404 } 114 | .CodeRay .rx .mod { color:#C2C } 115 | .CodeRay .rx .fu { color:#404; font-weight: bold } 116 | 117 | .CodeRay .s { color: #D20; } 118 | .CodeRay .s .s { } 119 | .CodeRay .s .s .s { background-color:#ffd0d0 } 120 | .CodeRay .s .k { color: #D14; } 121 | .CodeRay .s .ch { color: #D14; } 122 | .CodeRay .s .dl { color: #D14; } 123 | 124 | .CodeRay .sh { color:#D14 } 125 | .CodeRay .sh .k { } 126 | .CodeRay .sh .dl { color:#D14 } 127 | 128 | .CodeRay .sy { color:#990073 } 129 | .CodeRay .sy .k { color:#A60 } 130 | .CodeRay .sy .dl { color:#630 } 131 | 132 | .CodeRay .ta { color:#070 } 133 | .CodeRay .tf { color:#070; font-weight:bold } 134 | .CodeRay .ts { color:#D70; font-weight:bold } 135 | .CodeRay .ty { color:#339; font-weight:bold } 136 | .CodeRay .v { color:#036 } 137 | .CodeRay .xt { color:#444 } 138 | 139 | .CodeRay .ins { background: #afa; } 140 | .CodeRay .del { background: #faa; } 141 | .CodeRay .chg { color: #aaf; background: #007; } 142 | .CodeRay .head { color: #f8f; background: #505 } 143 | 144 | .CodeRay .ins .ins { color: #080; font-weight:bold } 145 | .CodeRay .del .del { color: #800; font-weight:bold } 146 | .CodeRay .chg .chg { color: #66f; } 147 | .CodeRay .head .head { color: #f4f; } 148 | -------------------------------------------------------------------------------- /styles/default.css: -------------------------------------------------------------------------------- 1 | * { 2 | font-family: inherit; 3 | border: none; 4 | font-size: 100%; 5 | font-style: inherit; 6 | margin: 0; 7 | padding: 0; } 8 | 9 | html { 10 | background: #fff; } 11 | 12 | ol, ul { 13 | margin: 0.3em 0; } 14 | 15 | p { 16 | margin: 1em 0; } 17 | 18 | table { 19 | border-collapse: collapse; 20 | border-spacing: 0; 21 | margin: auto; 22 | margin-top: 1em; } 23 | 24 | body { 25 | line-height: 1.2em; 26 | margin: 0; 27 | padding: 0; 28 | padding: 0 1em; 29 | text-align: justify; } 30 | 31 | /* Structure */ 32 | .halftitlepage { 33 | margin: auto; 34 | text-align: center; } 35 | 36 | .titlepage { 37 | margin: auto; 38 | text-align: center; } 39 | .titlepage h1 { 40 | font-size: 2.5em; 41 | line-height: 1.2em; 42 | font-weight: bold; 43 | margin-bottom: 0.2em; } 44 | 45 | .halftitlepage h1 { 46 | font-size: 2.5em; 47 | font-weight: bold; 48 | margin-bottom: 0.2em; } 49 | .halftitlepage h2 { 50 | font-size: 1.1em; 51 | font-style: italic; 52 | font-weight: bold; 53 | padding-top: 0; 54 | margin-top: 0; 55 | line-height: 2.5em; 56 | margin-bottom: 0.5em; 57 | prince-bookmark-level: none; } 58 | 59 | .titlepage h2 { 60 | font-size: 1.1em; 61 | font-style: italic; 62 | font-weight: bold; 63 | padding-top: 0; 64 | margin-top: 0; 65 | line-height: 2.5em; 66 | margin-bottom: 0.5em; 67 | prince-bookmark-level: none; } 68 | 69 | .author { 70 | font-size: 1em; } 71 | 72 | .pubdate { 73 | font-size: 0.8em; } 74 | 75 | li { 76 | list-style-type: square; 77 | margin: 0.4em 0; 78 | margin-left: 1.5em; } 79 | 80 | ol li { 81 | list-style-type: decimal; } 82 | 83 | .contents li { 84 | list-style-type: none; } 85 | 86 | img { 87 | margin: 0 5px; 88 | padding: 2px; } 89 | 90 | dt { 91 | font-weight: bold; 92 | margin-top: 1em; } 93 | 94 | dd { 95 | font-style: italic; } 96 | 97 | blockquote { 98 | margin: 1em 1em; 99 | font-style: italic; 100 | color: #121212; } 101 | 102 | table { 103 | border: 1px solid #e6e6e6; } 104 | 105 | th { 106 | background: #EEE; } 107 | 108 | tr, td, th { 109 | padding: 5px; } 110 | 111 | td, tr { 112 | border: 1px solid #e6e6e6; } 113 | 114 | sup { 115 | font-size: 0.7em; 116 | font-weight: bold; 117 | margin-left: -0.4em; } 118 | 119 | /* BLOCKS */ 120 | .center { 121 | margin: auto; 122 | text-align: center; } 123 | 124 | .left { 125 | margin: auto; 126 | text-align: left; } 127 | 128 | .right { 129 | margin: auto; 130 | text-align: center; } 131 | 132 | code { 133 | font-size: 0.8em; 134 | } 135 | 136 | .note, .important, .tip, .caution, .box { 137 | border: 1px solid #CCC; 138 | display: block; 139 | margin: 0.5em auto; 140 | padding: 1em; 141 | padding-top: 0em; 142 | width: 600px; 143 | background: #EEE; 144 | color: #1F1F1F; } 145 | 146 | .note > p, .important > p, .tip > p, .caution > p { 147 | margin: 0; 148 | padding: 0; } 149 | 150 | .note-title { 151 | font-weight: bold; 152 | margin-right: 1em; } 153 | 154 | .box-title { 155 | display: block; 156 | text-align: center; 157 | font-weight: bold; 158 | font-size: 120%; 159 | margin: 0.5em; 160 | } 161 | 162 | .comment { 163 | display: block; 164 | border: 1px solid #004D00; 165 | background: #7AFF7A; 166 | padding: 3px; 167 | margin: 1px; } 168 | .comment .comment-pre { 169 | color: #004D00; } 170 | 171 | .todo { 172 | display: block; 173 | border: 1px solid #990000; 174 | background: #FF9999; 175 | padding: 3px; 176 | margin: 1px; } 177 | .todo .todo-pre { 178 | color: #990000; } 179 | 180 | /* TEXT */ 181 | body { 182 | color: #000; 183 | font-size: 1em; } 184 | 185 | h2, section section h1, h1.toc-header { 186 | display: block; 187 | font-size: 2em; 188 | font-weight: bold; 189 | margin: 3em 0 1em 0; } 190 | 191 | h3, section section section h1 { 192 | font-size: 1.6em; 193 | font-weight: bold; 194 | margin: 3em 0 1em 0; } 195 | 196 | h4, section section section section h1 { 197 | font-size: 1.3em; 198 | font-weight: bold; 199 | margin: 3em 0 1em 0; } 200 | 201 | h5, section section section section section h1 { 202 | font-size: 1.2em; 203 | font-weight: bold; 204 | margin: 3em 0 1em 0; } 205 | 206 | em { 207 | font-style: italic; } 208 | 209 | a { 210 | color: #007bc4; 211 | text-decoration: none; } 212 | a:hover { 213 | color: #005b91; } 214 | 215 | span.line-numbers { 216 | margin: 0; 217 | padding: 3px; } 218 | 219 | nav, .navigation { 220 | display: block; 221 | margin: 1em auto; 222 | text-align: center; 223 | border: 1px solid #e6e6e6; } 224 | 225 | nav.contents { 226 | margin: auto; 227 | text-align: left; 228 | border: none; } 229 | nav a { 230 | margin: 1em; } 231 | 232 | .navigation a { 233 | margin: 1em; } 234 | 235 | nav.contents a { 236 | margin: 0; } 237 | 238 | mark { 239 | font-weight: bolder; 240 | font-style: italic; 241 | background: none; } 242 | 243 | td p, td ul, td ol { 244 | margin: 0; } 245 | 246 | .topic { 247 | margin: 2em auto; } 248 | 249 | /* FONTS */ 250 | body { 251 | font-family: 'Crimson Text', 'Palatino', 'Bookman', 'Georgia', 'Times'; } 252 | 253 | code, pre { 254 | font-family: "Droid Sans Mono", "Consolas", "Monaco", "Courier", "Monospace"; } 255 | -------------------------------------------------------------------------------- /styles/pagination.css: -------------------------------------------------------------------------------- 1 | @page { 2 | size: A4; 3 | margin: 40pt 30pt 40pt 30pt; 4 | @top { 5 | content: string(book-title) " - " string(chapter-title); 6 | font-style: italic; } 7 | 8 | @bottom { 9 | content: counter(page, decimal); } } 10 | 11 | @page frontmatter { 12 | @bottom { 13 | content: counter(page, lower-roman); } } 14 | 15 | @page backmatter { 16 | @bottom { 17 | content: counter(page, decimal); } } 18 | 19 | @page :first { 20 | padding-top: 10%; 21 | @top { 22 | content: normal; } 23 | 24 | @bottom { 25 | content: normal; } } 26 | 27 | ol.toc { 28 | margin-left: 1.5em; } 29 | 30 | .toc > li[class] { 31 | font-weight: bold; } 32 | .toc li { 33 | list-style-type: none; 34 | margin-left: 0; } 35 | .toc li a { 36 | color: #000; } 37 | .toc li a:hover { 38 | color: #000; } 39 | .toc li a::after { 40 | content: leader(".") target-counter(attr(href), page); } 41 | 42 | .titlepage h1, .halftitlepage h1 { 43 | string-set: book-title content(); } 44 | 45 | /* TOC Counters */ 46 | .toc > li[class~=chapter] { 47 | counter-increment: toc1; 48 | counter-reset: toc2; } 49 | .toc > li[class~=appendix] { 50 | counter-increment: appendix1; 51 | counter-reset: toc2; } 52 | .toc ol li[class] { 53 | counter-increment: toc2; 54 | counter-reset: toc3; } 55 | .toc ol ol li[class] { 56 | counter-increment: toc3; 57 | counter-reset: toc4; } 58 | .toc ol ol ol li[class] { 59 | counter-increment: toc4; 60 | counter-reset: toc5; } 61 | .toc ol ol ol ol li[class] { 62 | counter-increment: toc5; } 63 | .toc > li[class~=chapter]::before { 64 | content: counter(toc1) ". "; } 65 | .toc > li[class~=appendix]::before { 66 | content: counter(appendix1, upper-latin) ". "; } 67 | .toc > li[class] { 68 | margin: 1em 0; } 69 | .toc ol li[class]::before { 70 | margin-left: 1em; } 71 | .toc ol ol li[class]::before { 72 | margin-left: 2em; } 73 | .toc ol ol ol li[class]::before { 74 | margin-left: 3em; } 75 | .toc ol ol ol ol li[class]::before { 76 | margin-left: 4em; } 77 | .toc ol li[class~=frontmatter]::before { 78 | content: " "; } 79 | .toc ol li[class~=bodymatter]::before { 80 | content: counter(toc1) "." counter(toc2) " "; } 81 | .toc ol li[class~=appendix]::before { 82 | content: counter(appendix1, upper-latin) "." counter(toc2) " "; } 83 | .toc ol ol li[class~=bodymatter]::before { 84 | content: counter(toc1) "." counter(toc2) "." counter(toc3) " "; } 85 | .toc ol ol li[class~=appendix]::before { 86 | content: counter(appendix1, upper-latin) "." counter(toc2) "." counter(toc3) " "; } 87 | .toc ol ol ol li[class~=bodymatter]::before { 88 | content: counter(toc1) "." counter(toc2) "." counter(toc3) "." counter(toc4) " "; } 89 | .toc ol ol ol li[class~=appendix]::before { 90 | content: counter(appendix1, upper-latin) "." counter(toc2) "." counter(toc3) "." counter(toc4) " "; } 91 | .toc ol ol ol ol li[class~=bodymatter]::before { 92 | content: counter(toc1) "." counter(toc2) "." counter(toc3) "." counter(toc4) "." counter(toc5) " "; } 93 | .toc ol ol ol ol li[class~=appendix]::before { 94 | content: counter(appendix1, upper-latin) "." counter(toc2) "." counter(toc3) "." counter(toc4) "." counter(toc5) " "; } 95 | 96 | h2, section h1 { 97 | padding-top: 2em; 98 | string-set: chapter-title content(); 99 | page-break-before: always; } 100 | 101 | .halftitlepage h2, .titlepage h2 { 102 | page-break-before: avoid; } 103 | 104 | .bodymatter .chapter h2, .bodymatter .chapter h1 { 105 | counter-increment: h2; 106 | counter-reset: h3; } 107 | 108 | .backmatter h2, .backmatter h1 { 109 | counter-increment: a2; 110 | counter-reset: h3; } 111 | 112 | .bodymatter h3, .backmatter h3, .bodymatter section h1, .backmatter section h1 { 113 | counter-increment: h3; 114 | counter-reset: h4; } 115 | 116 | .bodymatter h4, .backmatter h4, .bodymatter section section h1, .backmatter section section h1 { 117 | counter-increment: h4; 118 | counter-reset: h5; } 119 | 120 | .bodymatter h5, .backmatter h5, .bodymatter section section section h1, .backmatter section section section h1 { 121 | counter-increment: h5; } 122 | 123 | h1, h2, h3, h4, h5 { 124 | page-break-after: avoid; } 125 | 126 | div.frontmatter { 127 | page: frontmatter; } 128 | div.backmatter { 129 | page: backmatter; } 130 | 131 | .bodymatter h2::before, .bodymatter h1:before { 132 | content: "Chapter " counter(h2, upper-roman) ": "; 133 | counter-reset: footnote; } 134 | 135 | .backmatter h2::before { 136 | content: "Appendix " counter(a2, upper-latin) ": "; } 137 | 138 | .bodymatter section h1:before { 139 | content: "Appendix " counter(a2, upper-latin) ": "; } 140 | .bodymatter h3::before, .bodymatter section h1:before { 141 | content: counter(h2) "." counter(h3) " "; } 142 | 143 | .backmatter h3::before { 144 | content: counter(a2, upper-latin) "." counter(h3) " "; } 145 | 146 | .bodymatter section section h1:before { 147 | content: counter(a2, upper-latin) "." counter(h3) " "; } 148 | .bodymatter h4::before, .bodymatter section section h1:before { 149 | content: counter(h2) "." counter(h3) "." counter(h4) " "; } 150 | 151 | .backmatter h4::before { 152 | content: counter(a2, upper-latin) "." counter(h3) "." counter(h4) " "; } 153 | 154 | .bodymatter section section section h2:before { 155 | content: counter(a2, upper-latin) "." counter(h3) "." counter(h4) " "; } 156 | .bodymatter h5::before, .bodymatter section section section section h2:before { 157 | content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) " "; } 158 | 159 | .backmatter h5::before, .bodymatter section section section section h2:before { 160 | content: counter(a2, upper-latin) "." counter(h3) "." counter(h4) "." counter(h5) " "; } 161 | 162 | .box, .note, .important, .tip, .caution, .code { 163 | page-break-inside: avoid; } 164 | 165 | /* Footnotes */ 166 | @page { 167 | @footnotes { 168 | border-top: 1px solid #000; } } 169 | 170 | .fn { 171 | font-size: 85%; 172 | margin-left: 1.5em; 173 | display: prince-footnote; 174 | counter-increment: footnote; } 175 | .fn:footnote-call { 176 | content: counter(footnote); 177 | font-size: 85%; 178 | vertical-align: super; 179 | line-height: none; 180 | font-weight: bold; 181 | margin-left: 1pt; } 182 | .fn:footnote-marker { 183 | font-weight: bold; 184 | margin-right: 0.5em; } 185 | -------------------------------------------------------------------------------- /text/gem-tips.glyph: -------------------------------------------------------------------------------- 1 | textile[ 2 | You could spend hours on the RubyGems web site to find what you're looking for sometimes. Not because you can't find it, but because often there are too many alternative libraries that overlap in terms of functionalities offered. 3 | 4 | A site to check when you don't know much of what has been done in a particular domain is =>[http://ruby-toolbox.com/|The Ruby Toolbox], which organizes quite a lot of gems into =>[http://ruby-toolbox.com/categories.html|categories]. This section is somewhat similar, but it focuses on just a few common tasks and a small set of hand-picked gems. 5 | 6 | ] 7 | def:[gem| 8 | textile[ 9 | *{{name}}* blockquote["{{desc}}"] 10 | * Web Page: =>[{{url}}] 11 | * Download: =>[http://www.rubygems.org/gems/{{name}}] 12 | * Documentation: =>[http://www.rubydoc.info/gems/{{name}}] 13 | ] 14 | ] 15 | section[ 16 | @title[Command Line Applications] 17 | gem[ 18 | @name[cmdparse] 19 | @url[http://cmdparse.rubyforge.org/] 20 | @desc[cmdparse provides classes for parsing commands on the command line; command line options are parsed using optparse or any other option parser implementation. ] 21 | ] 22 | gem[ 23 | @name[gli] 24 | @url[http://davetron5000.github.com/gli] 25 | @desc[An application and API for describing command line interfaces that can be used to quickly create a shell for executing command-line tasks.] 26 | ] 27 | gem[ 28 | @name[highline] 29 | @url[http://highline.rubyforge.org/] 30 | @desc[A high-level IO library that provides validation, type conversion, and more for command-line interfaces. HighLine also includes a complete menu system that can crank out anything from simple list selection to complete shells with just minutes of work.] 31 | ] 32 | gem[ 33 | @name[hirb] 34 | @url[https://github.com/cldwalker/hirb] 35 | @desc[A mini view framework for console/irb that's easy to use, even while under its influence. Console goodies include a no-wrap table, auto-pager, tree and menu] 36 | ] 37 | 38 | ] 39 | section[ 40 | @title[Documentation] 41 | gem[ 42 | @name[glyph] 43 | @url[http://www.h3rald.com/glyph/] 44 | @desc[Glyph is a framework for structured document authoring.] 45 | ] 46 | gem[ 47 | @name[rdoc] 48 | @url[https://github.com/rdoc/rdoc/] 49 | @desc[RDoc produces HTML and online documentation for Ruby projects. RDoc includes the rdoc and ri tools for generating and displaying online documentation.] 50 | ] 51 | gem[ 52 | @name[yard] 53 | @url[http://yardoc.org/] 54 | @desc[YARD is a documentation generation tool for the Ruby programming language. It enables the user to generate consistent, usable documentation that can be exported to a number of formats very easily, and also supports extending for custom Ruby constructs such as custom class level definitions.] 55 | ] 56 | ] 57 | section[ 58 | @title[Gem Management] 59 | gem[ 60 | @name[bundler] 61 | @url[http://gembundler.com/] 62 | @desc[Bundler manages an application's dependencies through its entire life, across many machines, systematically and repeatably.] 63 | ] 64 | gem[ 65 | @name[jeweler] 66 | @url[http://github.com/technicalpickles/jeweler] 67 | @desc[Simple and opinionated helper for creating Rubygem projects on GitHub] 68 | ] 69 | gem[ 70 | @name[bones] 71 | @url[https://github.com/TwP/bones] 72 | @desc[Mr Bones is a handy tool that creates new projects from a code skeleton.] 73 | ] 74 | ] 75 | section[ 76 | @title[GUI Programming] 77 | gem[ 78 | @name[bowline] 79 | @url[http://bowlineapp.com/] 80 | @desc[Ruby/JS GUI framework] 81 | ] 82 | gem[ 83 | @name[fxruby] 84 | @url[http://www.fxruby.org/] 85 | @desc[FXRuby is the Ruby binding to the FOX GUI toolkit] 86 | ] 87 | gem[ 88 | @name[wxruby] 89 | @url[http://wxruby.org/] 90 | @desc[wxRuby allows the creation of graphical user interface (GUI) applications via the wxWidgets library. wxRuby provides native-style GUI windows, dialogs and controls on platforms including Windows, OS X and Linux.] 91 | ] 92 | gem[ 93 | @name[qtruby4] 94 | @url[http://rubyforge.org/projects/korundum/] 95 | @desc[Qt4 Bindings for Ruby.] 96 | ] 97 | gem[ 98 | @name[rugui] 99 | @url[http://rugui.org/] 100 | @desc[RuGUI is a framework which aims to help building desktop applications. RuGUI was mostly inspired by the Ruby on Rails framework, taking most of its features from it.] 101 | ] 102 | box[What about Shoes?| 103 | =>[http://shoesrb.com/|Shoes] is a cross-platform, easy-to-use Ruby toolkit originally created by =>[#_why]. Unfortunately, it is distributed as a standalone application rather than a gem (yet), due to its internal architecture and dependencies. 104 | ] 105 | ] 106 | section[ 107 | @title[Markup and Template Languages] 108 | gem[ 109 | @name[bluecloth] 110 | @url[http://www.deveiate.org/projects/BlueCloth] 111 | @desc[BlueCloth is a Ruby implementation of Markdown, a text-to-HTML conversion tool for web writers. To quote from the project page: Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML).] 112 | ] 113 | gem[ 114 | @name[github-markup] 115 | @url[http://github.com/github/markup] 116 | @desc[This gem is used by GitHub to render any fancy markup such as Markdown, Textile, Org-Mode, etc. Fork it and add your own!] 117 | ] 118 | gem[ 119 | @name[haml] 120 | @url[http://haml-lang.com/] 121 | @desc[Haml (HTML Abstraction Markup Language) is a layer on top of XHTML or XML that's designed to express the structure of XHTML or XML documents in a non-repetitive, elegant, easy way, using indentation rather than closing tags and allowing Ruby to be embedded with ease. It was originally envisioned as a plugin for Ruby on Rails, but it can function as a stand-alone templating engine.] 122 | ] 123 | gem[ 124 | @name[liquid] 125 | @url[http://www.liquidmarkup.org/] 126 | @desc[A secure, non-evaling end user template engine with aesthetic markup.] 127 | ] 128 | gem[ 129 | @name[mustache] 130 | @url[http://github.com/defunkt/mustache] 131 | @desc[Inspired by ctemplate, Mustache is a framework-agnostic way to render logic-free views. As ctemplates says, "It emphasizes separating logic from presentation: it is impossible to embed application logic in this template language. Think of Mustache as a replacement for your views. Instead of views consisting of ERB or HAML with random helpers and arbitrary logic, your views are broken into two parts: a Ruby class and an HTML template.] 132 | ] 133 | gem[ 134 | @name[rdiscount] 135 | @url[http://github.com/rtomayko/rdiscount/] 136 | @desc[Fast Implementation of Gruber's Markdown in C] 137 | ] 138 | gem[ 139 | @name[redcloth] 140 | @url[http://redcloth.org/] 141 | @desc[RedCloth is a Ruby library for converting Textile into HTML.] 142 | ] 143 | ] 144 | section[ 145 | @title[Static Web Site Generators] 146 | gem[ 147 | @name[jekyll] 148 | @url[http://jekyllrb.com/] 149 | @desc[Jekyll is a simple, blog aware, static site generator.] 150 | ] 151 | gem[ 152 | @name[nanoc] 153 | @url[http://nanoc.stoneship.org/] 154 | @desc[a web publishing system written in Ruby for building small to medium-sized websites.] 155 | ] 156 | gem[ 157 | @name[toto] 158 | @url[http://cloudhead.io/toto] 159 | @desc[the tiniest blog-engine in Oz.] 160 | ] 161 | gem[ 162 | @name[webby] 163 | @url[http://webby.rubyforge.org/] 164 | @desc[Webby is a fantastic little website management system. It would be called a content management system if it were a bigger kid. But, it's just a runt with a special knack for transforming text. And that's really all it does - manages the legwork of turning text into something else, an ASCII Alchemist if you will. ] 165 | ] 166 | ] 167 | section[ 168 | @title[Testing] 169 | gem[ 170 | @name[bacon] 171 | @url[http://github.com/chneukirchen/bacon] 172 | @desc[Bacon is a small RSpec clone weighing less than 350 LoC but nevertheless providing all essential features.] 173 | ] 174 | gem[ 175 | @name[cucumber] 176 | @url[http://cukes.info/] 177 | @desc[Behaviour Driven Development with elegance and joy] 178 | ] 179 | gem[ 180 | @name[minitest] 181 | @url[https://github.com/seattlerb/minitest] 182 | @desc[minitest provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking. minitest/unit is a small and incredibly fast unit testing framework.] 183 | ] 184 | gem[ 185 | @name[rspec] 186 | @url[http://relishapp.com/rspec] 187 | @desc[RSpec is a Behaviour-Driven Development tool for Ruby programmers. BDD is an approach to software development that combines Test-Driven Development, Domain Driven Design, and Acceptance Test-Driven Planning. RSpec helps you do the TDD part of that equation, focusing on the documentation and design aspects of TDD.] 188 | ] 189 | gem[ 190 | @name[shoulda] 191 | @url[http://www.thoughtbot.com/projects/shoulda] 192 | @desc[Making tests easy on the fingers and eyes] 193 | ] 194 | ] 195 | section[ 196 | @title[Web Development] 197 | gem[ 198 | @name[rails] 199 | @url[http://rubyonrails.org/] 200 | @desc[Ruby on Rails is a full-stack web framework optimized for programmer happiness and sustainable productivity. It encourages beautiful code by favoring convention over configuration.] 201 | ] 202 | gem[ 203 | @name[sinatra] 204 | @url[http://www.sinatrarb.com/] 205 | @desc[Classy web-development dressed in a DSL] 206 | ] 207 | gem[ 208 | @name[padrino-framework] 209 | @url[http://www.padrinorb.com/] 210 | @desc[The Godfather of Sinatra provides a full-stack agnostic framework on top of Sinatra] 211 | ] 212 | gem[ 213 | @name[merb-core] 214 | @url[http://www.merbivore.com/] 215 | @desc[Merb. Pocket rocket web framework.] 216 | ] 217 | gem[ 218 | @name[ramaze] 219 | @url[http://ramaze.net/] 220 | @desc[Ramaze is a simple and modular web framework] 221 | ] 222 | gem[ 223 | @name[camping] 224 | @url[http://camping.rubyforge.org/] 225 | @desc[miniature rails for stay-at-home moms] 226 | ] 227 | ] 228 | section[ 229 | @title[Web and App Servers] 230 | gem[ 231 | @name[passenger] 232 | @url[http://www.modrails.com/] 233 | @desc[Easy and robust Ruby web application deployment.] 234 | ] 235 | gem[ 236 | @name[rack] 237 | @url[http://rack.rubyforge.org/] 238 | @desc[Rack provides a minimal interface between webservers supporting Ruby and Ruby frameworks.] 239 | ] 240 | gem[ 241 | @name[thin] 242 | @url[http://code.macournoyer.com/thin/] 243 | @desc[A thin and fast web server] 244 | ] 245 | gem[ 246 | @name[unicorn] 247 | @url[http://unicorn.bogomips.org/] 248 | @desc[Unicorn is an HTTP server for Rack applications designed to only serve fast clients on low-latency, high-bandwidth connections and take advantage of features in Unix/Unix-like kernels.] 249 | ] 250 | ] 251 | section[ 252 | @title[XML Parsing] 253 | gem[ 254 | @name[hpricot] 255 | @url[http://code.whytheluckystiff.net/hpricot/] 256 | @desc[a swift, liberal HTML parser with a fantastic library] 257 | ] 258 | gem[ 259 | @name[nokogiri] 260 | @url[http://nokogiri.org/] 261 | @desc[An HTML, XML, SAX, & Reader parser with the ability to search documents via XPath or CSS3 selectors... and much more] 262 | ] 263 | gem[ 264 | @name[xml-simple] 265 | @url[http://xml-simple.rubyforge.org/] 266 | @desc[A simple API for XML processing.] 267 | ] 268 | ] 269 | -------------------------------------------------------------------------------- /images/ruby-compendium/ruby.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | image/svg+xml 394 | 401 | 405 | 409 | 413 | 417 | 421 | 422 | 423 | 430 | 434 | 438 | 442 | 446 | 447 | 448 | 455 | 459 | 463 | 467 | 471 | 472 | 473 | 480 | 484 | 488 | 492 | 496 | 500 | 504 | 505 | 506 | 513 | 517 | 521 | 525 | 529 | 533 | 537 | 538 | 539 | 546 | 550 | 554 | 558 | 562 | 566 | 570 | 571 | 572 | 579 | 583 | 587 | 591 | 595 | 599 | 600 | 601 | 608 | 612 | 616 | 620 | 624 | 628 | 629 | 630 | 631 | 638 | 642 | 646 | 650 | 654 | 658 | 662 | 666 | 670 | 674 | 678 | 679 | 680 | 687 | 691 | 695 | 699 | 703 | 707 | 708 | 709 | 716 | 720 | 724 | 728 | 732 | 733 | 734 | 741 | 745 | 749 | 753 | 757 | 758 | 759 | 760 | 766 | 770 | 774 | 778 | 782 | 783 | 784 | 790 | 794 | 798 | 802 | 806 | 807 | 808 | 815 | 819 | 823 | 827 | 831 | 835 | 836 | 837 | 844 | 848 | 852 | 856 | 860 | 864 | 865 | 866 | --------------------------------------------------------------------------------