Top Banner
Master on Free Software Ruby (on Rails) Asís and David {asis.garcia, david.barral}@trabesoluciones.com
53
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Ruby On Rails

Master on Free Software

Ruby (on Rails)

Asís and David{asis.garcia, david.barral}@trabesoluciones.com

Page 2: Ruby On Rails

Master on Free Software

Outline (1)Social axis

- License- Comunity- Bussiness- Resources

Historical axis- Matz- Versions- Future

Technological axis- Source code- Tools- Platform

Page 3: Ruby On Rails

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

Page 4: Ruby On Rails

Master on Free Software

Ruby is born

Page 5: Ruby On Rails

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

Page 6: Ruby On Rails

Master on Free Software

Ruby's story

Page 7: Ruby On Rails

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

Page 8: Ruby On Rails

Master on Free Software

Ruby from the code (1)

Dynamic types

Object Oriented: Everything is an object

Page 9: Ruby On Rails

Master on Free Software

Ruby from the code (2)

Even classes are objects.

Weird? Not much, remember Smalltalk

Page 10: Ruby On Rails

Master on Free Software

Ruby from the code (3)

Even nil is an object !!!

[Only for pros] Redefine/Extend NilClass, OMG !!!

Page 11: Ruby On Rails

Master on Free Software

Ruby from the code (4)

Ranges Arrays Hashes Symbols Operator

overload

Page 12: Ruby On Rails

Master on Free Software

Ruby from the code (5)

Everything returns a value

Page 13: Ruby On Rails

Master on Free Software

Ruby from the code (6)

Regular Expressions

Only nil and false are false

Page 14: Ruby On Rails

Master on Free Software

Ruby from the code (7)

Control structures

if, unless pre/postfix

?: case

Page 15: Ruby On Rails

Master on Free Software

Ruby from the code (8)

Loops Closures (more about them later)

Page 16: Ruby On Rails

Master on Free Software

Ruby from the code (9) Enumerables

Page 17: Ruby On Rails

Master on Free Software

Ruby from the code (10)

Closures

Page 18: Ruby On Rails

Master on Free Software

Ruby from the code (11)

Multiple syntax: heaven or hell? Internal DSLs

Page 19: Ruby On Rails

Master on Free Software

Ruby from the code (12)

Class morphology

local => var

instance => @var

class => @@var

self

Multiple syntax !!

Page 20: Ruby On Rails

Master on Free Software

Ruby from the code (13)

Access levels: public, protected, private

Page 21: Ruby On Rails

Master on Free Software

Ruby from the code (14)

Modules Logic

agroupations Namespaces

Page 22: Ruby On Rails

Master on Free Software

Ruby from the code (15)

Mixins Code

inclussions Multiple

inheritance workaround

Page 23: Ruby On Rails

Master on Free Software

Ruby from the code (16)

Duck typing

Page 24: Ruby On Rails

Master on Free Software

Ruby from the code (17)

Method missing: Prevent errors, easy proxies and decorators, black magic (see Rails)

Page 25: Ruby On Rails

Master on Free Software

Ruby from the code (18)

Page 26: Ruby On Rails

Master on Free Software

Ruby from the code (19)

Introspection

Meta programming

Class reopening

Page 27: Ruby On Rails

Master on Free Software

Ruby from the code (20)

More control structures Exceptions Requires Core libraries include vs. extend Threads Tons of other stuff...

Page 28: Ruby On Rails

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>

Page 29: Ruby On Rails

Master on Free Software

Ruby Tools (2)

Rdoc

$ rdoc rdoc_example.rb

Page 30: Ruby On Rails

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+.

Page 31: Ruby On Rails

Master on Free Software

Ruby tools (4)

Rake

$ rake -f rake_example.rake

Hello World!

Like make Ruby DSL Everything is Ruby

Page 32: Ruby On Rails

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)

...

Page 33: Ruby On Rails

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

Page 34: Ruby On Rails

Master on Free Software

Ruby resources ruby-lang.org

en.wikipedia.org/wiki/Ruby_(programming_language)

www.ruby-doc.org

www.ruby-forum.com

rubyforge.org

jobs.rubynow.com

rubyconf2007.confreaks.com

google.com and ask for Ruby politely

Page 35: Ruby On Rails

Master on Free Software

Rails is born

Page 36: Ruby On Rails

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

Page 37: Ruby On Rails

Master on Free Software

Rails' story

Page 38: Ruby On Rails

Master on Free Software

Rails request overview

Page 39: Ruby On Rails

Master on Free Software

Rails from the code (1)

Page 40: Ruby On Rails

Master on Free Software

Rails from the code (2)

Page 41: Ruby On Rails

Master on Free Software

Rails from the code (3)

More on this later...

Page 42: Ruby On Rails

Master on Free Software

Rails tools

Console Generators Plugins How??? Wait a little...

Page 43: Ruby On Rails

Master on Free Software

To be continued...

Page 44: Ruby On Rails

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

Page 45: Ruby On Rails

Master on Free Software

... here we continue

Page 46: Ruby On Rails

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...

Page 47: Ruby On Rails

Master on Free Software

Rails 2.0 (1)

REST

Page 48: Ruby On Rails

Master on Free Software

Rails 2.0 (2)

Page 49: Ruby On Rails

Master on Free Software

Rails 2.0 (3)

Sexy migrations

Page 50: Ruby On Rails

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

Page 51: Ruby On Rails

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

Page 52: Ruby On Rails

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

Page 53: Ruby On Rails

Master on Free Software

That's all folks!!