• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Ruby Isn't Just About Rails
 

Ruby Isn't Just About Rails

on

  • 8,933 views

A whirlwind tour of the Rails-inspired Ruby ecosystem which has been frantically innovating for the past several years.

A whirlwind tour of the Rails-inspired Ruby ecosystem which has been frantically innovating for the past several years.

Statistics

Views

Total Views
8,933
Views on SlideShare
8,603
Embed Views
330

Actions

Likes
18
Downloads
203
Comments
0

13 Embeds 330

http://adam.blog.heroku.com 256
http://adam.heroku.com 30
http://www.slideshare.net 16
http://adamblog.heroku.com 7
http://ranchero.com 7
http://static.slideshare.net 4
http://lj-toys.com 2
http://paper.li 2
http://www.techgig.com 2
http://uptolife.blogspot.com 1
http://lcn-notes.blogspot.com 1
http://localhost:3000 1
http://adam.herokuapp.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Ruby Isn't Just About Rails Ruby Isn't Just About Rails Presentation Transcript

    • Ruby Isn’t Just About Rails Adam Wiggins Codemash 2009
    • ?
    • ? Ruby
    • You can’t sell a platform
    • You can’t sell a platform ...without a killer app.
    • A programming language is a platform
    • is the killer app Ruby for
    • Came for Rails, stayed for Ruby
    • An explosion of Ruby projects in the past 2 years
    • Let’s take a tour!
    • Rails is: ORM - ActiveRecord Web Layer - ActionPack Templating - ERB Test Framework - Test::Unit
    • ORM ActiveRecord
    • class CreatePosts < ActiveRecord::Migration create_table :posts do |t| t.string :title t.text :body t.datetime :created_at t.integer :post_id end end $ rake db:migrate class Post < ActiveRecord::Base has_many :comments end Post.find(:first, :conditions => [ quot;title = ?quot;, quot;First postquot; ])
    • ORM ActiveRecord DataMapper Sequel
    • Define schema in the code instead of the database http://datamapper.org
    • class Post include DataMapper::Resource property :id, Serial property :title, String property :body, Text property :created_at, DateTime has n, :comments end DataMapper.auto_upgrade! Post.first(:title => quot;First Postquot;)
    • Access a database with just hashes - or map models http://sequel.rubyforge.org
    • db = Sequel.connect('mysql://root@localhost/db') db.create_table :posts do primary_key :id varchar :title text :body datetime :created_at end db[:posts].filter(:title => quot;First Postquot;).first
    • Web Layer ActionPack
    • ActionController::Routing::Routes.draw do |map| map.resource :posts end class PostsController < ApplicationController def create @post = Post.create! params redirect_to(@post) end def show @post = Post.find(params[:id]) end end
    • Web Layer ActionPack Merb Sinatra
    • The hacker’s framework “No code is faster than no code” http://merbivore.org
    • Merb::Router.prepare do |router| resource :posts end class Posts < Merb::Controller def create @post = Post.create params redirect(url(:post, @post)) end def show @post = Post.find(params[:id]) display @post end end
    • use_orm :datamapper use_test :rspec use_template_engine :erb
    • Merb 2.0 == Rails 3.0
    • Sinatra The classy microframework for Ruby “Exposed simplicity instead of hidden complexity” http://sinatra.rubyforge.org
    • require 'rubygems' require 'sinatra' require 'lib/posts' post '/posts' post = Post.create! params redirect quot;/posts/#{post.id}quot; end get '/posts/:id' do @post = Post.find(params[:id]) erb :post end
    • Test Framework
    • Unit tests
    • TDD Test-Driven Development
    • BDD Behavior-Driven Development http://behaviour-driven.org
    • TATFT Test All The Darn Time
    • Test Framework Test::Unit
    • class PostTest < Test::Unit::TestCase def test_simple_slug post = Post.new :title => quot;First Postquot; assert_equal quot;first_postquot;, post.slug end def test_complex_slug post = Post.new :title => quot;My Post!quot;) assert_equal quot;my_postquot;, post.slug end end
    • RSpec Behavior-Driven Development http://rspec.info
    • describe Post do it quot;generates a url slug from the titlequot; do post = Post.new :title => quot;First Postquot; post.slug.should == quot;first_postquot; end it quot;drops punctuation from the url slugquot; do post = Post.new :title => quot;My Post!quot; post.slug.should == quot;my_postquot; end end
    • $ rake spec:doc Post - generates a url slug from the title - drops punctuation from the url slug
    • Templating Engine ERB
    • <div class=quot;postquot;> <h1><%= @post.title %></h1> <div class=quot;bodyquot;> <%= @post.body %> </div> </div>
    • Templating Engine ERB Haml
    • Haml Markup haiku http://haml.hamptoncatlin.com
    • .post %h1= @post.title .body= @post.body
    • Ties it all together http://rack.rubyforge.org
    • The End. http://adam.blog.heroku.com Adam Wiggins Codemash 2009