modify the way locomotive setups a mongo connection

This commit is contained in:
dinedine 2010-06-04 00:55:04 +02:00
parent 9f20f56b1d
commit 3d22ef4d1c
6 changed files with 11 additions and 33 deletions

2
.gitignore vendored
View File

@ -8,6 +8,8 @@ uploads
spec/tmp spec/tmp
public/sites public/sites
public/uploads public/uploads
public/stylesheets/all.css
public/javascripts/all.js
pkg pkg
*.gemspec *.gemspec
rails_3_gems rails_3_gems

View File

@ -13,6 +13,7 @@ gem "warden"
gem "devise", ">= 1.1.rc0" gem "devise", ">= 1.1.rc0"
gem "haml", '>= 3.0.1' gem "haml", '>= 3.0.1'
gem "rmagick" gem "rmagick"
gem "aws"
gem "jeweler" gem "jeweler"
gem "mimetype-fu", :require => "mimetype_fu" gem "mimetype-fu", :require => "mimetype_fu"
gem "formtastic-rails3", :require => "formtastic" gem "formtastic-rails3", :require => "formtastic"

View File

@ -14,16 +14,16 @@ begin
Jeweler::Tasks.new do |gem| Jeweler::Tasks.new do |gem|
gem.name = "locomotive_cms" gem.name = "locomotive_cms"
gem.summary = "Locomotive cms engine" gem.summary = "Locomotive cms engine"
gem.author = ['Didier Lafforgue'] gem.authors = ['Didier Lafforgue']
gem.email = ["didier@nocoffee.fr"] gem.email = ['didier@nocoffee.fr']
gem.date = Date.today gem.date = Date.today
gem.description = "a brand new CMS system with super sexy UI and cool features" gem.description = "a brand new CMS system with super sexy UI and cool features"
gem.homepage = %q{http://github.com/did/locomotive} gem.homepage = %q{http://github.com/did/locomotive}
gem.files = Dir[ gem.files = Dir[
"Gemfile", "Gemfile",
"{lib}/**/*",
"{app}/**/*", "{app}/**/*",
"{config}/**/*", "{config}/**/*",
"{lib}/**/*",
"{public}/stylesheets/**/*", "{public}/javascripts/**/*", "{public}/images/**/*", "{public}/stylesheets/**/*", "{public}/javascripts/**/*", "{public}/images/**/*",
"{vendor}/**/*"] "{vendor}/**/*"]
# other fields that would normally go in your gemspec # other fields that would normally go in your gemspec
@ -35,6 +35,7 @@ begin
end end
end end
end end
Jeweler::GemcutterTasks.new
rescue rescue
puts "Jeweler or one of its dependencies is not installed." puts "Jeweler or one of its dependencies is not installed."
end end

View File

@ -30,4 +30,4 @@ Locomotive::Application.configure do
# Enable threaded mode # Enable threaded mode
# config.threadsafe! # config.threadsafe!
end end

View File

@ -4,19 +4,9 @@ File.open(File.join(Rails.root, 'config/database.yml'), 'r') do |f|
@settings = YAML.load(f)[Rails.env] @settings = YAML.load(f)[Rails.env]
end end
Mongoid.configure do |config| Mongoid::Config.instance.from_hash(@settings)
name = @settings["database"]
host = @settings["host"]
config.master = Mongo::Connection.new.db(name)
# config.slaves = [
# Mongo::Connection.new(host, @settings["slave_one"]["port"], :slave_ok => true).db(name),
# Mongo::Connection.new(host, @settings["slave_two"]["port"], :slave_ok => true).db(name)
# ]
end
## various patches ## various patches
module Mongoid #:nodoc: module Mongoid #:nodoc:
# Enabling scope in validates_uniqueness_of validation # Enabling scope in validates_uniqueness_of validation

View File

@ -7,7 +7,7 @@ require 'formtastic'
require 'mongoid' require 'mongoid'
require 'mongoid_acts_as_tree' require 'mongoid_acts_as_tree'
require File.dirname(__FILE__) + '/../../vendor/plugins/custom_fields/init.rb' require File.dirname(__FILE__) + '/../../vendor/plugins/custom_fields/init.rb'
module Locomotive module Locomotive
class Engine < Rails::Engine class Engine < Rails::Engine
@ -16,22 +16,6 @@ module Locomotive
path = [*ActionController::Base.helpers_path] << File.dirname(__FILE__) + "/../../app/helpers" path = [*ActionController::Base.helpers_path] << File.dirname(__FILE__) + "/../../app/helpers"
ActionController::Base.helpers_path = path ActionController::Base.helpers_path = path
end end
# initializer "locomotive.require_dependencies", :after => :initialize_dependency_mechanism do
# require 'bundler'
# gemfile = Bundler::Definition.from_gemfile(root.join('Gemfile'))
#
# specs = gemfile.dependencies.select do |d|
# !%w{jeweler rails}.include?(d.name) and (d.groups & [:default, :production]).any?
# end
# specs.collect { |s| s.autorequire || [s.name] }.flatten.each do |r|
# puts "requiring #{r}"
# require r
# end
#
# # gemify it soon
# require File.dirname(__FILE__) + '/../../vendor/plugins/custom_fields/init.rb'
# end
end end
end end