Ruby (on Rails)

attackkaboomInternet and Web Development

Feb 2, 2013 (4 years and 4 months ago)

138 views

Master on Free Software
Ruby (on Rails)
Asís and David
{asis.garcia, david.barral}@trabesoluciones.com
Master on Free Software
Outline (1)
Social axis
- License
- Comunity
- Bussiness
- Resources
Historical axis
- Matz
- Versions
- Future
Technological axis
- Source code
- Tools
- Platform
Master on Free Software
Outline (2)
Social axis
- Licencense
- Comunity
- Bussiness
- Resources
Historical axis
- DHH and 37signals
- Versions
- Future
Technological axis
- Source code
- Tools
- Platform
- Deployment
Master on Free Software
Ruby is born
Master on Free Software
There is something about Ruby

Philosophy

Focus on programmers productivity and “joy”

Follows good IU design principles


We are the masters, they are the slaves”

Principle of least surprise (POLS)

License:

Matz own terms

Can be overriden with GPL
Master on Free Software
Ruby's story
Master on Free Software
Ruby basic install

Available as package on most systems
$ sudo apt-get install ruby irb rdoc ir
$ ruby -v

As source code
$ wget ftp://ftp.ruby-lang.org/pub/ruby/stable/ruby-1.8.6.tar.gz
$ tar xvfz ruby-1.8.6.tar.gz
$ cd ruby-1.8.6
$ ./configure
$ make
$ make test
$ make install
Master on Free Software
Ruby from the code (1)
Dynamic types
Object Oriented: Everything is an object
Master on Free Software
Ruby from the code (2)
Even classes are objects.
Weird? Not much, remember Smalltalk
Master on Free Software
Ruby from the code (3)
Even nil is an object !!!
[Only for pros]
Redefine/Extend NilClass, OMG !!!
Master on Free Software
Ruby from the code (4)

Ranges

Arrays

Hashes

Symbols

Operator
overload
Master on Free Software
Ruby from the code (5)

Everything
returns a
value
Master on Free Software
Ruby from the code (6)

Regular
Expressions

Only nil and
false are false
Master on Free Software
Ruby from the code (7)

Control
structures

if, unless

pre/postfix

?:

case
Master on Free Software
Ruby from the code (8)

Loops

Closures (more about them later)
Master on Free Software
Ruby from the code (9)

Enumerables
Master on Free Software
Ruby from the code (10)

Closures
Master on Free Software
Ruby from the code (11)

Multiple syntax: heaven or hell?

Internal DSLs
Master on Free Software
Ruby from the code (12)

Class morphology

local => var

instance => @var

class => @@var

self

Multiple syntax !!
Master on Free Software
Ruby from the code (13)

Access levels: public, protected, private
Master on Free Software
Ruby from the code (14)

Modules

Logic
agroupations

Namespaces
Master on Free Software
Ruby from the code (15)

Mixins

Code
inclussions

Multiple
inheritance
workaround
Master on Free Software
Ruby from the code (16)

Duck typing
Master on Free Software
Ruby from the code (17)

Method missing: Prevent errors, easy proxies
and decorators, black magic (see Rails)
Master on Free Software
Ruby from the code (18)
Master on Free Software
Ruby from the code (19)

Introspection

Meta
programming

Class
reopening
Master on Free Software
Ruby from the code (20)

More control structures

Exceptions

Requires

Core libraries

include vs. extend

Threads

Tons of other stuff...
Master on Free Software
Ruby Tools (1)
Irb: Interactive ruby shell
[david@io ~]
$ irb
>> 5+5
=> 10
>> class Dog
>> end
=> nil
>> dog = Dog.new
=> #<Dog:0x2aaaaabb0ba0>

Master on Free Software
Ruby Tools (2)
Rdoc
$ rdoc rdoc_example.rb
Master on Free Software
Ruby Tools (3)
RI
$ ri Array.delete_if
-------------------------------------------------------- Array#delete_if

array.delete_if {|item| block } -> array
------------------------------------------------------------------------

Deletes every element of _self_ for which _block_ evaluates to

+true+.

Master on Free Software
Ruby tools (4)
Rake
$ rake -f rake_example.rake
Hello World!

Like make

Ruby DSL

Everything is Ruby
Master on Free Software
Ruby tools (5)
Gem

yum|apt like tool: ruby package manager
$ gem search rails
$ sudo gem install rails -v1.2.5
$ gem list
*** LOCAL GEMS ***
actionmailer (2.0.2, 2.0.1, 1.3.3, 1.3.2, 1.2.5)
actionpack (2.0.2, 2.0.1, 1.13.3, 1.13.2, 1.12.5)
actionwebservice (1.2.6, 1.2.3, 1.2.2, 1.1.6)
activerecord (2.0.2, 2.0.1, 1.15.3, 1.15.2, 1.14.4)
...
Master on Free Software
Ruby tools (6)
Installing Gem (on Ubuntu)
$ sudo apt-get install libyaml-ruby libzlib-ruby
$ wget http://rubyforge.org/frs/download.php/29548/rubygems-1.0.1.tgz
$ tar xvfz rubygems-1.0.1.tgz
$ cd rubygems-1.0.1
$ sudo ruby setup.rb
$ sudo ln -s /usr/bin/gem1.8 /usr/bin/gem

Master on Free Software
Ruby resources

ruby-lang.org

en.wikipedia.org/wiki/Ruby_(programming_lang
uage)

www.ruby-doc.org

www.ruby-forum.com

rubyforge.org

jobs.rubynow.com

rubyconf2007.confreaks.com

google.com and ask for Ruby politely
Master on Free Software
Rails is born
Master on Free Software
There is something about
Rails

Web MVC framework (action oriented)

DRY: don't repeat yourself

CoC: convention over configuration

Opinionated


Mix Java and PHP”

Marketing +
buzz

MIT License
Master on Free Software
Rails' story
Master on Free Software
Rails request overview
Master on Free Software
Rails from the code (1)
Master on Free Software
Rails from the code (2)
Master on Free Software
Rails from the code (3)

More on this later...
Master on Free Software
Rails tools

Console

Generators

Plugins

How??? Wait a little...
Master on Free Software
To be continued...
Master on Free Software
Sqlite3 en Ubuntu
$ sudo apt-get install ruby1.8-dev
$ sudo apt-get install sqlite3 libsqlite3-dev
$ sudo gem install sqlite3-ruby
Master on Free Software
... here we continue
Master on Free Software
More on rails

More about validations

More on routes

Session storage

Filters

More on environments

Ajax

ERB alternatives: Haml,
Markaby

Advanced Active Record

Mailers

Caching

Custom generators

Some nice plugins

How to extend Rails

Capistrano

Rails 2.0...
Master on Free Software
Rails 2.0 (1)

REST
Master on Free Software
Rails 2.0 (2)
Master on Free Software
Rails 2.0 (3)

Sexy
migrations
Master on Free Software
Deployment

Escalabilidad en Rails” by Pablo A.Delgado
http://www.slideshare.net/pablete/escalabilidad-en-rails
http://amaiac.net/conferenciarails2007/torrents/06_Rails_Hispana_2007_Sala1_Escalabilidad.wmv.torrent
Master on Free Software
Resources (1)

rubyonrails.org

wiki.rubyonrails.org

agilewebdevelopment.com

www.ruby-forum.com

www.workingwithrails.com

Plugin repositories

agilewebdevelopment.com/plugins

www.railslodge.com

wiki.rubyonrails.org/rails/pages/Plugins
Master on Free Software
Resources (2)

Blogs

weblog.rubyonrails.com

www.loudthinking.com

www.therailsway.com

www.zedshaw.com

4trabes.com

Listas

lists.rubyonrails.org/mailman/listinfo/rails

lists.simplelogica.net/mailman/listinfo/ror-es
Master on Free Software
That's all folks!!