public
Description: Slides e scripts da palestra que fiz na Ceará On Rails
Homepage: http://tiago.zusee.com
Clone URL: git://github.com/bastos/onde-esta-meu-metodo.git
bastos (author)
Sat Nov 15 00:16:45 -0800 2008
commit  8d48c88d4a6f7f8fa7c652f3e243e2c597bb82c4
tree    e34b534b44e0730fa026781c2c7919ea9b1c74e0
parent  bf2d3a7145d1b20de3879856eca4f1135797ec59
onde-esta-meu-metodo / ceara_on_rails.rb
100644 273 lines (237 sloc) 5.097 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# -*- coding: utf-8 -*-
presentation :title => "Ruby - Onde está meu método? - Ceará on Rails" do
  slide do
    center do
      h1 "Onde está meu método?" , :style=>"margin-top:25%"
      h3 "Ruby, Mágica, Metaprogramação e diversão!"
    end
  end
 
  slide do
    h1 "Quem sou eu?"
    h2 "Tiago Bastos"
    h3 "%w{Estudante Desenvolvedor Python PHP Ruby *}.each {|a| puts a}"
  end
 
  slide do
    center {
      h1 "As coisas não precisam ser complicadas!"
      img :src => "assets/frustration.png", :alt=> "http://xkcd.com/457/"
    }
  end
 
  slide do
    h1 "Operadores são syntax sugar"
    code :type=>:ruby, :code => 'class Foo
def initialize
@fools = []
end
def << a
@fools << a
end
def * i
i.times { puts show_me_the_foo }
end
def show_me_the_foo
@fools.each {|foo| puts foo}
end
end'
  end
 
  slide do
    h1 "Exemplo"
    code :type => :ruby, :code => 'foo_box = Foo.new
foo_box << "LOL"
foo_box << "OMG"
foo_box.show_me_the_foo
foo_box * 10'
  end
 
  slide do
    h1 "Monkey Patching"
    h3 "Nada precisa ser tão difícil de se abrir, nem mesmo classes"
    code :type=>:ruby, :code => 'class String
def lolize
"LOL #{self} LOL"
end
end
 
"Ruby!".lolize
'
  end
 
  slide do
    h1 "Mixins"
    h2 ""
 code :type=>:ruby, :code => 'module Rubist;end
module Snaker;end
module Sysadmin;end
module JabbaTheHutt;end
class Programmer;end
 
class Me < Programmer
include Snaker
include Rubist
end
class You < Programmer
include Snaker
include Sysadmin
end
class UnHappy < Programmer
include JabbaTheHutt
end
'
  end
 
  slide do
    h1 "Blocos!"
    code :type=>:ruby, :code => 'LoLCat do
say "I haz Rubyz"
end'
  end
 
slide do
  h1 "Sinatra!"
  code :type=>:ruby, :code => "require 'sinatra'
 
get '/about' do
\"Sinatra, um minimalista webframework usando blocos!\"
end
"
end
 
  slide do
    h1 "yield"
    h3 "Blocos possuem o contexto de onde foram criadas"
    code :type => :ruby, :code => 'class Cat
def initialize
yield
end
def say(str)
puts str
end
end'
    p "undefined method `say' for main:Object (NoMethodError)"
  end
 
  slide do
    h1 "eval is not evil"
    h3 "Blocos + eval = DSL"
    code :type=>:ruby, :code => 'class Cat
def initialize(&block)
instance_eval(&block)
end
def say(str)
puts str
end
end
'
  end
 
  slide do
    h1 "Domain Specific Language"
    h3 "Blocos + eval = DSL"
    center { code :type=>:ruby, :code => 'Cat.new { say "Eval is not evil!" }' }
  end
 
  slide do
    h1 "Estes slides foram feitos com uma DSL: Gary"
    code :type=>:ruby, :code => 'presentation :title => "My First Presentation" do
slide do
h1 "Just a test"
code "def a; a+a;end"
end
 
slide do
h1 "Bye"
center { h3 "Bye people!" }
end
end
'
  end
 
  slide do
  h1 "BOT"
  code :type=>:ruby, :code => 'config do |c|
c.nick = "echo_bot"
c.server = "irc.freenode.net"
c.port = 6667
end
on :connect do
join "#Awesome_Channel"
end
on :channel, /.*/ do
msg channel, message
end'
  end
 
  slide do
    h1 "Onde está meu método!?"
    code :type=>:ruby, :code => 'class Cat
def method_missing(m, *args, &block)
if m.to_s =~/^gimme_(.+)_burgerz/
x = m.to_s.match(/^gimme_(.+)_burgerz/)[1]
puts "I Haz #{x.capitalize} burgerz"
else
super
end
end
end
 
Cat.new.gimme_ten_burgers
'
  end
 
  slide do
    h1 "I Haz Ten burgerz", :style=>"margin-top:30%"
  end
 
  slide do
    h1 "Lindo!", :style=>"margin-top:25%"
    h1 "Mas e ai?", :style=>"margin-top:25%"
  end
 
  slide do
    h1 "Ai que você entende o ActiveRecord!"
    code :type=>:ruby, :code => "Dummy.find_by_name('Tiago')"
    code :type=>:ruby, :code => "Dummy.find_by_name_and_age('Tiago', 22)"
  end
 
  slide do
    h1 "Ei Classe quero o fale"
    code :type=>:ruby, :code => "class DHH
def fale
puts 'FUCK YOU'
end
def exemplo
send(:fale)
end
end
 
DHH.new.exemplo
"
  end
 
  slide do
    h1 "Podemos simplesmente criar um alias para o método antigo"
    h2 "E redeclarar"
    code :type => :ruby, :code => 'class DHH
alias_method :antigo, :exemplo
def exemplo
puts ":D"
end
end
# O novo
DHH.new.exemplo
# O antigo!
DHH.new.old
'
  
  end
 
  slide do
    h1 "Ruby é divertido!"
    ul do
     li "Escreva DSL nele"
     li "Funções anônimas"
     li "Sintaxe Natural"
     li "Rails, Merb, Sinatra, Markaby, Grit, Rake..."
    end
  end
  
  slide do
    center { img :src=>"assets/vodka.jpg" }
  end
 
  slide :style=>"background-image:url(assets/mafia.jpg);
background-repeat: no-repeat;
background-attachment:fixed;
background-position: top center
" do
  h1 "Perguntas?"
  end
  
  slide do
    h1 "Obrigado!"
    div do
      p "Links:"
      ul do
        li "Meus projetos OpenSource http://github.com/bastos"
        li "Gary Presentation Builder http://github.com/bastos/gary"
        li "Frustation by http://xkcd.com/457/"
        li "Sinatra http://github.com/bmizerany/sinatra/tree/master"
        li "Isaac http://github.com/ichverstehe/isaac"
      end
    end
  end
end