This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I don't need this right now but I will need them for this current project over the summer. | |
Here's what I'm thinking: | |
- Build it on top of RESTClient | |
- On the surface, it should be compatible with ActiveResource | |
- Maybe take advantage of .to_model interface with ActiveORM in Rails3 | |
- Use Addressable as Jesse suggests, to construct the URL | |
- Defaults to Yajl, switchable to JSON gem | |
- Defaults to Nokogiri + libxml2 | |
- Pluggable backend: Net::HTTP or EventMachine's HTTP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'machinist/active_record' | |
require 'sham' | |
require 'faker' | |
# The one below is from an older version. In my newer version that works with rspec2, | |
# blueprints.rb is located in spec/support and the line below matches that. The advantage | |
# is that the generated spec_helper automatically loads anything under spec/support | |
require File.expand_path('blueprints.rb', File.dirname(__FILE__) + '/../spec/') | |
puts '', "Accounts ..." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In app/models/person.rb | |
class Person < ActiveRecord::Base | |
belongs_to :organization | |
validates_presence_of :name | |
validates_presence of :email | |
validates_uniqueness_of :email | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Animal | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods | |
def say | |
"animal" | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mock, this isn't real | |
$ rake db:schema:version | |
-> saves to db/schema/schema-20100403232.rb | |
# Now you don't have the problem with the timestamp embedded | |
# into the db/schema.rb every time you do a db:schema:dump |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Configuration | |
#CLOUD_ETH="eth0" | |
CLOUD_ETH="eth1" # Standard for Rackspace Cloud | |
CHEFSERVER="10.177.133.40" | |
# Do not edit below |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActionController::Routing::Routes.draw do |map| | |
map.root :controller => :home, :action => :index | |
map.resources :servicios | |
map.resources :nosotros | |
#map.servicios '/servicios/consultorias', :controller => 'servicios', :action => 'consultoria' | |
map.connect "/servicios/:action", :controller => "servicios" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Forgery | |
class Merchant | |
PRODUCTS = %w(coffee drink gas donut sandwich icecream cigarette) | |
PROMOTION_TYPES = [ | |
lambda { | |
["Buy X P get Y Q free", | |
[:X, rand(3)+1], | |
[:Y, rand(4)+1], | |
[:P, PRODUCTS.rand], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
def hello_loop(names) | |
names.each do |name| | |
puts "Hello #{name}" | |
end | |
end | |
hello_loop(%w( | |
Gafitescu |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/concerns/let.rb | |
# Ripped from Rspec 2.0 beta.12 | |
# I've found it so useful in Rspec, I made it into a module. Controller code with shared | |
# code seem to have a lot of use for this. For example, in inherited_resources, you would | |
# typically override model, parent, etc. to configure it. You would typically memomize it | |
# as well. With this, you can use a more compact let() syntax. | |
# (Note: This code will only work in Rails 3) | |
module Let |