Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ready to be gem'd

  • Loading branch information...
commit db19e9173bb8235fd69213ebb7609ff6afb6ee5e 1 parent 3c43f8d
@croaky authored
Showing with 60 additions and 11 deletions.
  1. +1 −0  Rakefile
  2. +7 −11 lib/sinatra/mongoid.rb
  3. +52 −0 sinatra-mongoid.gemspec
View
1  Rakefile
@@ -10,6 +10,7 @@ Jeweler::Tasks.new do |gem|
gem.add_dependency("sinatra")
gem.add_dependency("mongoid")
+ gem.add_dependency("mongo_ext")
end
Jeweler::GemcutterTasks.new
View
18 lib/sinatra/mongoid.rb
@@ -1,24 +1,20 @@
require 'sinatra/base'
require 'mongoid'
-require 'mongo_ext'
module Sinatra
module MongoidExtension
- module DatabaseConnection
- connection = Mongo::Connection.new(mongo_host)
- Mongoid.database = connection.db(mongo_db)
- if mongo_user
- Mongoid.database.authenticate(mongo_user, mongo_password)
- end
- end
-
def self.registered(app)
app.set :mongo_host, ENV['MONGO_HOST'] || 'localhost'
- app.set :mongo_db, ENV['MONGO_DB']
+ app.set :mongo_db, ENV['MONGO_DB'] || 'changeme'
app.set :mongo_user, ENV['MONGO_USER']
app.set :mongo_password, ENV['MONGO_PASSWORD']
- app.helpers MongoidExtension::DatabaseConnection
+ Mongoid.database = Mongo::Connection.new(app.mongo_host).
+ db(app.mongo_db)
+ if app.mongo_user
+ Mongoid.database.authenticate(app.mongo_user,
+ app.mongo_password)
+ end
end
end
View
52 sinatra-mongoid.gemspec
@@ -0,0 +1,52 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE DIRECTLY
+# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{sinatra-mongoid}
+ s.version = "0.0.0"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Dan Croak"]
+ s.date = %q{2010-01-14}
+ s.description = %q{Like a blind date for the nastiest Ruby Mongo ORM and web framework.}
+ s.email = %q{dcroak@thoughtbot.com}
+ s.extra_rdoc_files = [
+ "LICENSE",
+ "README.md"
+ ]
+ s.files = [
+ ".gitignore",
+ "LICENSE",
+ "README.md",
+ "Rakefile",
+ "VERSION",
+ "lib/sinatra/mongoid.rb"
+ ]
+ s.homepage = %q{http://github.com/dancroak/sinatra-mongoid}
+ s.rdoc_options = ["--charset=UTF-8"]
+ s.require_paths = ["lib"]
+ s.rubygems_version = %q{1.3.5}
+ s.summary = %q{A Mongoid extension for Sinatra.}
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+ s.add_runtime_dependency(%q<sinatra>, [">= 0"])
+ s.add_runtime_dependency(%q<mongoid>, [">= 0"])
+ s.add_runtime_dependency(%q<mongo_ext>, [">= 0"])
+ else
+ s.add_dependency(%q<sinatra>, [">= 0"])
+ s.add_dependency(%q<mongoid>, [">= 0"])
+ s.add_dependency(%q<mongo_ext>, [">= 0"])
+ end
+ else
+ s.add_dependency(%q<sinatra>, [">= 0"])
+ s.add_dependency(%q<mongoid>, [">= 0"])
+ s.add_dependency(%q<mongo_ext>, [">= 0"])
+ end
+end
+
Please sign in to comment.
Something went wrong with that request. Please try again.