SINATRA
SEQUEL
W2TAGS
Work: SKYEIGHT (S8)
➢



At-Work: monorails/NET 2.0
➢



Outside-Work: ruby/javascript
➢
Sinatra
don't do
 Magic
Sinatra
 basic Concept

Throw URL
     DO Some Stuff
require 'rubygems'
require 'sinatra'

get '/' do 'Hello World' end

Throw URL
          DO Some Stuff
require 'rubygems'
require 'sinatra'

get '/' do 'Hello World' end
            DO Some Stuff
Throw
              Controlle...
require 'rubygems'
require 'sinatra'

get '/' do
 @data = 'Hello World'
 erb :index                index.erb

end         ...
Simply
Sinatra
Sequel
require 'rubygems'
require 'sequel'
require 'sinatra'
DB = Sequel.connect(....)
class Entry < Sequel::Model
end
get '/' do...
require 'rubygems'
require 'sequel'
require 'sinatra'
DB = Sequel.connect(....)

                              Model
class...
require 'rubygems'
require 'sequel'
require 'sinatra'
DB = Sequel.connect(....)

                              Model
class...
require 'rubygems'
require 'sequel'
require 'sinatra'
DB = Sequel.connect(....)

                              Model
class...
require 'rubygems'
require 'sequel'
require 'sinatra'
DB = Sequel.connect(....)

                              Model
class...
MVC - R
require 'rubygems'
require 'sequel'
require 'sinatra'              Some Stuff
DB = Sequel.connect(....)

         ...
Simply
Sinatra
Sequel
W2Tags
require 'rubygems'
require 'sequel'
require 'sinatra'                                 index.w2erb
require 'w2tags'
       ...
W2Tags
   index.w2erb          index.erb

%h1 Entry List <h1>Entry List</h1>
               <% @recs.each do |r| %>
-each ...
Sinatra
 crud
Entry
Action Method 1            Method 2
 List get '/entries'
 New get '/entries/new'    post '/entries/new...
Sinatra                    get '/entries' do
                                                    1
                       ...
Sinatra crud
Display   Action
Sinatra
Simply
Magic
1     2      3



    W2Tags
    Simply
    Magic
Auto Generate
                1
Auto Generate
                1
Auto Generate
                2
Auto Generate
                3
Resources
Sinatra : http:/github.com/bmizerany/sinatra
Sequel : http:/github.com/jeremyevans/sequel
W2Tags : http:/github....
rack


            Ec = New EventContex
          Ec.request = New Rack::Request
        ●


          Ec.response = New R...
erb.hot
sinatra_table.hot
                                          5
                                                   11
      ...
sinatra_form2.hot
Sequel – DB Toolkit
DB[:tabel] #Dataset chainable method, return:Dataset
where, filter, exclude, order, reverse_order, uni...
fast prototyping with sinatra sequel w2tags
fast prototyping with sinatra sequel w2tags
fast prototyping with sinatra sequel w2tags
fast prototyping with sinatra sequel w2tags
Upcoming SlideShare
Loading in …5
×

fast prototyping with sinatra sequel w2tags

4,334 views

Published on

fast prototyping with sinatra sequel w2tags, when you need to prototype sometime it need framework that works simple complete and less typing, w2tags use HAML like syntax to speed up the prototyping

Published in: Technology, Business
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,334
On SlideShare
0
From Embeds
0
Number of Embeds
927
Actions
Shares
0
Downloads
44
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

fast prototyping with sinatra sequel w2tags

  1. 1. SINATRA SEQUEL W2TAGS
  2. 2. Work: SKYEIGHT (S8) ➢ At-Work: monorails/NET 2.0 ➢ Outside-Work: ruby/javascript ➢
  3. 3. Sinatra don't do Magic
  4. 4. Sinatra basic Concept Throw URL DO Some Stuff
  5. 5. require 'rubygems' require 'sinatra' get '/' do 'Hello World' end Throw URL DO Some Stuff
  6. 6. require 'rubygems' require 'sinatra' get '/' do 'Hello World' end DO Some Stuff Throw Controller URL Return string
  7. 7. require 'rubygems' require 'sinatra' get '/' do @data = 'Hello World' erb :index index.erb end <%= @data %> View URL Controller Return string
  8. 8. Simply Sinatra Sequel
  9. 9. require 'rubygems' require 'sequel' require 'sinatra' DB = Sequel.connect(....) class Entry < Sequel::Model end get '/' do @recs = Entry.all erb :index index.erb end <h1>Entry List</h1> <% @recs.each do |r| %> <%= r.title %> <br/> <% end %>
  10. 10. require 'rubygems' require 'sequel' require 'sinatra' DB = Sequel.connect(....) Model class Entry < Sequel::Model end get '/' do @recs = Entry.all erb :index index.erb end <h1>Entry List</h1> <% @recs.each do |r| %> <%= r.title %> <br/> <% end %>
  11. 11. require 'rubygems' require 'sequel' require 'sinatra' DB = Sequel.connect(....) Model class Entry < Sequel::Model end get '/' do View @recs = Entry.all erb :index index.erb end <h1>Entry List</h1> <% @recs.each do |r| %> <%= r.title %> <br/> <% end %>
  12. 12. require 'rubygems' require 'sequel' require 'sinatra' DB = Sequel.connect(....) Model class Entry < Sequel::Model end get '/' do View @recs = Entry.all erb :index index.erb end <h1>Entry List</h1> <% @recs.each do |r| %> Controller <%= r.title %> <br/> <% end %>
  13. 13. require 'rubygems' require 'sequel' require 'sinatra' DB = Sequel.connect(....) Model class Entry < Sequel::Model end get '/' do View @recs = Entry.all erb :index index.erb end <h1>Entry List</h1> R <% @recs.each do |r| %> Controller <%= r.title %> ou <br/> te <% end %>
  14. 14. MVC - R require 'rubygems' require 'sequel' require 'sinatra' Some Stuff DB = Sequel.connect(....) Model class Entry < Sequel::Model end get '/' do View @recs = Entry.all erb :index index.erb end <h1>Entry List</h1> R <% @recs.each do |r| %> Controller <%= r.title %> ou <br/> te <% end %>
  15. 15. Simply Sinatra Sequel W2Tags
  16. 16. require 'rubygems' require 'sequel' require 'sinatra' index.w2erb require 'w2tags' %h1 Entry List require 'w2tags/sinatra_hook' Auto Generate Auto Generate -each @recs;r = r.title DB = Sequel.connect(....) %br/ class Entry < Sequel::Model end index.erb get '/' do @recs = Entry.all <h1>Entry List</h1> erb :index <% @recs.each do |r| %> end <%= r.title %> <br/> <% end %>
  17. 17. W2Tags index.w2erb index.erb %h1 Entry List <h1>Entry List</h1> <% @recs.each do |r| %> -each @recs;r <%= r.title %> = r.title <br/> %br/ <% end %> See the flow clearly
  18. 18. Sinatra crud Entry Action Method 1 Method 2 List get '/entries' New get '/entries/new' post '/entries/new' Edit get '/entries/:id' put '/entries/:id' Delete delete '/entries/:id'
  19. 19. Sinatra get '/entries' do 1 erb :entries_index crud get '/entries/new' do 2 erb :entries_new Entry post '/entries/new' do redirect '/entries' Action Method 1 Method 2 do get '/entries/:id' 3 List get '/entries' erb :entries_edit New get '/entries/new'put '/entries/:id' do post '/entries/new' redirect '/entries' Edit get '/entries/:id' delete '/entries/:id' do put '/entries/:id' Delete delete '/entries' redirect '/entries/:id'
  20. 20. Sinatra crud Display Action
  21. 21. Sinatra Simply Magic
  22. 22. 1 2 3 W2Tags Simply Magic
  23. 23. Auto Generate 1
  24. 24. Auto Generate 1
  25. 25. Auto Generate 2
  26. 26. Auto Generate 3
  27. 27. Resources Sinatra : http:/github.com/bmizerany/sinatra Sequel : http:/github.com/jeremyevans/sequel W2Tags : http:/github.com/wharsojo/w2tags Demo : http:/github.com/wharsojo/demo_sinatra Thank you! slideshare.com/wharsojo...
  28. 28. rack Ec = New EventContex Ec.request = New Rack::Request ● Ec.response = New Rack::Response ● Array of code-block before Sinatra.application.filters all will be When error do Sinatra.application.error execute or select .errors Lookup Event Sinatra.application.events (post,delete,put,get,head) or do/raise error not_found Array of code-block Code-block/render Execute first match inside instance object of will be Render EventContext execute W2Tags/Erb ● Haml, Sass ● Builder wh/id-ruby ●
  29. 29. erb.hot
  30. 30. sinatra_table.hot 5 11 1 6 2 3 1 11 1 8 2 4 7 5 9 4 3 12 6 12 7 8 9 10 10
  31. 31. sinatra_form2.hot
  32. 32. Sequel – DB Toolkit DB[:tabel] #Dataset chainable method, return:Dataset where, filter, exclude, order, reverse_order, uniq, limit, paginate, join, inner_join, left_outer_join, DB[:tabel]...all #records (Array of record) DB[:tabel]...first #record (Hash of field_name / value) DB[:tabel]...order(:field).last #record DB[:tabel]...map :field #Array of value DB[:tabel]...[Integer / Hash] Integer=> ...limit(Integer).all Hash => ...where(Hash ).first DB[:tabel]...[ 2] #eq DB[:tabel].limit( 2).all DB[:tabel]...[:id=>2] #eq DB[:tabel].where(:id=>2).first #Summarizing: result Number ...count, max, min, avg, sum #Manipulation DB[:tabel]...delete, ...update, insert, <<

×