amardaxini-enginator 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ === 1.0.0 / 2009-07-23
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
@@ -0,0 +1,27 @@
1
+ enginator.gemspec
2
+ History.txt
3
+ lib/enginator.rb
4
+ bin/Enginator.rb
5
+ Rakefile
6
+ Manifest
7
+ README
8
+ rails_generators/USAGE
9
+ rails_generators/templates/my_db.yml
10
+ rails_generators/templates/USAGE
11
+ rails_generators/templates/init.rb
12
+ rails_generators/templates/uninstall.rb
13
+ rails_generators/templates/unit_test.rb
14
+ rails_generators/templates/Rakefile
15
+ rails_generators/templates/generator.rb
16
+ rails_generators/templates/README
17
+ rails_generators/templates/test_helper.rb
18
+ rails_generators/templates/plugin.rb
19
+ rails_generators/templates/MIT-LICENSE
20
+ rails_generators/templates/install.rb
21
+ rails_generators/templates/load_config.rb
22
+ rails_generators/templates/just.html.erb
23
+ rails_generators/templates/tasks.rake
24
+ rails_generators/engine_generator.rb
25
+ README.txt
26
+ Readme.rdoc
27
+ test/test_enginator.rb
data/README ADDED
@@ -0,0 +1,30 @@
1
+ = engine_generator
2
+
3
+ * http://github.com/amardaxini/#{project_name}
4
+
5
+ == DESCRIPTION:
6
+
7
+ Engine Generator is Used for generating a Rails Engine
8
+ In this engine has separate Database which Does not relate with Main application database
9
+
10
+ == FEATURES/PROBLEMS:
11
+
12
+ While installing application as engine we have to copy several files
13
+ After copy Engine has one single database but here engine has its own database
14
+
15
+ # sudo gem install amardaxini-engine_generator
16
+ # /script/generate engine engine_name sourcedir:pluggapleapplicationpath
17
+ # change user_name and password in database.yml
18
+ # rake db:create:all
19
+ # rake db:migrate
20
+ If database is other than mysql change database.yml
21
+ What it Does
22
+ # It copies sourcepath/app folder to engine name/app
23
+ # Add self.connection :#{engine name}_dev to all model
24
+ # Removing application controller and added engine controller which inherits from main app controller
25
+ # Remaining Application controller in heri from engine controller
26
+ # Copy routes.rb and paste into vendor/plugins/engine/config/routes.rb
27
+ # Copy migrate folder into vendor/plugins/engine/db/migrate
28
+ # Making Significant change in migration file thwn paste into mainapp/db/migrate folder
29
+
30
+
@@ -0,0 +1,48 @@
1
+ = enginator
2
+
3
+ * FIX (url)
4
+
5
+ == DESCRIPTION:
6
+
7
+ FIX (describe your package)
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * FIX (list of features or problems)
12
+
13
+ == SYNOPSIS:
14
+
15
+ FIX (code sample of usage)
16
+
17
+ == REQUIREMENTS:
18
+
19
+ * FIX (list of requirements)
20
+
21
+ == INSTALL:
22
+
23
+ * FIX (sudo gem install, anything else)
24
+
25
+ == LICENSE:
26
+
27
+ (The MIT License)
28
+
29
+ Copyright (c) 2009 FIX
30
+
31
+ Permission is hereby granted, free of charge, to any person obtaining
32
+ a copy of this software and associated documentation files (the
33
+ 'Software'), to deal in the Software without restriction, including
34
+ without limitation the rights to use, copy, modify, merge, publish,
35
+ distribute, sublicense, and/or sell copies of the Software, and to
36
+ permit persons to whom the Software is furnished to do so, subject to
37
+ the following conditions:
38
+
39
+ The above copyright notice and this permission notice shall be
40
+ included in all copies or substantial portions of the Software.
41
+
42
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
43
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
44
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
45
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
46
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
47
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
48
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('enginator', '0.1.0') do |p|
6
+ p.project = "enginator"
7
+ p.description = "A collection of useful generator scripts for Rails engine."
8
+ p.url = ""
9
+ p.author = 'Amar Daxini'
10
+ p.email = "amar.daxini (at) gmail (dot) com"
11
+ p.ignore_pattern = ["script/*"]
12
+ p.development_dependencies = []
13
+ end
14
+
15
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
@@ -0,0 +1,30 @@
1
+ = engine_generator
2
+
3
+ * http://github.com/amardaxini/#{project_name}
4
+
5
+ == DESCRIPTION:
6
+
7
+ Engine Generator is Used for generating a Rails Engine
8
+ In this engine has separate Database which Does not relate with Main application database
9
+
10
+ == FEATURES/PROBLEMS:
11
+
12
+ While installing application as engine we have to copy several files
13
+ After copy Engine has one single database but here engine has its own database
14
+
15
+ # sudo gem install amardaxini-engine_generator
16
+ # /script/generate engine engine_name sourcedir:pluggapleapplicationpath
17
+ # change user_name and password in database.yml
18
+ # rake db:create:all
19
+ # rake db:migrate
20
+ If database is other than mysql change database.yml
21
+ What it Does
22
+ # It copies sourcepath/app folder to engine name/app
23
+ # Add self.connection :#{engine name}_dev to all model
24
+ # Removing application controller and added engine controller which inherits from main app controller
25
+ # Remaining Application controller in heri from engine controller
26
+ # Copy routes.rb and paste into vendor/plugins/engine/config/routes.rb
27
+ # Copy migrate folder into vendor/plugins/engine/db/migrate
28
+ # Making Significant change in migration file thwn paste into mainapp/db/migrate folder
29
+
30
+
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ abort "you need to write me"
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{enginator}
5
+ s.version = "0.1.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Amar Daxini"]
9
+ s.date = %q{2009-07-23}
10
+ s.default_executable = %q{Enginator.rb}
11
+ s.description = %q{A collection of useful generator scripts for Rails engine.}
12
+ s.email = %q{amar.daxini (at) gmail (dot) com}
13
+ s.executables = ["Enginator.rb"]
14
+ s.extra_rdoc_files = ["lib/enginator.rb", "bin/Enginator.rb", "README", "README.txt"]
15
+ s.files = ["enginator.gemspec", "History.txt", "lib/enginator.rb", "bin/Enginator.rb", "Rakefile", "Manifest", "README", "rails_generators/USAGE", "rails_generators/templates/my_db.yml", "rails_generators/templates/USAGE", "rails_generators/templates/init.rb", "rails_generators/templates/uninstall.rb", "rails_generators/templates/unit_test.rb", "rails_generators/templates/Rakefile", "rails_generators/templates/generator.rb", "rails_generators/templates/README", "rails_generators/templates/test_helper.rb", "rails_generators/templates/plugin.rb", "rails_generators/templates/MIT-LICENSE", "rails_generators/templates/install.rb", "rails_generators/templates/load_config.rb", "rails_generators/templates/just.html.erb", "rails_generators/templates/tasks.rake", "rails_generators/engine_generator.rb", "README.txt", "Readme.rdoc", "test/test_enginator.rb"]
16
+ s.homepage = %q{}
17
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Enginator", "--main", "README"]
18
+ s.require_paths = ["lib"]
19
+ s.rubyforge_project = %q{enginator}
20
+ s.rubygems_version = %q{1.3.4}
21
+ s.summary = %q{A collection of useful generator scripts for Rails engine.}
22
+ s.test_files = ["test/test_enginator.rb"]
23
+
24
+ if s.respond_to? :specification_version then
25
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
26
+ s.specification_version = 3
27
+
28
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
29
+ else
30
+ end
31
+ else
32
+ end
33
+ end
@@ -0,0 +1,5 @@
1
+ class module Enginators
2
+ VERSION = '1.0.0'
3
+ # nothing to see here, the real action is under rails_generators
4
+ end
5
+
@@ -0,0 +1,31 @@
1
+ Description:
2
+ Explain the generator
3
+ This generator behaves like as pluguin generator
4
+ but it copies your app folder of your application
5
+ to vendor/plugin/<%= file_name %>/app
6
+
7
+ if error A copy of ApplicationController has been removed from the module tree but is still active!
8
+ main_app/config/environments/development.rbmake it true if false config.cache_classes = true
9
+
10
+ Example:
11
+ 1)./script/generate engine engine_name sourcedir:pluggapleapplicationpath
12
+ 2)change user_name and password in database.yml
13
+ 3)rake db:create:all
14
+ 4)rake db:migrate
15
+ If database is other than mysql change database.yml
16
+ if source_dir is not given then copies own app folder
17
+ The above generator copy your source application app folder to vendor/app/#{engine_name}/app
18
+ Copy routes.rb
19
+ Check that route file any map.root or any map.{...} change as needed
20
+ It update database.yml file added another mysql adapter named with engine_name_dev with engine_name_dev database
21
+ Change username and password
22
+ Then rake db:create:all or create database manually
23
+ rake db:migrate
24
+ Some times it Giving an error
25
+ A copy of ApplicationController has been removed from the module tree but is still active!
26
+ Config/environment/your mode like development.rb
27
+ change config.cache_classes=false to true
28
+
29
+
30
+
31
+
@@ -0,0 +1,197 @@
1
+ class EngineGenerator < Rails::Generator::NamedBase
2
+
3
+ attr_accessor :plugin_path,:source_dir,:plugin_name,:db_name,:user_name,:password
4
+ require 'fileutils'
5
+
6
+ def initialize(runtime_args, runtime_options = {})
7
+ super
8
+ @plugin_name = runtime_args.first
9
+ @db_name = ""
10
+ @user_name = ""
11
+ @password = ""
12
+ @attributes = []
13
+ @source_dir = ""
14
+ runtime_args[1..-1].each do |arg|
15
+ @attributes << arg
16
+ end
17
+ @attributes.flatten.uniq
18
+ #Dynamic Addding database and username and password
19
+ @attributes.each do |option|
20
+ option_parameter = option.split(":")
21
+ if option_parameter.first == "db"
22
+ @db_name = option_parameter[1]
23
+ elsif option_parameter.first == "sourcedir"
24
+ @source_dir = option_parameter.last
25
+ end
26
+ option_parameter = []
27
+ end
28
+
29
+
30
+ if !@source_dir.blank?
31
+ source_path = @source_dir+"/app"
32
+ if !File.directory?(source_path)
33
+ @source_dir = ""
34
+ end
35
+ end
36
+
37
+ @plugin_path = "vendor/plugins/#{plugin_name}"
38
+ FileUtils.mkdir(@plugin_path)
39
+ FileUtils.mkdir(@plugin_path+"/config")
40
+ FileUtils.cp_r(@source_dir+'/app',@plugin_path+"/app")
41
+ FileUtils.cp(@source_dir+'/config/routes.rb',@plugin_path+"/config")
42
+ FileUtils.cp_r(@source_dir+'/db',@plugin_path+"/db")
43
+ end
44
+
45
+ def manifest
46
+ record do |m|
47
+ m.directory @plugin_path+"/lib"
48
+ m.directory @plugin_path+"/tasks"
49
+ m.directory @plugin_path+"/test"
50
+ m.template 'README', "#{plugin_path}/README"
51
+ m.template 'MIT-LICENSE', "#{plugin_path}/MIT-LICENSE"
52
+ m.template 'Rakefile', "#{plugin_path}/Rakefile"
53
+ m.template 'init.rb', "#{plugin_path}/init.rb"
54
+ m.template 'install.rb', "#{plugin_path}/install.rb"
55
+ m.template 'uninstall.rb', "#{plugin_path}/uninstall.rb"
56
+ m.template 'plugin.rb', "#{plugin_path}/lib/#{plugin_name}.rb"
57
+ m.template 'tasks.rake', "#{plugin_path}/tasks/#{plugin_name}_tasks.rake"
58
+ m.template 'unit_test.rb', "#{plugin_path}/test/#{plugin_name}_test.rb"
59
+ m.template 'test_helper.rb', "#{plugin_path}/test/test_helper.rb"
60
+ m.template 'my_db.yml', "#{plugin_path}/config/my_db.yml"
61
+ # m.template "load_config.rb", "config/initializers/load_#{file_name}_config.rb"
62
+ # m.file "my_db.yml", "config/#{file_name}_config.yml"
63
+ end
64
+ end
65
+
66
+ def constant_name
67
+ file_name.underscore.upcase
68
+ end
69
+ def singular_name
70
+ file_name.underscore
71
+ end
72
+
73
+ def plural_name
74
+ file_name.underscore.pluralize
75
+ end
76
+
77
+ def class_name
78
+ file_name.camelize
79
+ end
80
+
81
+ def plural_class_name
82
+ plural_name.camelize
83
+ end
84
+
85
+ def after_generate
86
+ # `rake enginedb:create`
87
+ #add filename =amar then add amar_dev to an all model self.establish_connection :amar_dev
88
+ change_model_content
89
+ # add to database yml amar_dev with data base amar_dev
90
+ change_database_yml_content
91
+
92
+ #added self.connection modelname.connection end
93
+ change_migration_content
94
+
95
+ #replace "< ApplicationController" with " < plural_class_name"
96
+ change_controller_content
97
+
98
+ # now Change Plugin ApplicationController to #plural_class_name and inhrit from main ApplicationController
99
+ #prepend line require 'application_controller.rb'
100
+ change_application_controller_of_engine
101
+
102
+ #Added all migration to base migration
103
+ FileUtils.cp_r(@plugin_path+"/db/migrate/.",'db/migrate')
104
+ end
105
+ def change_model_content
106
+ Dir.glob("#{plugin_path}/app/models/*.rb").each do |f|
107
+ content = ""
108
+ file = File.open(f,"r")
109
+ file.each do |line|
110
+ content += "#{line} "
111
+ end
112
+ db_connection = "self.establish_connection :#{file_name}_dev"
113
+ content.sub!(/ActiveRecord::Base\s{1}/,"ActiveRecord::Base\n #{db_connection} \n")
114
+
115
+ #Find out ActiveRecord::Base and after this line place self.establish_connection :amar_dev
116
+ file = File.open(f,"w")
117
+ file.write(content)
118
+ file.close
119
+ end
120
+ end
121
+ # add to database yml #{file_name}_dev with data base #{file_name}_dev
122
+ def change_database_yml_content
123
+ dbconfig = YAML::load(File.open('config/database.yml'))
124
+ mydb = {"#{file_name}_dev"=>{"encoding"=>"utf8","reconnect"=>false,"adapter"=>"mysql","username"=>"root", "database"=>"#{file_name}_dev","pool"=>5, "password"=>"", "socket"=>"/var/run/mysqld/mysqld.sock"}}
125
+ dbconfig = dbconfig.merge(mydb)
126
+ File.open('config/database.yml','w'){ |f| YAML.dump(dbconfig, f) }
127
+ end
128
+ #added self.connection modelname.connection end
129
+ def change_migration_content
130
+ Dir.glob("#{plugin_path}/db/migrate/*.rb").each do |f|
131
+ content = ""
132
+ file = File.open(f,"r")
133
+ file.each do |line|
134
+ content += "#{line} "
135
+ end
136
+ mig_array = ["To", "From", "Create" ,"Remove"]
137
+ model_name = ""
138
+ mig_array.each do |m_a|
139
+ reg_exp = %r{#{m_a}(.+)\s+<}
140
+ model_name = reg_exp.match(content)[1] unless reg_exp.match(content).nil?
141
+ if !model_name.blank?
142
+ break
143
+ end
144
+ end
145
+ migrate_connection =""
146
+ if !model_name.blank?
147
+ migrate_connection = "def self.connection
148
+ #{model_name.singularize}.connection
149
+ end"
150
+ end
151
+ if !model_name.blank?
152
+ content.sub!(/ActiveRecord::Migration\s{1}/,"ActiveRecord::Migration\n #{migrate_connection} \n")
153
+ end
154
+ file = File.open(f,"w")
155
+ file.write(content)
156
+ file.close
157
+ end
158
+
159
+ end
160
+ #replace "< ApplicationController" with " < plural_class_nameController"
161
+ def change_controller_content
162
+
163
+ Dir.glob("#{plugin_path}/app/controllers/*.rb").each do |f|
164
+ content = ""
165
+ file = File.open(f,"r")
166
+ file.each do |line|
167
+ content += "#{line} "
168
+ end
169
+ content.sub!(/< ApplicationController{1}/,"< #{plural_class_name}Controller \n")
170
+ file = File.open(f,"w")
171
+ file.write(content)
172
+ file.close
173
+ end
174
+ end
175
+ # now Change Plugin ApplicationController to #plural_class_name and inhrit from main ApplicationController
176
+ #prepend line require 'application_controller.rb'
177
+ def change_application_controller_of_engine
178
+
179
+ application_content = ""
180
+ application_controller_file = File.open("#{plugin_path}/app/controllers/application_controller.rb","r")
181
+ application_controller_file .each do |line|
182
+ application_content += "#{line} "
183
+ end
184
+ app1 = "require"
185
+ app2 ="'application_controller.rb'"
186
+ app3 = "class #{plural_class_name}Controller < ApplicationController"
187
+ application_content.sub!(/class ApplicationController < ActionController::Base{1}/,"#{app1}\s#{app2} \n#{app3}")
188
+ application_controller_file = File.open("#{plugin_path}/app/controllers/application_controller.rb","w")
189
+ application_controller_file.write(application_content)
190
+ application_controller_file.close
191
+ File.rename("#{plugin_path}/app/controllers/application_controller.rb","#{plugin_path}/app/controllers/#{plural_name}_controller.rb")
192
+ end
193
+
194
+
195
+
196
+ end
197
+
@@ -0,0 +1,20 @@
1
+ Copyright (c) <%= Date.today.year %> [name of plugin creator]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,13 @@
1
+ <%= class_name %>
2
+ <%= "=" * class_name.size %>
3
+
4
+ Introduction goes here.
5
+
6
+
7
+ Example
8
+ =======
9
+
10
+ Example goes here.
11
+
12
+
13
+ Copyright (c) <%= Date.today.year %> [name of plugin creator], released under the MIT license
@@ -0,0 +1,23 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Test the <%= file_name %> plugin.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib'
11
+ t.libs << 'test'
12
+ t.pattern = 'test/**/*_test.rb'
13
+ t.verbose = true
14
+ end
15
+
16
+ desc 'Generate documentation for the <%= file_name %> plugin.'
17
+ Rake::RDocTask.new(:rdoc) do |rdoc|
18
+ rdoc.rdoc_dir = 'rdoc'
19
+ rdoc.title = '<%= class_name %>'
20
+ rdoc.options << '--line-numbers' << '--inline-source'
21
+ rdoc.rdoc_files.include('README')
22
+ rdoc.rdoc_files.include('lib/**/*.rb')
23
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ ./script/generate <%= file_name %> Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,8 @@
1
+ class <%= class_name %>Generator < Rails::Generator::NamedBase
2
+ def manifest
3
+ record do |m|
4
+ # m.directory "lib"
5
+ # m.template 'README', "README"
6
+ end
7
+ end
8
+ end
@@ -0,0 +1 @@
1
+ # Include hook code here
@@ -0,0 +1 @@
1
+ # Install hook code here
@@ -0,0 +1,2 @@
1
+ raw_config = File.read(RAILS_ROOT + "/config/<%= file_name %>_config.yml")
2
+ <%= constant_name %>_CONFIG = YAML.load(raw_config).symbolize_keys
@@ -0,0 +1,28 @@
1
+ # MySQL. Versions 4.1 and 5.0 are recommended.
2
+ #
3
+ # Install the MySQL driver:
4
+ # gem install mysql
5
+ # On Mac OS X:
6
+ # sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
7
+ # On Mac OS X Leopard:
8
+ # sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
9
+ # This sets the ARCHFLAGS environment variable to your native architecture
10
+ # On Windows:
11
+ # gem install mysql
12
+ # Choose the win32 build.
13
+ # Install MySQL and put its /bin directory on your path.
14
+ #
15
+ # And be sure to use new-style password hashing:
16
+ # http://dev.mysql.com/doc/refman/5.0/en/old-client.html
17
+ mydb:
18
+ adapter: mysql
19
+ encoding: utf8
20
+ reconnect: false
21
+ database:
22
+ pool: 5
23
+ username:
24
+ password:
25
+ socket: /var/run/mysqld/mysqld.sock
26
+
27
+
28
+
@@ -0,0 +1 @@
1
+ # <%= class_name %>
@@ -0,0 +1,32 @@
1
+ require 'activerecord'
2
+ require 'yaml'
3
+ require 'ruby-debug'
4
+ namespace :enginedb do
5
+
6
+ desc 'Creates the databases defined in your config/my_db.yml (unless they already exist)'
7
+ task :create do
8
+ YAML::load(File.open('vendor/plugins/amar/config/my_db.yml')).each_value do |config|
9
+ begin
10
+ ActiveRecord::Base.establish_connection(config)
11
+ ActiveRecord::Base.connection
12
+ rescue
13
+ case config['adapter']
14
+ when 'mysql'
15
+ @charset = 'utf8'
16
+ @collation = 'utf8_general_ci'
17
+ ActiveRecord::Base.establish_connection(config.merge({'database' => nil}))
18
+ ActiveRecord::Base.connection.create_database(config['database'], {:charset => @charset, :collation => @collation})
19
+ ActiveRecord::Base.establish_connection(config)
20
+ when 'postgresql'
21
+ `createdb "#{config['database']}" -E utf8`
22
+ end
23
+ end
24
+ end
25
+
26
+ end
27
+ desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x"
28
+ task :migrate do
29
+ ActiveRecord::Migrator.migrate("db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
30
+ # Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'active_support'
3
+ require 'active_support/test_case'
@@ -0,0 +1 @@
1
+ # Uninstall hook code here
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class <%= class_name %>Test < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ test "the truth" do
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require "test/unit"
2
+ require "pluggable_engine_generator"
3
+
4
+ class TestPluggableEngineGenerator < Test::Unit::TestCase
5
+ def test_sanity
6
+ flunk "write tests or I will kneecap you"
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: amardaxini-enginator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Amar Daxini
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-23 00:00:00 -07:00
13
+ default_executable: Enginator.rb
14
+ dependencies: []
15
+
16
+ description: A collection of useful generator scripts for Rails engine.
17
+ email: amar.daxini (at) gmail (dot) com
18
+ executables:
19
+ - Enginator.rb
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - lib/enginator.rb
24
+ - bin/Enginator.rb
25
+ - README
26
+ - README.txt
27
+ files:
28
+ - enginator.gemspec
29
+ - History.txt
30
+ - lib/enginator.rb
31
+ - bin/Enginator.rb
32
+ - Rakefile
33
+ - Manifest
34
+ - README
35
+ - rails_generators/USAGE
36
+ - rails_generators/templates/my_db.yml
37
+ - rails_generators/templates/USAGE
38
+ - rails_generators/templates/init.rb
39
+ - rails_generators/templates/uninstall.rb
40
+ - rails_generators/templates/unit_test.rb
41
+ - rails_generators/templates/Rakefile
42
+ - rails_generators/templates/generator.rb
43
+ - rails_generators/templates/README
44
+ - rails_generators/templates/test_helper.rb
45
+ - rails_generators/templates/plugin.rb
46
+ - rails_generators/templates/MIT-LICENSE
47
+ - rails_generators/templates/install.rb
48
+ - rails_generators/templates/load_config.rb
49
+ - rails_generators/templates/just.html.erb
50
+ - rails_generators/templates/tasks.rake
51
+ - rails_generators/engine_generator.rb
52
+ - README.txt
53
+ - Readme.rdoc
54
+ - test/test_enginator.rb
55
+ has_rdoc: false
56
+ homepage: ""
57
+ post_install_message:
58
+ rdoc_options:
59
+ - --line-numbers
60
+ - --inline-source
61
+ - --title
62
+ - Enginator
63
+ - --main
64
+ - README
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: "0"
72
+ version:
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: "1.2"
78
+ version:
79
+ requirements: []
80
+
81
+ rubyforge_project: enginator
82
+ rubygems_version: 1.2.0
83
+ signing_key:
84
+ specification_version: 3
85
+ summary: A collection of useful generator scripts for Rails engine.
86
+ test_files:
87
+ - test/test_enginator.rb