• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
ERECOMPI
 

ERECOMPI

on

  • 1,796 views

Palestra de Ruby on Rails que dei no evento ERECOMPI, em Teresina, no Piauí.

Palestra de Ruby on Rails que dei no evento ERECOMPI, em Teresina, no Piauí.

Statistics

Views

Total Views
1,796
Views on SlideShare
1,671
Embed Views
125

Actions

Likes
2
Downloads
62
Comments
0

4 Embeds 125

http://desunidos.wordpress.com 68
http://constantinoneto.wordpress.com 55
http://www.slideshare.net 1
url_unknown 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    ERECOMPI ERECOMPI Presentation Transcript

    • Ruby on Rails Thursday, June 4, 2009
    • AkitaOnRails.com slideshare.net/akitaonrails Thursday, June 4, 2009
    • 2008 Thursday, June 4, 2009
    • 2008 Thursday, June 4, 2009
    • 13 e 14 Outubro 2009 Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • ~108 slides ~90 min Thursday, June 4, 2009
    • www.slideshare.net/akitaonrails fabio.akita@locaweb.com.br Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • “Especialista em uma coisa só é um amador em todo o resto.” Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Ruby on Rails 2.3 Ruby 1.8 Novo Ruby 1.9 Thursday, June 4, 2009
    • Ruby on Rails 2.3 Ruby 1.8 Novo Ruby 1.9 Thursday, June 4, 2009
    • Ruby on Rails 2.3 Ruby 1.8 Novo Ruby 1.9 Thursday, June 4, 2009
    • “Matz” 1993 Thursday, June 4, 2009
    • “Prag Dave” 2001 Thursday, June 4, 2009
    • “DHH” 2004 Thursday, June 4, 2009
    • Charles Nutter 2006 Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • “Tornar as coisas simples fáceis e as coisas complexas possíveis” Filosofia Ruby Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • O que dizem por aí ... Thursday, June 4, 2009
    • Pouco usado Thursday, June 4, 2009
    • Rails não Escala Thursday, June 4, 2009
    • Ruby é Lento Thursday, June 4, 2009
    • WTF!? Thursday, June 4, 2009
    • Pouco usado Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Rails não Escala Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Para colocar as coisas em perspectiva, o Friendster foi escrito em Java e eles mudaram para PHP. MySpace foi escrito em ColdFusion e eles mudaram para ASP.NET. Quando as pessoas caem em problemas de escalabilidade, normalmente acham que a linguagem é o problema, mas eu acho que isso raramente é a realidade. Blaine Cook http://www.akitaonrails.com/2008/6/17/chatting-with-blaine-cook-twitter Thursday, June 4, 2009
    • “O The New York Times usou Ruby on Rails para agregar, analizar e mostrar os resultados das eleições em quase tempo real em um de seus sites mais acessados de todos os tempos.” http://www.computerworld.com.au/article/268003/ruby_rails_rolls_into_enterprise?fp=16&fpid=1 Thursday, June 4, 2009
    • Ruby é Lento Thursday, June 4, 2009
    • x mais lento que C++ Thursday, June 4, 2009
    • x mais lento que C++ 0 50 100 Python 2 150 Ruby 1.9 200 Perl JRuby Python 3 PHP Ruby 1.8.6 Thursday, June 4, 2009
    • Homepage: 331 ms Thursday, June 4, 2009
    • Homepage: 331 ms Total: 5.45 s Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • PHP “puro” 331 req/s CakePHP 4 a 8 req/s* Code Igniter 22 a 98 req/s* Rails (2008) 88 req/s Thursday, June 4, 2009
    • PHP “puro” 331 req/s CakePHP 4 a 8 req/s* Code Igniter 22 a 98 req/s* Rails (2008) 88 req/s Thursday, June 4, 2009
    • PHP “puro” 331 req/s CakePHP 4 a 8 req/s* Code Igniter 22 a 98 req/s* Rails (2008) 88 req/s Thursday, June 4, 2009
    • PHP “puro” 331 req/s CakePHP 4 a 8 req/s* Code Igniter 22 a 98 req/s* Rails (2008) 88 req/s Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • PHP Reload Java Persistente Ruby Misto Thursday, June 4, 2009
    • PHP Reload Java Persistente Ruby Misto Thursday, June 4, 2009
    • PHP Reload Java Persistente Ruby Misto Thursday, June 4, 2009
    • Browser Rails Banco de Banco Slave Dados Thursday, June 4, 2009
    • Browser Rails Banco de Banco Slave Dados Thursday, June 4, 2009
    • Browser Rails Banco de Banco Slave Dados Thursday, June 4, 2009
    • Browser Rails Banco Slave Banco de Dados Thursday, June 4, 2009
    • Browser Rails Banco de Banco Slave Dados Thursday, June 4, 2009
    • Browser Rails Memcached Banco de Banco Slave Dados Thursday, June 4, 2009
    • Browser Rails Memcached Banco de Banco Slave Dados Thursday, June 4, 2009
    • Browser Memcached Rails Memcached Banco de Banco Slave Dados Thursday, June 4, 2009
    • Browser Memcached Web Caches Rails Memcached Banco de Banco Slave Dados Thursday, June 4, 2009
    • Performance != Escalabilidade Thursday, June 4, 2009
    • Performance Ghz “Vertical” Thursday, June 4, 2009
    • Escalabilidade MultiCore “Horizontal” Thursday, June 4, 2009
    • Ruby on Rails Thursday, June 4, 2009
    • RUBY Thursday, June 4, 2009
    • Rails ActiveSupport RUBY Thursday, June 4, 2009
    • ActionController ActionPack ActionView Rails ActiveSupport RUBY Thursday, June 4, 2009
    • ActiveRecord ActionController ActionPack ActionView Rails ActiveSupport RUBY Thursday, June 4, 2009
    • ActionMailer ActiveRecord ActionController ActionPack ActionView Rails ActiveSupport RUBY Thursday, June 4, 2009
    • ActiveResource ActionWebService ActionMailer ActiveRecord ActionController ActionPack ActionView Rails ActiveSupport RUBY Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • RSpec describe Product do include ProductSpecHelper before(:each) do @product = Product.new end it quot;should not be valid when emptyquot; do @product.should_not be_valid end it quot;should be valid when having correct informationquot; do @product.attributes = valid_product_attributes @product.should be_valid end end Thursday, June 4, 2009
    • RSpec describe Product do include ProductSpecHelper before(:each) do @product = Product.new end it quot;should not be valid when emptyquot; do rake spec @product.should_not be_valid end it quot;should be valid when having correct informationquot; do @product.attributes = valid_product_attributes @product.should be_valid end end Thursday, June 4, 2009
    • Model class Product < ActiveRecord::Base after_create :set_initial_inventory has_many :variants, :dependent => :destroy has_many :images, :as => :viewable, :order => :position, :dependent => :destroy has_many :properties, :through => :product_properties belongs_to :tax_category validates_presence_of :name validates_presence_of :master_price validates_presence_of :description make_permalink :with => :name, :field => :permalink end Thursday, June 4, 2009
    • Model class Product < ActiveRecord::Base after_create :set_initial_inventory has_many :variants, :dependent => :destroy has_many :images, :as => :viewable, :order => :position, :dependent => :destroy has_many :properties, :through => :product_properties Product.find(1) belongs_to :tax_category validates_presence_of :name validates_presence_of :master_price validates_presence_of :description make_permalink :with => :name, :field => :permalink end Thursday, June 4, 2009
    • Controller class UsersController < Spree::BaseController resource_controller before_filter :initialize_extension_partials actions :all, :except => [:index, :destroy] show.before do @orders = Order.checkout_completed(true) .find_all_by_user_id(current_user.id) end create.after { self.current_user = @user } create.response do |wants| wants.html { redirect_back_or_default(products_path) } end end Thursday, June 4, 2009
    • Controller class UsersController < Spree::BaseController resource_controller before_filter :initialize_extension_partials actions :all, :except => [:index, :destroy] show.before do @orders = Order.checkout_completed(true) /users/1 .find_all_by_user_id(current_user.id) end create.after { self.current_user = @user } create.response do |wants| wants.html { redirect_back_or_default(products_path) } end end Thursday, June 4, 2009
    • Views ERB <div id=quot;product-listingquot;> <%= breadcrumbs(@taxon) %> <br/> <%= render :partial => quot;shared/products.html.erbquot;, :locals => {:products => @products, :taxon => @taxon } %> </div> <% content_for :sidebar do %> <td id=quot;shop-by-colquot; valign=quot;topquot;> <%= render :partial => quot;shared/taxonomiesquot; %> </td> <% end %> <%= render :partial => 'shared/paginate', :locals => {:collection => @products, :options => {}} unless @products.empty? %> Thursday, June 4, 2009
    • Views HAML #product-listing =breadcrumbs(@taxon) %br =render :partial => quot;shared/products.html.erbquot;, :locals => {:products => @products, :taxon => @taxon} -content_for :sidebar do %td#shop-by-col(:valign => quot;topquot;) =render :partial => quot;shared/taxonomiesquot; =render :partial => 'shared/paginate', :locals => {:collection => @products, :options => {}} unless @products.empty? Thursday, June 4, 2009
    • Rotas RESTFul ActionController::Routing::Routes.draw do |map| map.connect ':controller/service.wsdl', :action => 'wsdl' map.resources :products, :member => {:change_image => :post} map.resources :addresses map.resources :orders, :has_many => [:line_items] map.namespace :admin do |admin| admin.resources :users admin.resources :products end end Thursday, June 4, 2009
    • Rotas RESTFul ActionController::Routing::Routes.draw do |map| GET /products/new map.connect ':controller/service.wsdl', :action => 'wsdl' GET /products map.resources :products, :member => POST /products {:change_image => :post} map.resources :addresses GET /products/1 map.resources :orders, GET /products/1/edit :has_many => [:line_items] map.namespacePUT /products/1 :admin do |admin| DESTROY /products/1 admin.resources :users admin.resources :products end end Thursday, June 4, 2009
    • Migrations class RenameAppConfiguration < ActiveRecord::Migration def self.up rename_table :app_configurations, :configurations change_table :configurations do |t| t.string :type end end def self.down change_table :configurations do |t| t.remove :type end rename_table :configurations, :app_configurations end end Thursday, June 4, 2009
    • Migrations class RenameAppConfiguration < ActiveRecord::Migration def self.up rename_table :app_configurations, :configurations change_table :configurations do |t| t.string :type end end rake db:migrate def self.down change_table :configurations do |t| t.remove :type end rename_table :configurations, :app_configurations end end Thursday, June 4, 2009
    • “Beautiful Code” Thursday, June 4, 2009
    • @Transient public BigDecimal getTotal() //$Id: Booking.java 5579 2007-06-27 00:06:49Z gavin $ { package org.jboss.seam.example.booking; return hotel.getPrice().multiply( new BigDecimal( getNights() ) ); } import java.io.Serializable; import java.math.BigDecimal; @Transient import java.text.DateFormat; public int getNights() import java.util.Date; { return (int) ( checkoutDate.getTime() - checkinDate.getTime() ) / import javax.persistence.Basic; 1000 / 60 / 60 / 24; import javax.persistence.Entity; } import javax.persistence.GeneratedValue; import javax.persistence.Id; @Id @GeneratedValue import javax.persistence.ManyToOne; public Long getId() import javax.persistence.Temporal; { import javax.persistence.TemporalType; return id; import javax.persistence.Transient; } public void setId(Long id) import org.hibernate.validator.Length; { import org.hibernate.validator.NotNull; this.id = id; import org.hibernate.validator.Pattern; } import org.jboss.seam.annotations.Name; @NotNull @Entity @Basic @Temporal(TemporalType.DATE) @Name(quot;bookingquot;) public Date getCheckinDate() public class Booking implements Serializable { { return checkinDate; private Long id; } private User user; public void setCheckinDate(Date datetime) private Hotel hotel; { private Date checkinDate; this.checkinDate = datetime; private Date checkoutDate; } private String creditCard; private String creditCardName; @ManyToOne @NotNull private int creditCardExpiryMonth; public Hotel getHotel() private int creditCardExpiryYear; { private boolean smoking; return hotel; private int beds; } public void setHotel(Hotel hotel) public Booking() {} { this.hotel = hotel; public Booking(Hotel hotel, User user) } { this.hotel = hotel; @ManyToOne @NotNull this.user = user; public User getUser() } { return user; } Thursday, June 4, 2009
    • public int getBeds() public void setUser(User user) { { return beds; this.user = user; } } public void setBeds(int beds) @Basic @Temporal(TemporalType.DATE) { @NotNull this.beds = beds; public Date getCheckoutDate() } { @NotNull(message=quot;Credit card name is requiredquot;) return checkoutDate; @Length(min=3, max=70, message=quot;Credit card name is requiredquot;) } public String getCreditCardName() public void setCheckoutDate(Date checkoutDate) { { return creditCardName; this.checkoutDate = checkoutDate; } } public void setCreditCardName(String creditCardName) @NotNull(message=quot;Credit card number is requiredquot;) { @Length(min=16, max=16, message=quot;Credit card number must 16 digits longquot;) this.creditCardName = creditCardName; @Pattern(regex=quot;^d*$quot;, message=quot;Credit card number must be numericquot;) } public String getCreditCard() { public int getCreditCardExpiryMonth() return creditCard; { } return creditCardExpiryMonth; } public void setCreditCard(String creditCard) { public void setCreditCardExpiryMonth(int creditCardExpiryMonth) this.creditCard = creditCard; { } this.creditCardExpiryMonth = creditCardExpiryMonth; } @Transient public String getDescription() public int getCreditCardExpiryYear() { { DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM); return creditCardExpiryYear; return hotel==null ? null : hotel.getName() + } quot;, quot; + df.format( getCheckinDate() ) + quot; to quot; + df.format( getCheckoutDate() ); public void setCreditCardExpiryYear(int creditCardExpiryYear) } { this.creditCardExpiryYear = creditCardExpiryYear; public boolean isSmoking() } { return smoking; @Override } public String toString() { public void setSmoking(boolean smoking) return quot;Booking(quot; + user + quot;,quot;+ hotel + quot;)quot;; { } this.smoking = smoking; } } Thursday, June 4, 2009
    • class Booking < ActiveRecord::Base belongs_to :hotel belongs_to :user validates_presence_of :hotel validates_presence_of :user validates_presence_of :credit_card validates_presence_of :credit_card_name validates_length_of :credit_card, :within => 16..16 validates_format_of :credit_card, :with => /^d*$/ validates_length_of :credit_card_name, :within => 3..70 def total hotel.price * nights end def nights ((checkout_date - checkin_date) / 1.day).round end def to_s quot;Booking(#{user},#{hotel})quot; end end Thursday, June 4, 2009
    • class CreateBookings < ActiveRecord::Migration def self.up create_table :bookings do |t| t.references :user t.references :hotel t.datetime :checkin t.datetime :checkout t.string :credit_card t.string :credit_card_name t.integer :credit_card_expiry_month t.integer :credit_card_expiry_year t.boolean :smoking t.integer :beds t.timestamps end end def self.down drop_table :bookings end end Thursday, June 4, 2009
    • 190 vs 40 Thursday, June 4, 2009
    • “Eles servem mais de 23 milhões de visitantes/mês. A conversão resultou em 20 mil linhas de Ruby em vez de 125 mil linhas de Java e, mais importante, facilitou a dificuldade que tinham em manutenção. Uma vez completo e otimizado, o site deles agora é mais rápido que antes. Eles também finalizaram a reescrita do sistema em apenas 3 meses com 4 desenvolvedores.” http://www.railsonwave.com/railsonwave/2008/6/4/yellowpages-com-migrates-to-rails Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • 11 mil classes! 46 só de coleções! Thursday, June 4, 2009
    • • Classes: • Modules: • Array • Enumerable • Hash • Comparable • Set • Sorted Set Thursday, June 4, 2009
    • 1.400 Classes: • classesArray • Modules: • • Enumerable • Hash • Comparable 6 de Set só • • Sorted coleções! Set Thursday, June 4, 2009
    • Ferramentas Ágeis Thursday, June 4, 2009
    • Gerenciamento Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Repositórios Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Integração Contínua Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Manutenção Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Open Source Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • describe BankAccount do before :each do @bank_account = BankAccount.new :balance => 250 end it quot;should not be validquot; do @bank_account.should be_valid end it quot;should transfer funds successfullyquot; do @bank_account.should_receive(:transfer) .with_args(:amount => 100) .and_return(true) @bank_account.execute_transaction(:amount => 100) @bank_account.balance.should == 150 end end Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Funcionalidade: Adição Para evitar erros bobos Como um péssimo matemático Eu quero saber como somar dois números Cenário: Adicionar dois números Dado que eu digitei 50 na calculadora E que eu digitei 70 na calculadora Quando eu aperto o botão de soma Então o resultado na calculadora deve ser 120 Thursday, June 4, 2009
    • Before do @calc = Calculadora.new end Dado /que eu digitei (d+) na calculadora/ do |n| @calc.push n.to_i end Quando 'eu aperto o botão de soma' do @result = @calc.soma end Então /o resultado na calculadora deve ser (d*)/ do |result| @result.should == result.to_i end Thursday, June 4, 2009
    • class SignupTest < ActionController::IntegrationTest def test_trial_account_sign_up visit home_path click_link quot;Sign upquot; fill_in quot;Emailquot;, :with => quot;good@example.comquot; select quot;Free accountquot; click_button quot;Registerquot; end end Thursday, June 4, 2009
    • rspec rspec.info cucumber cukes.info shoulda thoughtbot.com/projects/shoulda webrat github.com/brynary/webrat integrity integrityapp.com ZenTest zenspider.com Thursday, June 4, 2009
    • • plugins de Active Record • plugins de Views • plugins de Localização • CMS • Parsers • Autenticadores/Autorizadores Thursday, June 4, 2009
    • Comunidade Thursday, June 4, 2009
    • peepcode.com Geoffrey Thursday, June 4, 2009
    • railsenvy.com Jason e Gregg Thursday, June 4, 2009
    • railscasts.com Ryan Bates Thursday, June 4, 2009
    • guias.rubyonrails.pro.br Pratik Naik Thursday, June 4, 2009
    • rubylearning.org Satish Talim Thursday, June 4, 2009
    • rubyinside.com.br Peter Cooper Thursday, June 4, 2009
    • why.nomedojogo.com _why Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Thursday, June 4, 2009
    • Uma pulga ... Thursday, June 4, 2009
    • Standish Group - CHAOS Report 2009 Thursday, June 4, 2009
    • Fracasso Total 24% Sucesso 32% Fracasso Médio 44% Standish Group - CHAOS Report 2009 Thursday, June 4, 2009
    • Winston W. Royce - 1970 Thursday, June 4, 2009
    • “Eu acredito neste conceito mas a implementação descrita acima é arriscada e convida falhas.” Winston W. Royce - 1970 Thursday, June 4, 2009
    • “Eu acredito neste conceito mas a implementação descrita acima é arriscada e convida falhas.” Winston W. Royce - 1970 Thursday, June 4, 2009
    • “Eu acredito neste conceito mas a implementação descrita acima é arriscada e convida falhas.” Winston W. Royce - 1970 Thursday, June 4, 2009
    • Insanidade Thursday, June 4, 2009
    • “Querer resultados melhores fazendo a mesma coisa.” Thursday, June 4, 2009
    • “Think Different” Thursday, June 4, 2009
    • “Think Different” Thursday, June 4, 2009
    • Obrigado! akitaonrails.com Thursday, June 4, 2009