Permalink
Browse files

remove mongomapper generators

  • Loading branch information...
1 parent 6da2776 commit d087c11d1f4577d5bf24aa6f44f983f08eb61f4c @negonicrac negonicrac committed Sep 11, 2012
View
@@ -2,6 +2,10 @@
* Write some documentation. (In both the github wiki and the source code)
* Remove generators that exist in other libraries
+== Development
+* optimize
+ * MongoMapper generators removed. MongoMapper (https://github.com/jnunemaker/mongomapper) has its own generators.
+
== 0.17.5
* optimize
* Remove FactoryGirl
View
@@ -38,8 +38,6 @@ To avoid overriding the rails built-in Erb template generators this project uses
* DataMapper: José Valim
* Authlogic: Jeff Tucker
-* Mongomapper: Jai-Gouk Kim
-* MongoMapper: Kristian Mandrup (for 0.8) - needs testing
* Shoulda: Peter Haza
* SimpleForm: Peter Gumeson
@@ -1,59 +0,0 @@
-require 'rails/generators/named_base'
-require 'rails/generators/active_model'
-
-module MongoMapper
- module Generators
- class Base < Rails::Generators::NamedBase #:nodoc:
-
- def self.source_root
- @_mongomapper_source_root ||= File.expand_path(File.join(File.dirname(__FILE__),
- 'mongo_mapper', generator_name, 'templates'))
- end
- end
-
- class ActiveModel < Rails::Generators::ActiveModel #:nodoc:
- def self.all(klass)
- "#{klass}.all"
- end
-
- def self.find(klass, params=nil)
- "#{klass}.find(#{params})"
- end
-
- def self.build(klass, params=nil)
- if params
- "#{klass}.new(#{params})"
- else
- "#{klass}.new"
- end
- end
-
- def save
- "#{name}.save"
- end
-
- def update_attributes(params=nil)
- "#{name}.update(#{params})"
- end
-
- def errors
- "#{name}.errors"
- end
-
- def destroy
- "#{name}.destroy"
- end
- end
- end
-end
-
-module Rails
- module Generators
- class GeneratedAttribute #:nodoc:
- def type_class
- return 'DateTime' if type.to_s == 'datetime'
- return type.to_s.camelcase
- end
- end
- end
-end
@@ -1,30 +0,0 @@
-require 'generators/mongo_mapper'
-
-module MongoMapper
- module Generators
- class InstallGenerator < Base
- class_option :host, :type => :string, :default => 'localhost', :desc => "Name of the Mongo host use"
-
- def create_files
- template "mongo_mapper.rb" , "config/initializers/mongo_mapper.rb"
- template "database.mongo.yml" , "config/database.mongo.yml"
- say "Please ensure Gemfile contains: gem '#{orm_gem_name}', '>=0.8.2'"
- say "For production enviroment DB configuration, set environment variables as indicated in config/database.mongo.yml"
- end
-
- protected
-
- def database
- name
- end
-
- def orm_gem_name
- "mongo_mapper"
- end
-
- def host
- options[:host] || 'localhost'
- end
- end
- end
-end
@@ -1,25 +0,0 @@
-defaults: &defaults
- adapter: mongodb
- host: <%= host %>
- # slaves:
- # - host: slave1.local
- # port: 27018
- # - host: slave2.local
- # port: 27019
-
-development:
- <<: *defaults
- database: <%= database %>_development
-
-test:
- <<: *defaults
- database: <%= database %>_test
-
-# set these environment variables on your prod server
-production:
- <<: *defaults
- host: <%= ENV['MONGOID_HOST'] %>
- port: <%= ENV['MONGOID_PORT'] %>
- username: <%= ENV['MONGOID_USERNAME'] %>
- password: <%= ENV['MONGOID_PASSWORD'] %>
- database: <%= ENV['MONGOID_DATABASE'] %>
@@ -1,9 +0,0 @@
-database_config_file = File.join(Rails.root, "/config/database.mongo.yml")
-yaml_content = File.read(database_config_file)
-db_config = YAML::load(yaml_content)
-
-if db_config[Rails.env] && db_config[Rails.env]['adapter'] == 'mongodb'
- mongo = db_config[Rails.env]
- MongoMapper.connection = Mongo::Connection.new(mongo['host'])
- MongoMapper.database = mongo['database']
-end
@@ -1,84 +0,0 @@
-require 'generators/mongo_mapper'
-require 'generators/helpers/model_helper'
-
-module MongoMapper
- module Generators
- class ModelGenerator < Base
-
- argument :attributes, :type => :array, :default => [], :banner => "field:type field:type#, posfixing with '#' marks attribute to be indexed"
-
- class_option :timestamps, :type => :boolean, :aliases => "-T", :desc => "Add timestamps created_at and updated_at", :default => false
- class_option :embedded, :type => :boolean, :aliases => "-E", :desc => "Embedded document", :default => false
- class_option :version, :type => :boolean, :aliases => "-V", :desc => "Add versioning", :default => false
- class_option :parent, :type => :string, :aliases => "-P", :desc => "Class name of parent document"
-
- # check_class_collision
-
- attr_accessor :model_attributes, :model_indexes
-
- def initialize(*args, &block)
- super
- # from helpers/model_helper
- # parse_model_attributes
-
- @model_attributes = []
- @model_indexes = {}
-
- @model_attributes = attributes
- end
-
- def create_model_file
- template 'model.rb', "app/models/#{file_name}.rb"
- end
-
- protected
-
- def embedded_statement
- "include MongoMapper::EmbeddedDocument"
- end
-
- def version_statement
- 'include Versioned # see http://github.com/nathancolgate/versioned for 0.8 compatible version'
- end
-
- def timestamps_statement
- 'timestamps!'
- end
-
- def statements
- stm_list = []
- stm_list << embedded_statement if embedded?
- stm_list << version_statement if version?
- stm_list << timestamps_statement if timestamps?
- stm_list.join("\n")
- end
-
-
- def version?
- options[:version]
- end
-
- def embedded?
- options[:embedded]
- end
-
- def parent?
- options[:parent]
- end
-
- def timestamps?
- options[:timestamps]
- end
-
- def model_exists?
- File.exist? destination_path("app/models/#{file_name}.rb")
- end
-
- def model_columns_for_attributes
- class_name.constantize.columns.reject do |column|
- column.name.to_s =~ /^(id|created_at|updated_at)$/
- end
- end
- end
- end
-end
@@ -1,36 +0,0 @@
-class <%= class_name %><%= "< #{options[:parent].classify}" if parent? %>
-<% unless parent? -%>
- include MongoMapper::Document
-<% end -%>
-<%= statements %>
-<% unless parent? -%>
-# Validations :::::::::::::::::::::::::::::::::::::::::::::::::::::
-# validates_presence_of :attribute
-
-# Assocations :::::::::::::::::::::::::::::::::::::::::::::::::::::
-# belongs_to :model
-# many :model
-# one :model
-
-# Callbacks :::::::::::::::::::::::::::::::::::::::::::::::::::::::
-# before_create :your_model_method
-# after_create :your_model_method
-# before_update :your_model_method
-
-# Attribute options extras ::::::::::::::::::::::::::::::::::::::::
-# attr_accessible :first_name, :last_name, :email
-
-# Validations
-# key :name, :required => true
-
-# Defaults
-# key :done, :default => false
-
-# Typecast
-# key :user_ids, Array, :typecast => 'ObjectId'
-
-<% end -%>
-<% model_attributes.each_with_index do |attribute, i| -%>
- key :<%= attribute.name %>, <%= attribute.type_class %><%= ", :index => true" if model_indexes[attribute.name] %>
-<% end -%>
-end
@@ -1,15 +0,0 @@
-require 'generators/mongo_mapper'
-
-module MongoMapper
- module Generators
- class ObserverGenerator < Base
- check_class_collision :suffix => "Observer"
-
- def create_observer_file
- template 'observer.rb', File.join('app/models', class_path, "#{file_name}_observer.rb")
- end
-
- hook_for :test_framework
- end
- end
-end
@@ -1,3 +0,0 @@
-class <%= class_name %> < MongoMapper::Observer
- # add observer code here!
-end
View
@@ -5,7 +5,7 @@ module Rails3Generators
Rails::Generators.hidden_namespaces << "rails"
-%w(active_record data_mapper mongo_mapper mongoid active_model).each do |orm|
+%w(active_record data_mapper active_model).each do |orm|
Rails::Generators.hidden_namespaces <<
[
"#{orm}:migration",
@@ -31,6 +31,8 @@ Gem::Specification.new do |s|
s.post_install_message = %Q{
rails3-generators-#{Rails3::Generators::VERSION}
+MongoMapper generators removed. MongoMapper (https://github.com/jnunemaker/mongomapper) has its own generators.
+
Be sure to check out the wiki, https://wiki.github.com/indirect/rails3-generators/,
for information about recent changes to this project.
}
@@ -1,17 +0,0 @@
-require 'test_helper'
-require 'lib/generators/mongo_mapper/testing_helper'
-
-class MongoMapper::Generators::InstallGeneratorTest < Rails::Generators::TestCase
- destination File.join(Rails.root)
- tests MongoMapper::Generators::InstallGenerator
-
- setup :prepare_destination
- setup :copy_routes
-
- test "invoke" do
- run_generator ['test-db']
- assert_file "config/initializers/mongo_mapper.rb" do |initializer|
- assert_match /MongoMapper.connection = Mongo::Connection.new(\S+)/, initializer
- end
- end
-end
Oops, something went wrong.

0 comments on commit d087c11

Please sign in to comment.