This file contains 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
info: Extracting ruby-enterprise-1.8.7-2010.02 ... | |
++ [[ -n '' ]] | |
+++ dirname /Users/thomasmpack/.rvm/log/ree-1.8.7-2010.02/extract.log | |
++ mkdir -p /Users/thomasmpack/.rvm/log/ree-1.8.7-2010.02 | |
++ touch /Users/thomasmpack/.rvm/log/ree-1.8.7-2010.02/extract.log /Users/thomasmpack/.rvm/log/ree-1.8.7-2010.02/extract.error.log | |
++ tee /Users/thomasmpack/.rvm/log/ree-1.8.7-2010.02/extract.log | |
+++ date '+%Y-%m-%d %H:%M:%S' | |
++ echo '[2010-08-10 10:22:28] cat /Users/thomasmpack/.rvm/archives/ruby-enterprise-1.8.7-2010.02.tar.gz | gunzip | tar xf - -C /Users/thomasmpack/.rvm/src' | |
++ [[ -z '' ]] | |
++ eval 'cat /Users/thomasmpack/.rvm/archives/ruby-enterprise-1.8.7-2010.02.tar.gz | gunzip | tar xf - -C /Users/thomasmpack/.rvm/src' |
This file contains 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
describe "POST create" do | |
describe "with valid params" do | |
it "assigns a newly created attending as @attending" do | |
Attending.stub(:new).with({'event_id' => 1}) { mock_attending(:save => true) } | |
post :create, :event_id => 1 | |
assigns(:attending).should be(mock_attending) | |
end | |
end | |
end |
This file contains 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
namespace :wtp do | |
namespace :jsroutes do | |
desc "Regenerate routes for users" | |
task :users do | |
puts "Recreating routes for users..." | |
JsRoutes.generate!({}) | |
end | |
end | |
end |
This file contains 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 UrlHelper | |
def with_subdomain(subdomain) | |
subdomain = (subdomain || "") | |
subdomain += "." unless subdomain.empty? | |
[subdomain, request.domain, request.port_string].join | |
end | |
def url_for(options = nil) | |
if options.kind_of?(Hash) && options.has_key?(:subdomain) | |
options[:host] = with_subdomain(options.delete(:subdomain)) |
This file contains 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
# ---role | |
module BookManager | |
def create_book(attrs) | |
self.books.create! attrs | |
end | |
def update_book(book_id,attrs) | |
book = self.books.find(book_id) | |
book.update_attributes attrs |
This file contains 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 'services/user' | |
require 'services/artist' | |
describe 'POST /interests' do | |
# Use User and Artist Ruby wrappers to call services | |
let(:user) { Services::User.create(:name => 'Mike Pack') } | |
let(:artist) { Services::Artist.create(:name => 'Cool Band', :genres => ['Jazz', 'R&B']) } | |
it 'registers a users interest in an artist' do | |
# Initiate POST request |
This file contains 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
post '/interests' do | |
# Connect to Redis | |
uri = URI.parse(ENV["REDIS_URL"] || 'redis://localhost:6379') | |
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password) | |
# Parse the JSON body | |
join = JSON.parse(request.body.read) | |
# Register the user's interest in an artist | |
REDIS.sadd("artists:#{join['artist_id']}", join['user_id']) |
This file contains 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
REDIS.smembers('artists:1') #=> ["1","2","3"] where 1, 2 and 3 are user IDs | |
REDIS.smembers('users:1') #=> ["1","2","3"] where 1, 2 and 3 are artist IDs |
This file contains 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
artist_keys = REDIS.smembers('users:1') | |
artist_keys.map!{ |artist_id| "artists:#{artist_id}" } #=> ["artists:1", "artists:2", "artists:3"] | |
REDIS.sinter(*artist_keys) #=> ["2","3"] where 2 and 3 are user IDs |
OlderNewer