Skip to content

Instantly share code, notes, and snippets.

View cpetersen's full-sized avatar

Chris Petersen cpetersen

View GitHub Profile
module CouchRest
class ExtendedDocument
##########
# Start processing a view and return in 1 sec
# This seems like a hack, is there a better way to implement this?
##########
def self.process_index
r = RestClient::Resource.new("http://#{self.database.server.uri}/#{self.database.name}/#{self.design_doc_id}/_view/#{self.design_doc["views"].keys.first}?limit=0", :timeout => 1)
begin
r.get
class Person < ActiveRecord:Base
attr_accessor :name
def to_s
name
end
end
@names = Person.new(:name => "Colin")
@names = Person.all
merb : worker (port 4000) ~ HTTP status code 403 - (RestClient::RequestFailed)
/Users/cpetersen/Code/assaydepot/depot-store/gems/gems/rest-client-1.0.3/lib/restclient/request.rb:195:in `process_result'
/Users/cpetersen/Code/assaydepot/depot-store/gems/gems/rest-client-1.0.3/lib/restclient/request.rb:125:in `transmit'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/http.rb:543:in `start'
/Users/cpetersen/Code/assaydepot/depot-store/gems/gems/rest-client-1.0.3/lib/restclient/request.rb:123:in `transmit'
/Users/cpetersen/Code/assaydepot/depot-store/gems/gems/rest-client-1.0.3/lib/restclient/request.rb:49:in `execute_inner'
/Users/cpetersen/Code/assaydepot/depot-store/gems/gems/rest-client-1.0.3/lib/restclient/request.rb:39:in `execute'
/Users/cpetersen/Code/assaydepot/depot-store/gems/gems/rest-client-1.0.3/lib/restclient/request.rb:17:in `execute'
/Users/cpetersen/Code/assaydepot/depot-store/gems/gems/rest-client-1.0.3/lib/restclient.rb:73:in `put'
/Users/cpetersen/Code/assaydepot/de
require 'couchrest'
class Log < CouchRest::ExtendedDocument
database = CouchRest.new
database.default_database = "logger"
use_database database.default_database
property :response_time
property :created_at
{
"_id": "cell-based-assays-9",
"_rev": "923-3362030991",
"name": "Cell-Based Assays",
"wares": [
{
"ware_id": "23dc69331f0632bffa5179e6296d0c1a",
"name": "Ciliary Motility in Airway Cells "
}
],
[cpetersen@cpetersen depot-catalog-slice (master)]$ thor merb:gem:redeploy
Installing abstract-1.0.0
Installing cgi_multipart_eof_fix-2.5.0
Installing couchrest-0.33
Installing daemons-1.0.10
Installing erubis-2.6.3
Installing extlib-0.9.10
Installing fail-fast-1.0.0
Installing fastthread-1.0.1
Building native extensions. This could take a while...
[cpetersen@cpetersen depot-catalog-slice (master)]$ ./bin/rake spec --trace
(in /Users/cpetersen/Code/assaydepot2/depot-catalog-slice)
~ Merb 1.0.9 loaded
Loading init file from /Users/cpetersen/Code/assaydepot2/depot-catalog-slice/config/init.rb
** Invoke spec (first_time)
** Invoke spec:default (first_time)
** Execute spec:default
/opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:827:in `report_activate_error': RubyGem version error: merb-core(1.0.12 not = 1.0.9) (Gem::LoadError)
from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:261:in `activate'
from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:68:in `gem'
1)
NoMethodError in 'DepotOrderSlice::QuoteMailer#notify_on_event email template should include the id, name and email'
undefined method `each' for nil:NilClass
/Users/cpetersen/Code/assaydepot/depot-order-slice/app/models/quoted_ware.rb:172:in `save_attachments'
/Users/cpetersen/Code/assaydepot/depot-order-slice/gems/gems/couchrest-0.33/lib/couchrest/mixins/callbacks.rb:386:in `_run_save_callbacks'
/Users/cpetersen/Code/assaydepot/depot-order-slice/gems/gems/couchrest-0.33/lib/couchrest/more/extended_document.rb:205:in `save'
/Users/cpetersen/Code/assaydepot/depot-order-slice/gems/gems/couchrest-0.33/lib/couchrest/more/extended_document.rb:203:in `catch'
/Users/cpetersen/Code/assaydepot/depot-order-slice/gems/gems/couchrest-0.33/lib/couchrest/more/extended_document.rb:203:in `save'
./spec/mailers/quote_mailer_spec.rb:13:
desc 'backup the production database'
task :backup do
server = "your server"
username = "your user"
keypair = "#{Merb.root}/path/to/your/keypair"
databases = ["your", "databases", "here" ]
ssh_command = "ssh -i #{keypair} -L 5985:localhost:5984 #{username}@#{server}"
pid, stdin, stdout, stderr = Open4::popen4 ssh_command
module CouchRest
class Logger
def self.log
Thread.current["couchrest.logger"] ||= {:queries => []}
end
def initialize(app, db=nil)
@app = app
@db = db