Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ruby on Rails it's ecosystem

Ruby on Rails it's ecosystem

Como surgiu o Ruby e o Rails.

83118406a790e21044557806ac5e44ad?s=128

Frankyston Lins Nogueira

March 30, 2019
Tweet

More Decks by Frankyston Lins Nogueira

Other Decks in Programming

Transcript

  1. @frankyston https://frankyston.dev Ruby on Rails and its ecosystem #phpcomrapadura @frankyston

  2. @frankyston https://frankyston.dev Dev @ Impulso Network Dev @ SmartFit @frankyston

    Frankyston Lins
  3. @frankyston https://frankyston.dev Comunidade de Devs Alocação de devs/projetos https://impulso.network/ @impulsonetwork

  4. @frankyston https://frankyston.dev Academias Inteligentes Treinos funcionais https://www.smartfit.com.br/ @SmartFitOficial

  5. @frankyston https://frankyston.dev Ruby on Rails and its ecosystem #phpcomrapadura @frankyston

  6. None
  7. @frankyston https://frankyston.dev Como surgiu o ruby?

  8. None
  9. @frankyston https://frankyston.dev Yukihiro "Matz" Matsumoto Japão em 1993 (1995) Perl

    script Pyton - POO Ocidente em 1999 (1.3)
  10. @frankyston https://frankyston.dev Linguagem interpretada

  11. @frankyston https://frankyston.dev Em ruby, tudo é objeto

  12. @frankyston https://frankyston.dev class Comida end refeicao = Comida.new refeicao.class #

    => Comida
  13. @frankyston https://frankyston.dev “PHP”.class String < Object 1.class Fixnum < Integer

  14. @frankyston https://frankyston.dev Trabalha com herança, classes, métodos, polimorfismo e escalonamento

  15. @frankyston https://frankyston.dev class MyClass include Enumerable end class MyClass2 <

    MyClass def my_method end end class MyClass self.my_method puts "Método de classe" end end class MyClass2 < MyClass private def my_method end end
  16. @frankyston https://frankyston.dev Sintaxe simples e de fácil compreensão

  17. @frankyston https://frankyston.dev if i > 10 puts "maior que 10"

    elseif i ==10 puts " igual a10" else puts "Menor que 10" end for a in (1..6) puts a end 6.times { |t| puts t }
  18. @frankyston https://frankyston.dev Tipagem dinâmica mas forte

  19. @frankyston https://frankyston.dev nome = "Frankyston" idade = 31 evento =

    "PHP com Rapadura" peso = "Segredo :)"
  20. @frankyston https://frankyston.dev sintaxe é enxuta, quase não havendo necessidade de

    colchetes e outros caracteres
  21. @frankyston https://frankyston.dev Blocos e Lambdas

  22. @frankyston https://frankyston.dev def chama_bloco yield('ola', 99) end chama_bloco {|str, num|

    puts str + ' ' + num.to_s} chama_bloco do |str, num| puts str + ' ' + num.to_s end
  23. @frankyston https://frankyston.dev array = [1, 2, 3, 5, 6, 7,

    8, 9, 10] array.each { |element| puts element } array.each_with_index do |index, element| puts "#{index} => #{element}” end
  24. @frankyston https://frankyston.dev RubyGems

  25. @frankyston https://frankyston.dev ruby '2.2.5' source 'https://rubygems.org' gem 'rails' gem 'pg'

    gem 'bootstrap-sass' gem ‘simple_form' group :production do gem 'lograge', '0.10.0' gem 'newrelic_rpm', '3.15.0.314' gem 'therubyracer', '0.12.2' end group :development, :test do gem 'pry-meta', '0.0.10' gem 'resque-mock', '0.1.1' gem 'rspec-rails', '3.4.2' gem 'rubocop', '0.50.0', require: false end
  26. @frankyston https://frankyston.dev Como surgiu o rails?

  27. None
  28. @frankyston https://frankyston.dev David “DHH” Heinemeier Hansson EUA em 2003 (2005)

    Perl script Pyton - POO Ocidente em 1999 (1.3)
  29. @frankyston https://frankyston.dev Framework Web quer dizer meta framework

  30. @frankyston https://frankyston.dev DRY - Don’t Repeat Yourself

  31. @frankyston https://frankyston.dev class User < ActiveRecord::Base def self.all_active where("state =

    ?", "active") end def self.all_inactive where("state = ?", "inactive") end def active? self.state == 'active' end def inactive? self.state == 'inactive' end end
  32. @frankyston https://frankyston.dev class User < ActiveRecord::Base
 
 STATES = ['active',

    'inactive']
 
 class <<self
 STATES.each do |state_name|
 define_method "all_#{state_name}" do
 where("state = ?", state_name)
 end
 end
 end
 
 STATES.each do |state_name|
 define_method "#{state_name}?" do
 self.state == state_name
 end
 end
 end
  33. @frankyston https://frankyston.dev MVC Model - View - Controller

  34. None
  35. @frankyston https://frankyston.dev Convention over configuration

  36. @frankyston https://frankyston.dev ORM Object Relational Mapper

  37. @frankyston https://frankyston.dev class Person < ActiveRecord::Base end person = Person.new

    person.name = "Frankyston" person.age = 20 person.save person = Person.find(1) puts person.name # Frankyston person = Person.find_by_age(30) puts person.name # Frankyston
  38. @frankyston https://frankyston.dev TDD/BDD

  39. @frankyston https://frankyston.dev require File.dirname(__FILE__) + '/../test_helper' class UserTest < Test::Unit::TestCase

    fixtures :users # Replace this with your real tests. def test_truth assert true end end
  40. @frankyston https://frankyston.dev class User < ActiveRecord::Base validates :firstname, presence: true

    validates :lastname, presence: true validates :email, presence: true, uniqueness: true end describe User do it "é válido quando nome, último nome e email estão presentes" do user = User.new( firstname: 'Bruce', lastname: 'Dickinson', email: 'bruce@ironmaiden.com' ) expect(user).to be_valid end end
  41. @frankyston https://frankyston.dev Agile (XP/Scrum)

  42. @frankyston https://frankyston.dev Cases

  43. None
  44. Legal, tem vaga pra trabalhar?

  45. None
  46. None
  47. None
  48. None
  49. None
  50. None
  51. None
  52. Pergunta?

  53. @frankyston https://frankyston.dev Obrigado! #phpcomrapadura @frankyston