semac 2011 - apresentando ruby e ruby on rails

Download SEMAC 2011 - Apresentando Ruby e Ruby on Rails

Post on 15-Jan-2015

1.001 views

Category:

Technology

1 download

Embed Size (px)

DESCRIPTION

Apresentação sobre Ruby e Ruby on Rails para o SEMAC da UNESP de São José do Rio Preto.

TRANSCRIPT

  • 1. Apresentando Rubye Ruby on Rails a apresentao j vai comear ...

2. Apresentando Rubye Ruby on Rails 3. Fabio Akitawww.akitaonrails.com@akitaonrails 4. Fabio Akitawww.akitaonrails.com@akitaonrails1990 5. Ruby 1994 (linguagem)Ruby on Rails2004 (framework web) 6. 1.8.7Ruby1.9.21.9.3-dev 2.3.11Ruby on Rails 3.0.73.1-RC1 7. 1.8.7Ruby1.9.21.9.3-dev 2.3.11Ruby on Rails 3.0.73.1-RC1 8. 1.8.7Ruby1.9.21.9.3-dev 2.3.11Ruby on Rails 3.0.73.1-RC1 9. Orientao a Objetos 10. UMLDiagrama de Classes 11. !? UMLDiagrama de Classes 12. !? UMLDiagrama de ClassesPOO? 13. !? UMLDiagrama de Classes POC! 14. Alan KayA melhor maneirade prever o futuro invent-lo 15. Alan KayEu inventei o termoOrientao a Objetose posso dizer queeu no tinha C++ em mente 16. Alan KayEu inventei o termoOrientao a Objetose posso dizer queeu no tinha C++ em mente 17. Hello World 18. Hello World 19. #include int main(){ printf("Hello worldn"); return 0;} 20. class HelloWorldApp {public static void main(String[] args) {System.out.println("Hello World!");}} 21. Transcript show: Hello, world!. 22. puts Hello World 23. Procedures?? 24. Procedures?? 25. puts Hello World=> Hello World 26. puts Hello World=> Hello WorldKernel.puts Hello World=> Hello World 27. puts Hello World=> Hello WorldKernel.puts Hello World=> Hello Worldputs self.class 28. puts Hello World=> Hello WorldKernel.puts Hello World=> Hello World thisputs self.class 29. puts Hello World=> Hello WorldKernel.puts Hello World=> Hello World thisputs self.class => Object 30. puts Hello World=> Hello WorldKernel.puts Hello World=> Hello World thisputs self.class => ObjectObject.ancestors => [Object, Kernel, BasicObject] 31. puts Hello World=> Hello WorldKernel.puts Hello World=> Hello World thisputs self.class => ObjectObject.ancestors => [Object, Kernel, BasicObject] 32. "teste".class => String 33. "teste".class => String1.class 34. "teste".class => String1.class => Fixnum 35. "teste".class => String1.class => Fixnumtrue.class => TrueClass 36. "teste".class => String1.class => Fixnumtrue.class => TrueClassnil 37. "teste".class => String1.class => Fixnumtrue.class => TrueClassnil.class => NilClass 38. "teste".class => String1.class => Fixnumtrue.class => TrueClassNullPointerException!?nil.class => NilClass 39. "teste".class => String1.class => Fixnumtrue.class => TrueClassnil.class => NilClass 40. 1 + 2 41. 1 + 21.+(2) 42. def hello(name)return "Hello, " + nameendputs hello("Fabio") => "Hello, Fabio" 43. def hello(name)return "Hello, " + nameendputs hello "Fabio" => "Hello, Fabio" 44. def hello(name)return "Hello, " + nameendputs hello "Fabio" => "Hello, Fabio"ParntesesOpcionais 45. def hello(name)"Hello, " + nameendputs hello "Fabio" => "Hello, Fabio" 46. def hello(name)"Hello, " + nameendputs hello "Fabio" return => "Hello, Fabio" automtico 47. def hello(name)"Hello, #{name}"endputs hello "Fabio" => "Hello, Fabio" 48. def hello(name)"Hello, #{name}"endputs hello "Fabio" => "Hello, Fabio" Interpolao 49. class Stringdef hello(name)"#{self}, #{name}"endend 50. class Stringdef hello(name)"#{self}, #{name}"endend"Hello".hello "Fabio" => "Hello, Fabio" 51. class Stringdef hello(name)"#{self}, #{name}"endend"Hello".hello "Fabio"Classes => "Hello, Fabio" Abertas! 52. module Legaldef bu!"Buuu!"endendclass Stringinclude Legalendclass Fixnuminclude Legalend"foo".bu! => "Buuu!"10.bu! => "Buuu!" 53. module Legaldef bu!"Buuu!"endendclass Stringinclude Legalendclass Fixnuminclude Legalend"foo".bu! => "Buuu!"10.bu! => "Buuu!" 54. module Legaldef bu!"Buuu!"endendclass Stringinclude Legalendclass FixnumModuleinclude LegalendMixin"foo".bu! => "Buuu!"10.bu! => "Buuu!" 55. module Legaldef bu!"Buuu!"endendclass Stringinclude Legalendclass FixnumModuleinclude LegalendMixin"foo".bu! => "Buuu!"10.bu! => "Buuu!" 56. module Legaldef bu!"Buuu!"endendclass Stringinclude Legalendclass FixnumModuleinclude LegalendMixin"foo".bu! => "Buuu!"10.bu! => "Buuu!" 57. require rubygemsrequire active_supportTime.now + 1.day => 2011-05-18 11:44:20 -0300Time.now + 1.week => 2011-05-24 11:44:24 -0300(1.gigabyte - 100.megabytes) / 1.megabyte => 924 58. require rubygemsrequire active_supportTime.now + 1.day => 2011-05-18 11:44:20 -0300Time.now + 1.week => 2011-05-24 11:44:24 -0300(1.gigabyte - 100.megabytes) / 1.megabyte => 924 59. require rubygemsrequire active_supportTime.now + 1.day => 2011-05-18 11:44:20 -0300Time.now + 1.week => 2011-05-24 11:44:24 -0300(1.gigabyte - 100.megabytes) / 1.megabyte => 924 60. require rubygemsrequire active_supportTime.now + 1.day => 2011-05-18 11:44:20 -0300Time.now + 1.week => 2011-05-24 11:44:24 -0300(1.gigabyte - 100.megabytes) / 1.megabyte => 924 61. list = [1,2,3,4,5]soma = 0for i in listsoma += iendputs soma => 15 62. list = [1,2,3,4,5]soma = 0for i in listsoma += iendputs soma => 15 63. list = [1,2,3,4,5]soma = 0for i in listsoma += iendputs soma => 15 64. list = [1,2,3,4,5]soma = list.inject(0) { |total, i| total += i }puts soma => 15 65. list = [1,2,3,4,5]soma = list.inject(0) { |total, i| total += i }puts soma => 15 66. list = [1,2,3,4,5]soma = list.inject(0) { |total, i| total += i }puts soma => 15 67. list = [1,2,3,4,5]soma = list.inject(0) { |total, i| total += i }puts soma => 15 68. list = [1,2,3,4,5]soma = list.inject(0) { |total, i| total += i }puts soma => 15 69. list = [1,2,3,4,5]soma = list.inject(0) do |total, i|total += iendputs soma => 15 70. list = [1,2,3,4,5]soma = list.inject(0) do |total, i|total += iendputs somaAnonymous => 15 Inner Class? 71. list = [1,2,3,4,5]soma = list.inject(0) do |total, i|total += iendputs soma => 15 72. list = [1,2,3,4,5]soma = list.inject(0) do |total, i|total += iendputs soma => 15CLOSURE! 73. class Foodef method_missing(method)print "#{method} called"endendFoo.new.bar => "bar called"Foo.new.send(:bar) => "bar called" 74. class Foodef method_missing(method)print "#{method} called"endendFoo.new.bar => "bar called"Foo.new.send(:bar) => "bar called" 75. class Foodef method_missing(method)print "#{method} called"endendFoo.new.bar => "bar called"Foo.new.send(:bar) => "bar called"Messages! 76. World!20060101 77. require builderxml = Builder::XmlMarkup.newxml.instruct! :xml xml.Hello "World!" World!xml.date doxml.year "2006"2006xml.month "01" 01xml.day "01" 01end 78. require builderxml = Builder::XmlMarkup.newxml.instruct! :xml xml.Hello "World!" World!xml.date doxml.year "2006"2006xml.month "01" 01xml.day "01" 01end 79. require builderxml = Builder::XmlMarkup.newxml.instruct! :xml xml.Hello "World!" World!xml.date doxml.year "2006"2006xml.month "01" 01xml.day "01" 01end 80. require builderxml = Builder::XmlMarkup.newxml.instruct! :xml xml.Hello "World!" World!xml.date doxml.year "2006"2006xml.month "01" 01xml.day "01" 01end 81. require builderxml = Builder::XmlMarkup.newxml.instruct! :xml xml.Hello "World!" World!xml.date doxml.year "2006"2006xml.month "01" 01xml.day "01" 01end 82. require rubygemsrequire mechanizea = Mechanize.new do |agent|agent.user_agent_alias = Mac Safarienda.get(http://google.com/) do |page|search_result = page.form_with(:name => f) do |search|search.q = Hello worldend.submitsearch_result.links.each do |link|puts link.textendend 83. require rubygemsrequire mechanizea = Mechanize.new do |agent|agent.user_agent_alias = Mac Safarienda.get(http://google.com/) do |page|search_result = page.form_with(:name => f) do |search|search.q = Hello worldend.submitsearch_result.links.each do |link|puts link.textendend 84. require rubygemsrequire mechanizea = Mechanize.new do |agent|agent.user_agent_alias = Mac Safarienda.get(http://google.com/) do |page|search_result = page.form_with(:name => f) do |search|search.q = Hello worldend.submitsearch_result.links.each do |link|puts link.textendend 85. require rubygemsrequire mechanizea = Mechanize.new do |agent|agent.user_agent_alias = Mac Safarienda.get(http://google.com/) do |page|search_result = page.form_with(:name => f) do |search|search.q = Hello worldend.submitsearch_result.links.each do |link|puts link.textendend 86. class Twitterinclude HTTPartybase_uri twitter.combasic_auth username, passwordendTwitter.post(/statuses/update.json,:query => { :status => "Its an HTTParty and everyone is invited!"}) 87. class Twitterinclude HTTPartybase_uri twitter.combasic_auth username, passwordendTwitter.post(/statuses/update.json,:query => { :status => "Its an HTTParty and everyone is invited!"}) 88. 19901995PostScript level 2PostScript level 31992 september 11, 1996 OO Forth Forth1987986ect Logo Tcl Tcl/Tk1986 mid 1988 end 1988 Fortran 90 ISO1991AA+ 1988 1992 JKMPS (FIPS) 1990 MUMPS ISO 1996M M ANSIOpen M 1986 1992 1994dec 8, 1995dec 11, 1995 Modula 3Delphi1988march 2, 1995 APL96 1996ABC1987 PythonBorland 1991 Object Pascal 1985 Turbo PascalANSI Rexx fOberon Oberon-2 1987 1991Modula-2 ISOAda 95 june 1, 1996Ada ISO 19871995NetRexx 1991ANSI CISO CISO C (C89)(C90)(C95)1989 december 15, 1990april 1, 1996JScripmay 19Cmm LiveScript JavaScript1992 1995december 1995 ARM C++ 1989Oak Java 1 june 1991may 23, 1995 Ruby february 24, 1993 Ruby 0.95 december 1995 Self Self 4.0EiffelEiffel 2Eiffel 3 july 10, 1995Eiffel 41986 19881993december 11, 1996PHP/FI 1995 Sather 0.1 Sather 1.0Sather 1.1 june 1991mid-1994september 1995 Perl 1.000Perl 2.000Perl 3.000 Perl 4.000 Perl 5.000ecember 18, 1987january 5, 1988 october 18, 1989 march 21, 1991 october 18, 1994 Objective Caml1996sic 1.0QuickBasic 4.5 MS Basic PDS 7.0MS PDS 7.1 Visual Basic 3.0Visual Basic 4.0 1989Visual Basic 1.0 Visual Basic 2.051988 1990may 20, 1991march 1992 june 93 september 1995Clos1989Common L