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
development: &global_settings | |
database: textual_development | |
host: 127.0.0.1 | |
port: 27017 | |
test: | |
database: textual_test | |
<<: *global_settings | |
production: |
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 'pp' | |
require 'rubygems' | |
require 'mongo_mapper' | |
MongoMapper.database = 'testing' | |
class Site | |
include MongoMapper::Document | |
key :domain, String | |
key :authorizations, Array |
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 'open-uri' | |
# url dsl -- the ultimate url dsl! | |
# | |
# You just can't beat this: | |
# | |
# $ irb -r url_dsl | |
# >> include URLDSL | |
# => Object | |
# >> http://github.com/defunkt.json |
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 :harmony do | |
desc "Munges the data" | |
task :munge => :environment do | |
docs_with_publish = Item.collection.find({'publish' => {'$exists' => true}}).to_a | |
puts "Item count: #{Item.count}" | |
puts "Items with publish key: #{docs_with_publish.size}" | |
docs_with_publish.each do |hash| | |
hash.delete('publish') |
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
class ActiveSupport::TestCase | |
def setup | |
clear_all_collections | |
end | |
def clear_all_collections | |
Dir[Rails.root + 'app/models/**/*.rb'].each do |model_path| | |
klass = File.basename(model_path, '.rb').classify.constantize | |
klass.collection.remove if klass.respond_to?(:collection) | |
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
require 'pp' | |
require 'rubygems' | |
require 'mongo_mapper' | |
MongoMapper.database = 'testing' | |
class Rating | |
include MongoMapper::EmbeddedDocument | |
key :user_id, ObjectId |
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
class Comment | |
include MongoMapper::EmbeddedDocument | |
include Gravatarable | |
key :name, String | |
key :email, String | |
key :url, String | |
key :body, String | |
key :created_at, Time | |
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
# Have to use ActiveRecord so that New Relic shows it on all graphs. | |
# The push scope false stuff makes it so that you can track usage by model and overall. | |
if defined?(NewRelic) | |
module MongoMapperNewRelic | |
def self.included(model) | |
mm_class_methods = [ | |
:find, | |
:find!, | |
:paginate, | |
:first, |
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 'test/unit/ui/console/testrunner' | |
class Test::Unit::UI::Console::TestRunner | |
def add_fault(fault) | |
hax_output(fault) | |
@faults << fault | |
output_single(fault.single_character_display, 1) | |
@already_outputted = true | |
end | |
def hax_output(fault) |