an introduction to ruby web frameworks
TRANSCRIPT
![Page 1: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/1.jpg)
An Introduction to Ruby Web Frameworks
Ryan Carmelo BrionesServer Monkey / Code Samurai, Edgecase, LLC
![Page 2: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/2.jpg)
Commanding Your SSH Universe with Capistrano
Thurs 5/24 5:20 PM in Portland 251
![Page 3: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/3.jpg)
An Introduction to Ruby Web Frameworks
Ryan Carmelo BrionesServer Monkey / Code Samurai, Edgecase, LLC
![Page 4: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/4.jpg)
0 to Ruby in 45 minutes
![Page 5: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/5.jpg)
Define: Framework
![Page 6: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/6.jpg)
FrameworkResuable
![Page 7: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/7.jpg)
FrameworkEncapsulated
![Page 8: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/8.jpg)
FrameworkDomain Specific!
![Page 9: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/9.jpg)
Why Ruby?
![Page 10: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/10.jpg)
RubyReady to lead Object Oriented since day 1
User.all.reject { |user| user.admin? }.each do |user| user.expire 1.days.from_now user.saveend
![Page 11: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/11.jpg)
RubyFine-grained Control
User.all.reject { |user| user.admin? }.each do |user| user.expire 1.days.from_now user.saveend
![Page 12: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/12.jpg)
RubyPromotes Beautiful Code
User.all.reject { |user| user.admin? }.each do |user| user.expire 1.days.from_now user.saveend
![Page 13: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/13.jpg)
RubyMRI has performance issues
![Page 14: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/14.jpg)
RubyLibraries?
![Page 15: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/15.jpg)
RubyAlternative Implementations
YARV(aka Ruby 1.9)
![Page 16: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/16.jpg)
Ruby Frameworks
![Page 17: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/17.jpg)
Rack
![Page 18: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/18.jpg)
RackResponding to the #call
class HelloWorld def call(env) [200, {"Content-Type" => "text/plain"}, ["Hello world!"]] endend
![Page 19: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/19.jpg)
RackLet the handlers do the
work
![Page 20: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/20.jpg)
Ruby on Rails
![Page 21: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/21.jpg)
RailsCode Generation
![Page 22: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/22.jpg)
RailsCode Generation
![Page 23: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/23.jpg)
RailsConvention over Configuration
• Naming Conventions• conference_registrations• conference_registration.rb• ConferenceRegistration < ActiveRecord::Base
• Load Paths
![Page 24: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/24.jpg)
• Naming Conventions• conference_registrations• conference_registration.rb• ConferenceRegistration < ActiveRecord::Base
• Load Paths
RailsConvention over Configuration
Opinionated Software / “The Golden Path”
![Page 25: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/25.jpg)
RailsDomain Specific Languages
# models
class Publication < ActiveRecord::Basehas_many :subscriptionshas_many :subscribers, :through => :subscriptions,
:class_name => ‘User’end
# rails router
ActionController::Routing::Routes.draw do |map|map.resources :publications, :has_many => [:subscriptions]map.resources :users
map.login ‘/login’, :controller => ‘sessions’, :action => ‘login’map.connect ‘:controller/:action/:id’
end
![Page 26: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/26.jpg)
RailsFirst-class Testing
![Page 27: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/27.jpg)
RailsToo much magic
![Page 28: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/28.jpg)
RailsMoving to fast?
![Page 29: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/29.jpg)
Merb
![Page 30: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/30.jpg)
MerbAll you need, nil you don’t
![Page 31: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/31.jpg)
MerbEschews “magic”
![Page 32: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/32.jpg)
MerbChallenge: Benchmark and
Profile
![Page 33: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/33.jpg)
MerbFlexible == Unproductive?
![Page 34: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/34.jpg)
MerbResources / Documentation
![Page 35: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/35.jpg)
Camping
![Page 36: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/36.jpg)
CampingAll in one file / Rapid Prototypes#!/usr/bin/env rubyrequire ‘rubygems’require ‘camping’
Camping.goes :Foo
module Foo::Controllersclass Home < R ‘/’def getrender :home_index
endend
end
module Foo::Viewsdef home_indexh1 ‘Home’
endend
![Page 37: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/37.jpg)
CampingAll in one file / Rapid Prototypes#!/usr/bin/env rubyrequire ‘rubygems’require ‘camping’
Camping.goes :Foo
module Foo::Controllersclass Home < R ‘/’def getrender :home_index
endend
end
module Foo::Viewsdef home_indexh1 ‘Home’
endend
# setup app namespace
![Page 38: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/38.jpg)
CampingAll in one file / Rapid Prototypes#!/usr/bin/env rubyrequire ‘rubygems’require ‘camping’
Camping.goes :Foo
module Foo::Controllersclass Home < R ‘/’def getrender :home_index
endend
end
module Foo::Viewsdef home_indexh1 ‘Home’
endend
# route request to http://app/
# setup app namespace
![Page 39: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/39.jpg)
CampingAll in one file / Rapid Prototypes#!/usr/bin/env rubyrequire ‘rubygems’require ‘camping’
Camping.goes :Foo
module Foo::Controllersclass Home < R ‘/’def getrender :home_index
endend
end
module Foo::Viewsdef home_indexh1 ‘Home’
endend
# route request to http://app/# route get requests to http://app/
# setup app namespace
![Page 40: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/40.jpg)
CampingAll in one file / Rapid Prototypes#!/usr/bin/env rubyrequire ‘rubygems’require ‘camping’
Camping.goes :Foo
module Foo::Controllersclass Home < R ‘/’def getrender :home_index
endend
end
module Foo::Viewsdef home_indexh1 ‘Home’
endend
# route request to http://app/# route get requests to http://app/# render home_index view
# setup app namespace
![Page 41: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/41.jpg)
CampingSmall apps, Many mounts
![Page 42: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/42.jpg)
CampingStructure translates to other
popular MVCs
![Page 43: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/43.jpg)
CampingNo standard test framework
![Page 44: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/44.jpg)
Sinatra
![Page 45: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/45.jpg)
SinatraSimple. Fast. Effective.
#!/usr/bin/env rubyrequire ‘rubygems’require ‘sinatra’
get ‘/’ do“Hello, World!”
end
![Page 46: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/46.jpg)
Extra Credit
IOWARamazeWavesMavericMackNitroWuby
![Page 47: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/47.jpg)
Questions?
![Page 48: An Introduction to Ruby Web Frameworks](https://reader035.vdocuments.net/reader035/viewer/2022071600/613d3024736caf36b75a5c52/html5/thumbnails/48.jpg)
Thank You
http://brionesandco.com/ryanbrioneshttp://theedgecase.com
http://blog.theedgecase.com