Skip to content

Instantly share code, notes, and snippets.

View nmerouze's full-sized avatar

Nicolas Mérouze nmerouze

View GitHub Profile
#!/bin/sh
# Create a bleeding edge Merb application with DataMapper.
curl -L http://merbivore.com/merb.thor > merb.thor
thor merb:tasks:setup
bin/thor merb:edge --install
bin/thor merb:edge:plugins --install
bin/thor merb:edge:dm_core --install
bin/thor merb:edge:dm_more --install
bin/thor merb:source:install dm-more/merb_datamapper
#!/bin/sh
# Update Thor script, sources and gems.
bin/thor merb:tasks:update
bin/thor merb:source:refresh
bin/thor merb:edge --install
bin/thor merb:edge:plugins --install
bin/thor merb:edge:dm_core --install
bin/thor merb:edge:dm_more --install
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe PostsController do
integrate_views
describe 'GET /index' do
before(:each) do
get :index
class User
include DataMapper::Resource
property :id, Serial
property :email, String, :format=> :email_address
property :email_confirmation, String, :format=> :email_address
validates_is_confirmed :email
end
### Rails Edge
$:.unshift File.join(File.dirname(__FILE__), 'rack-mount/lib')
$:.unshift File.join(File.dirname(__FILE__), 'rails/activesupport/lib')
$:.unshift File.join(File.dirname(__FILE__), 'rails/actionpack/lib')
require 'active_support'
require 'action_view'
require 'action_view/base'
require 'action_controller'
require 'action_controller/abstract'
### Rails 3
$:.unshift File.join(File.dirname(__FILE__), 'rack-router/lib')
$:.unshift File.join(File.dirname(__FILE__), 'rack-mount/lib')
$:.unshift File.join(File.dirname(__FILE__), 'rails/activesupport/lib')
$:.unshift File.join(File.dirname(__FILE__), 'rails/actionpack/lib')
require 'active_support'
require 'action_view'
require 'action_view/base'
# http://github.com/giraffesoft/resource_controller/tree/master
### Exemple
class MoviesController < ResourceController::Base
end
# MongoDB Java driver vs Ruby Driver with JRuby 1.3.1
#
# user system total real
# java driver (find) 2.266000 0.000000 2.266000 ( 2.266000)
# ruby driver (find) 6.790000 0.000000 6.790000 ( 6.790000)
# java driver (create) 0.602000 0.000000 0.602000 ( 0.602000)
# ruby driver (create) 3.963000 0.000000 3.963000 ( 3.963000)
require "java"
require "benchmark"
Ruby 1.8.6 w/o C extension
==========================
user system total real
single object inserts: 3.450000 0.160000 3.610000 ( 3.779446)
multiple object insert: 2.190000 0.020000 2.210000 ( 2.223418)
find_one: 0.070000 0.000000 0.070000 ( 0.087103)
Ruby 1.8.6 w/ C extension
=========================
user system total real
class User
include MongoMapper::Document
devise :authenticatable, :rememberable
key :email, String
key :encrypted_password, String
key :password_salt, String
key :remember_token, String
key :remember_created_at, DateTime
timestamps!