flextao-arm 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +7 -0
- data/MIT-LICENSE.txt +19 -0
- data/README.rdoc +113 -0
- data/Rakefile +87 -0
- data/TODO +0 -0
- data/arm.gemspec +28 -0
- data/bin/arm +12 -0
- data/lib/arm.rb +7 -0
- data/lib/arm/facade.rb +12 -0
- data/lib/arm/skeleton_generator.rb +38 -0
- data/lib/arm/tasks/arm.rake +41 -0
- data/lib/arm/tasks/arm.rb +3 -0
- data/skeleton/Rakefile +47 -0
- data/skeleton/config/database.yml.example +20 -0
- data/skeleton/config/environment.rb +0 -0
- data/skeleton/script/_jrubycleanup.bat +21 -0
- data/skeleton/script/_jrubysetcp.bat +10 -0
- data/skeleton/script/_jrubyvars.bat +91 -0
- data/skeleton/script/_jrubyvmopts.bat +81 -0
- data/skeleton/script/jrake +115 -0
- data/skeleton/script/jrake.bat +12 -0
- data/skeleton/vendor/ext/activerecord-2.3.2/lib/active_record/schema_dumper.rb +182 -0
- data/skeleton/vendor/ext/jdbc_tasks_postgre_fix.rb +29 -0
- metadata +94 -0
data/CHANGES
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
|
2
|
+
== release 0.0.1
|
3
|
+
|
4
|
+
* generated project skeleton by 'arm' command
|
5
|
+
* activerecord 2.3.2 patch for dumping database schema with string type primary key
|
6
|
+
* activerecord-jdbc-adapter postgre fix patch
|
7
|
+
* froze activerecord, activesupport, rails and activerecord-jdbc-adapter in vendor/gems directory after project skeleton created
|
data/MIT-LICENSE.txt
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2009 Flextao
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
= ARM
|
2
|
+
|
3
|
+
Support ARM version: 0.0.x
|
4
|
+
|
5
|
+
ARM generates project skeleton for Java project to embed ActiveRecord Migration.
|
6
|
+
|
7
|
+
== GEM Installation
|
8
|
+
|
9
|
+
Run the following if you haven't already:
|
10
|
+
|
11
|
+
gem sources -a http://gems.github.com
|
12
|
+
|
13
|
+
Install the gem:
|
14
|
+
|
15
|
+
sudo gem install flextao-arm
|
16
|
+
|
17
|
+
== Use it in your project
|
18
|
+
|
19
|
+
* To install ARM and generate project skeleton, use cruby. I never tried it in jruby.
|
20
|
+
* Install activerecord, activesupport and rails gems, by default, ARM takes version 2.3.2, you can specify a system environment variable ACTIVERECORD_VERSION to change the version.
|
21
|
+
* Install activerecord-jdbc-adapter gem
|
22
|
+
* go to your Java project root directory
|
23
|
+
* run script 'arm', it will create project skeleton for you
|
24
|
+
* add jruby complete jar and database jdbc jars into lib dir
|
25
|
+
* add migration into db/migrate directory
|
26
|
+
* config database.yml, see config/database.yml.example for example
|
27
|
+
* do migrate: './script/jrake db:migrate'
|
28
|
+
|
29
|
+
== Project skeleton generated by ARM
|
30
|
+
|
31
|
+
-- db => Same directory with Rails
|
32
|
+
-- config => Same directory with Rails, you need create a database.yml here
|
33
|
+
-- lib => Put jruby complete jar and jdbc jars here
|
34
|
+
-- script => Jrake and jrake.bat inside
|
35
|
+
-- vendor
|
36
|
+
---- ext => ActiveRecord 2.3.2 patch and activerecord-jdbc-adapter postgre fix patch inside
|
37
|
+
---- gems => All gems need would be froze here
|
38
|
+
-- Rakefile => Initialize a Rails environment and load Rails database and misc tasks.
|
39
|
+
Take a look after created, and customs it as you need.
|
40
|
+
|
41
|
+
== Tips
|
42
|
+
|
43
|
+
* Why version 2.3.2?
|
44
|
+
|
45
|
+
ActiveRecord assumes type of table primary key (e.g. id) is integer, but you may need it as string type in a Hibernate project. ARM has a patch for activerecord 2.3.2 to dump database schema with string type primary key. If your Java project is using integer as table primary key, you should be able to use any version of activerecord.
|
46
|
+
|
47
|
+
* Different convention between Java and Rails
|
48
|
+
|
49
|
+
In Java, most of time use long over integer as column type and use double over float as column type. In Rails, they are opposite.
|
50
|
+
|
51
|
+
* Integrate with Hibernate
|
52
|
+
|
53
|
+
Change the property 'hibernate.hbm2ddl.auto' to be 'validate', so that Hibernate would validate the Java models with database schema on startup.
|
54
|
+
|
55
|
+
* Run migration in Java (Web Application). The following is a simple Migrator implementation.
|
56
|
+
|
57
|
+
public class Migrator {
|
58
|
+
/**
|
59
|
+
* this is a simple check method to verify directory to run migration
|
60
|
+
*/
|
61
|
+
public static boolean isMigrationBaseDir(String dir) {
|
62
|
+
return new File(path(dir, "db")).exists();
|
63
|
+
}
|
64
|
+
|
65
|
+
private final String base; // base directory to run migration
|
66
|
+
|
67
|
+
public Migrator(String base) {
|
68
|
+
this.base = base;
|
69
|
+
}
|
70
|
+
|
71
|
+
public void migrate() {
|
72
|
+
Ruby runtime = JavaEmbedUtils.initialize(new ArrayList());
|
73
|
+
runtime.evalScriptlet(script());
|
74
|
+
}
|
75
|
+
|
76
|
+
private String script() {
|
77
|
+
StringBuffer buffer = new StringBuffer();
|
78
|
+
buffer.append("require 'rubygems'\n");
|
79
|
+
buffer.append("require 'rake'\n");
|
80
|
+
if (".".equals(base)) {
|
81
|
+
buffer.append(runRakeScript());
|
82
|
+
} else {
|
83
|
+
buffer.append("Dir.chdir('" + base + "') do\n");
|
84
|
+
buffer.append(" " + runRakeScript() + "\n");
|
85
|
+
buffer.append("end\n");
|
86
|
+
}
|
87
|
+
return buffer.toString();
|
88
|
+
}
|
89
|
+
|
90
|
+
private String runRakeScript() {
|
91
|
+
// The rake file generated by ARM, defines db:migrate task as default task
|
92
|
+
// so you could just run the default task here.
|
93
|
+
return "Rake.application.run";
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
And also, you may need the following packaging script in your ant war target, then you could write a Servlet to do migration on server startup:
|
98
|
+
|
99
|
+
<webinf dir="${java.project.dir}">
|
100
|
+
<include name="db/**/*"/>
|
101
|
+
<include name="config/**/*"/>
|
102
|
+
<include name="script/**/*"/>
|
103
|
+
<include name="vendor/**/*"/>
|
104
|
+
<include name="Rakefile"/>
|
105
|
+
</webinf>
|
106
|
+
|
107
|
+
== License
|
108
|
+
|
109
|
+
ARM is available under an MIT License Copyright (c) 2009 Flextao.
|
110
|
+
|
111
|
+
== Author
|
112
|
+
|
113
|
+
Li Xiao <xli@flextao.com>
|
data/Rakefile
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# Rakefile for ARM -*- ruby -*-
|
2
|
+
|
3
|
+
# Copyright 2009 by flextao.com (Li Xiao <xli@flextao.com>)
|
4
|
+
# All rights reserved.
|
5
|
+
|
6
|
+
require 'rake/rdoctask'
|
7
|
+
|
8
|
+
begin
|
9
|
+
require 'rubygems'
|
10
|
+
require 'rake/gempackagetask'
|
11
|
+
rescue Exception
|
12
|
+
nil
|
13
|
+
end
|
14
|
+
|
15
|
+
# The default task is run if rake is given no explicit arguments.
|
16
|
+
|
17
|
+
desc "Default Task"
|
18
|
+
task :default => :gem
|
19
|
+
|
20
|
+
# CVS Tasks ----------------------------------------------------------
|
21
|
+
|
22
|
+
# Create a task to build the RDOC documentation tree.
|
23
|
+
|
24
|
+
rd = Rake::RDocTask.new("rdoc") { |rdoc|
|
25
|
+
rdoc.rdoc_dir = 'html'
|
26
|
+
rdoc.template = 'html'
|
27
|
+
rdoc.title = "ARM -- ActiveRecord Migration"
|
28
|
+
rdoc.options << '--line-numbers' << '--inline-source' <<
|
29
|
+
'--main' << 'README.rdoc' <<
|
30
|
+
'--title' << '"ARM -- ActiveRecord Migration'
|
31
|
+
rdoc.rdoc_files.include('README.rdoc', 'MIT-LICENSE.txt', 'TODO', 'CHANGES')
|
32
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
33
|
+
}
|
34
|
+
|
35
|
+
# ====================================================================
|
36
|
+
# Create a task that will package the DTR software into distributable
|
37
|
+
# tar, zip and gem files.
|
38
|
+
|
39
|
+
if ! defined?(Gem)
|
40
|
+
puts "Package Target requires RubyGEMs"
|
41
|
+
else
|
42
|
+
|
43
|
+
gem_content = <<-GEM
|
44
|
+
Gem::Specification.new do |spec|
|
45
|
+
spec.name = 'arm'
|
46
|
+
spec.version = "0.0.1"
|
47
|
+
spec.summary = "ARM generates project skeleton for Java project to embed ActiveRecord Migration."
|
48
|
+
|
49
|
+
#### Dependencies and requirements.
|
50
|
+
spec.files = #{(Dir.glob("lib/**/*") + Dir.glob("skeleton/**/*") + ["bin/arm", "CHANGES", "arm.gemspec", "lib", "MIT-LICENSE.txt", "Rakefile", "README.rdoc", "TODO"]).inspect}
|
51
|
+
|
52
|
+
#### Load-time details: library and application (you will need one or both).
|
53
|
+
|
54
|
+
spec.require_path = 'lib' # Use these for libraries.
|
55
|
+
|
56
|
+
spec.bindir = "bin" # Use these for applications.
|
57
|
+
spec.executables = ["arm"]
|
58
|
+
spec.default_executable = "arm"
|
59
|
+
|
60
|
+
#### Documentation and testing.
|
61
|
+
|
62
|
+
spec.has_rdoc = true
|
63
|
+
spec.extra_rdoc_files = #{rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a.inspect}
|
64
|
+
spec.rdoc_options = #{rd.options.inspect}
|
65
|
+
|
66
|
+
#### Author and project details.
|
67
|
+
|
68
|
+
spec.author = "Li Xiao"
|
69
|
+
spec.email = "xli@flextao.com"
|
70
|
+
spec.homepage = "http://github.com/flextao/arm/tree/master"
|
71
|
+
end
|
72
|
+
GEM
|
73
|
+
File.open(File.dirname(__FILE__) + '/arm.gemspec', 'w') do |f|
|
74
|
+
f.write(gem_content)
|
75
|
+
end
|
76
|
+
|
77
|
+
#build gem package same steps with github
|
78
|
+
File.open(File.dirname(__FILE__) + '/arm.gemspec') do |f|
|
79
|
+
data = f.read
|
80
|
+
spec = nil
|
81
|
+
Thread.new { spec = eval("$SAFE = 3\n#{data}") }.join
|
82
|
+
package_task = Rake::GemPackageTask.new(spec) do |pkg|
|
83
|
+
#pkg.need_zip = true
|
84
|
+
#pkg.need_tar = true
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
data/TODO
ADDED
File without changes
|
data/arm.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = 'arm'
|
3
|
+
spec.version = "0.0.1"
|
4
|
+
spec.summary = "ARM generates project skeleton for Java project to embed ActiveRecord Migration."
|
5
|
+
|
6
|
+
#### Dependencies and requirements.
|
7
|
+
spec.files = ["lib/arm", "lib/arm/facade.rb", "lib/arm/skeleton_generator.rb", "lib/arm/tasks", "lib/arm/tasks/arm.rake", "lib/arm/tasks/arm.rb", "lib/arm.rb", "skeleton/config", "skeleton/config/database.yml.example", "skeleton/config/environment.rb", "skeleton/Rakefile", "skeleton/script", "skeleton/script/_jrubycleanup.bat", "skeleton/script/_jrubysetcp.bat", "skeleton/script/_jrubyvars.bat", "skeleton/script/_jrubyvmopts.bat", "skeleton/script/jrake", "skeleton/script/jrake.bat", "skeleton/vendor", "skeleton/vendor/ext", "skeleton/vendor/ext/activerecord-2.3.2", "skeleton/vendor/ext/activerecord-2.3.2/lib", "skeleton/vendor/ext/activerecord-2.3.2/lib/active_record", "skeleton/vendor/ext/activerecord-2.3.2/lib/active_record/schema_dumper.rb", "skeleton/vendor/ext/jdbc_tasks_postgre_fix.rb", "bin/arm", "CHANGES", "arm.gemspec", "lib", "MIT-LICENSE.txt", "Rakefile", "README.rdoc", "TODO"]
|
8
|
+
|
9
|
+
#### Load-time details: library and application (you will need one or both).
|
10
|
+
|
11
|
+
spec.require_path = 'lib' # Use these for libraries.
|
12
|
+
|
13
|
+
spec.bindir = "bin" # Use these for applications.
|
14
|
+
spec.executables = ["arm"]
|
15
|
+
spec.default_executable = "arm"
|
16
|
+
|
17
|
+
#### Documentation and testing.
|
18
|
+
|
19
|
+
spec.has_rdoc = true
|
20
|
+
spec.extra_rdoc_files = ["README.rdoc", "MIT-LICENSE.txt", "TODO", "CHANGES"]
|
21
|
+
spec.rdoc_options = ["--line-numbers", "--inline-source", "--main", "README.rdoc", "--title", "\"ARM -- ActiveRecord Migration"]
|
22
|
+
|
23
|
+
#### Author and project details.
|
24
|
+
|
25
|
+
spec.author = "Li Xiao"
|
26
|
+
spec.email = "xli@flextao.com"
|
27
|
+
spec.homepage = "http://github.com/flextao/arm/tree/master"
|
28
|
+
end
|
data/bin/arm
ADDED
data/lib/arm.rb
ADDED
data/lib/arm/facade.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
|
2
|
+
require 'arm/skeleton_generator'
|
3
|
+
|
4
|
+
module ARM
|
5
|
+
module Facade
|
6
|
+
def generate!
|
7
|
+
root = File.expand_path('.')
|
8
|
+
skeleton = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'skeleton'))
|
9
|
+
SkeletonGenerator.new(root, skeleton).generate!
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module ARM
|
5
|
+
class SkeletonGenerator
|
6
|
+
def initialize(root, skeleton)
|
7
|
+
@root = root
|
8
|
+
@skeleton = skeleton
|
9
|
+
end
|
10
|
+
|
11
|
+
def generate!
|
12
|
+
%w(
|
13
|
+
config
|
14
|
+
db
|
15
|
+
db/migrate
|
16
|
+
lib
|
17
|
+
script
|
18
|
+
vendor
|
19
|
+
vendor/gems
|
20
|
+
vendor/ext
|
21
|
+
).each { |path| copy_directory path }
|
22
|
+
copy_file('Rakefile')
|
23
|
+
end
|
24
|
+
|
25
|
+
def copy_file(path)
|
26
|
+
FileUtils.cp(File.join(@skeleton, path), @root)
|
27
|
+
end
|
28
|
+
|
29
|
+
def copy_directory(path)
|
30
|
+
skeleton_path = File.join(@skeleton, path)
|
31
|
+
if File.exist?(skeleton_path)
|
32
|
+
FileUtils.cp_r(skeleton_path, @root)
|
33
|
+
else
|
34
|
+
FileUtils.mkdir_p(File.join(@root, path))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
|
2
|
+
namespace :arm do
|
3
|
+
namespace :freeze do
|
4
|
+
desc "Lock this application to the current gems (by unpacking them into vendor/gems)"
|
5
|
+
task :gems do
|
6
|
+
require 'rubygems'
|
7
|
+
require 'rubygems/gem_runner'
|
8
|
+
|
9
|
+
activerecord_gems = %w(activerecord rails activesupport)
|
10
|
+
activerecord_gems_version = ENV['ACTIVERECORD_VERSION'] || '2.3.2'
|
11
|
+
|
12
|
+
gems = activerecord_gems.collect { |g| find_gem(g, activerecord_gems_version) }
|
13
|
+
gems << find_gem('activerecord-jdbc-adapter')
|
14
|
+
|
15
|
+
rm_rf GEMS_ROOT
|
16
|
+
mkdir_p GEMS_ROOT
|
17
|
+
|
18
|
+
begin
|
19
|
+
chdir(GEMS_ROOT) do
|
20
|
+
gems.each do |g|
|
21
|
+
puts "Freezing gem #{g.name} to #{g.version}"
|
22
|
+
Gem::GemRunner.new.run(["unpack", g.name, "--version", g.version.to_s])
|
23
|
+
mv(Dir.glob("#{g.name}*").first, g.name)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
rescue Exception
|
27
|
+
rm_rf GEMS_ROOT
|
28
|
+
raise
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def find_gem(name, version=nil)
|
35
|
+
g = version ? Gem.cache.find_name(name, "= #{version}").first : Gem.cache.find_name(name).sort_by { |g| g.version }.last
|
36
|
+
unless g
|
37
|
+
puts "No #{name} gem #{version} is installed. Do 'gem list #{name}' to see what you have available."
|
38
|
+
exit
|
39
|
+
end
|
40
|
+
g
|
41
|
+
end
|
data/skeleton/Rakefile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
|
2
|
+
RAILS_ENV = ENV['RAILS_ENV'] || 'development'
|
3
|
+
RAILS_ROOT = File.dirname(__FILE__) unless defined?(RAILS_ROOT)
|
4
|
+
ARM_ROOT = RAILS_ROOT
|
5
|
+
GEMS_ROOT = File.join(ARM_ROOT, 'vendor', 'gems')
|
6
|
+
|
7
|
+
if File.exist?(File.join(GEMS_ROOT, 'activerecord'))
|
8
|
+
|
9
|
+
Dir.entries(GEMS_ROOT).select { |p|
|
10
|
+
p.match(/^[^\.]/) and File.directory?(File.join(GEMS_ROOT, p, "lib"))
|
11
|
+
}.each { |p|
|
12
|
+
$:.unshift(File.join(GEMS_ROOT, p, "lib"))
|
13
|
+
}
|
14
|
+
|
15
|
+
require 'initializer'
|
16
|
+
require 'activerecord'
|
17
|
+
|
18
|
+
# only support activerecord 2.3.2 for dumpping string type id for table now
|
19
|
+
if ActiveRecord::VERSION::STRING == '2.3.2'
|
20
|
+
$:.unshift File.join(ARM_ROOT, 'vendor', 'ext', 'activerecord-2.3.2', 'lib')
|
21
|
+
end
|
22
|
+
|
23
|
+
arm_log_dir = File.exists?('logs') ? logs : (File.exists?('log') ? 'log' : '')
|
24
|
+
ActiveRecord::Base.logger = Logger.new(File.join(ARM_ROOT, arm_log_dir, 'arm.log'))
|
25
|
+
ActiveRecord::Base.logger.level = Logger::DEBUG
|
26
|
+
ActiveRecord::Base.configurations = Rails::Configuration.new.database_configuration
|
27
|
+
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[RAILS_ENV])
|
28
|
+
|
29
|
+
# load rails tasks we need
|
30
|
+
RAILS_GEM_DIR = Dir.entries(GEMS_ROOT).detect {|path| path =~ /rails/}
|
31
|
+
load File.join(GEMS_ROOT, RAILS_GEM_DIR, 'lib', 'tasks', 'misc.rake')
|
32
|
+
load File.join(GEMS_ROOT, RAILS_GEM_DIR, 'lib', 'tasks', 'databases.rake')
|
33
|
+
|
34
|
+
# fix activerecord-jdbc-adapter 0.9.1 postgre adapter drop database problem
|
35
|
+
if ActiveRecord::Base.configurations[RAILS_ENV]['driver'] =~ /postgres/
|
36
|
+
load File.join(ARM_ROOT, 'vendor', 'ext', 'jdbc_tasks_postgre_fix.rb')
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "do db:migrate task, it's for Migrator.java to do migration easier"
|
40
|
+
task :default => ['db:migrate']
|
41
|
+
|
42
|
+
task :test do
|
43
|
+
# in misc.rake, defined :default => :test, so we need define an empty test task here
|
44
|
+
end
|
45
|
+
else
|
46
|
+
require 'arm/tasks/arm'
|
47
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
production:
|
2
|
+
adapter: jdbc
|
3
|
+
driver: org.postgresql.Driver
|
4
|
+
username: postgres
|
5
|
+
password: sa
|
6
|
+
url: jdbc:postgresql://localhost/app_name
|
7
|
+
|
8
|
+
development:
|
9
|
+
adapter: jdbc
|
10
|
+
driver: org.postgresql.Driver
|
11
|
+
username: postgres
|
12
|
+
password: sa
|
13
|
+
url: jdbc:postgresql://localhost/app_name
|
14
|
+
|
15
|
+
test:
|
16
|
+
adapter: jdbc
|
17
|
+
driver: org.postgresql.Driver
|
18
|
+
username: postgres
|
19
|
+
password: sa
|
20
|
+
url: jdbc:postgresql://localhost/app_name_test
|
File without changes
|
@@ -0,0 +1,21 @@
|
|
1
|
+
@echo off
|
2
|
+
|
3
|
+
rem ----- Restore Environment Variables ---------------------------------------
|
4
|
+
|
5
|
+
:cleanup
|
6
|
+
set JRUBY_BASE=%_JRUBY_BASE%
|
7
|
+
set _JRUBY_BASE=
|
8
|
+
set JRUBY_HOME=%_JRUBY_HOME%
|
9
|
+
set _JRUBY_HOME=
|
10
|
+
set CLASSPATH=%_CLASSPATH%
|
11
|
+
set _CLASSPATH=
|
12
|
+
set CP=%_CP%
|
13
|
+
set JAVA_COMMAND=%_JAVA_COMMAND%
|
14
|
+
set _LIBJARS=
|
15
|
+
set _RUNJAVA=
|
16
|
+
set _STARTJAVA=
|
17
|
+
set _JAVA_COMMAND=
|
18
|
+
set _VM_OPTS=
|
19
|
+
set _RUBY_OPTS=
|
20
|
+
:finish
|
21
|
+
exit /b %E%
|
@@ -0,0 +1,91 @@
|
|
1
|
+
@echo off
|
2
|
+
rem Environment Variable Prequisites:
|
3
|
+
rem
|
4
|
+
rem JRUBY_BASE (Optional) Base directory for resolving dynamic portions
|
5
|
+
rem of a JRuby installation. If not present, resolves to
|
6
|
+
rem the same directory that JRUBY_HOME points to.
|
7
|
+
rem
|
8
|
+
rem JRUBY_HOME (Optional) May point at your JRuby "build" directory.
|
9
|
+
rem If not present, the current working directory is assumed.
|
10
|
+
rem
|
11
|
+
rem JRUBY_OPTS (Optional) Default JRuby command line args.
|
12
|
+
rem
|
13
|
+
rem JAVA_HOME Must point at your Java Development Kit installation.
|
14
|
+
rem
|
15
|
+
|
16
|
+
rem ----- Save Environment Variables That May Change --------------------------
|
17
|
+
|
18
|
+
set CLASSPATH=lib
|
19
|
+
|
20
|
+
set _JRUBY_BASE=%JRUBY_BASE%
|
21
|
+
set _JRUBY_HOME=%JRUBY_HOME%
|
22
|
+
set _CLASSPATH=%CLASSPATH%
|
23
|
+
set _CP=%CP%
|
24
|
+
|
25
|
+
|
26
|
+
rem ----- Verify and Set Required Environment Variables -----------------------
|
27
|
+
|
28
|
+
if not "%JAVA_HOME%" == "" goto gotJava
|
29
|
+
echo You must set JAVA_HOME to point at your Java Development Kit installation
|
30
|
+
goto cleanup
|
31
|
+
:gotJava
|
32
|
+
|
33
|
+
if not "%JRUBY_HOME%" == "" goto gotHome
|
34
|
+
set JRUBY_HOME=%~dp0..
|
35
|
+
:gotHome
|
36
|
+
|
37
|
+
if not "%JRUBY_BASE%" == "" goto gotBase
|
38
|
+
set JRUBY_BASE=%JRUBY_HOME%
|
39
|
+
:gotBase
|
40
|
+
|
41
|
+
|
42
|
+
rem ----- Prepare Appropriate Java Execution Commands -------------------------
|
43
|
+
|
44
|
+
if not "%JAVA_COMMAND%" == "" goto gotCommand
|
45
|
+
set _JAVA_COMMAND=%JAVA_COMMAND%
|
46
|
+
set JAVA_COMMAND=java
|
47
|
+
:gotCommand
|
48
|
+
|
49
|
+
if not "%OS%" == "Windows_NT" goto noTitle
|
50
|
+
rem set _STARTJAVA=start "JRuby" "%JAVA_HOME%\bin\java"
|
51
|
+
set _STARTJAVA=%JAVA_HOME%\bin\%JAVA_COMMAND%
|
52
|
+
goto gotTitle
|
53
|
+
:noTitle
|
54
|
+
rem set _STARTJAVA=start "%JAVA_HOME%\bin\java"
|
55
|
+
set _STARTJAVA=%JAVA_HOME%\bin\%JAVA_COMMAND%
|
56
|
+
:gotTitle
|
57
|
+
|
58
|
+
rem ----- Set up the VM options
|
59
|
+
call "%~dp0_jrubyvmopts.bat" %*
|
60
|
+
set _RUNJAVA="%JAVA_HOME%\bin\java"
|
61
|
+
|
62
|
+
rem ----- Set Up The Runtime Classpath ----------------------------------------
|
63
|
+
|
64
|
+
for %%i in ("%JRUBY_HOME%\lib\*.jar") do @call :setcp %%i
|
65
|
+
|
66
|
+
if not "%CLASSPATH%" == "" goto gotCP
|
67
|
+
set CLASSPATH=%CP%
|
68
|
+
goto doneCP
|
69
|
+
:gotCP
|
70
|
+
set CLASSPATH=%CP%;%CLASSPATH%
|
71
|
+
:doneCP
|
72
|
+
|
73
|
+
goto :EOF
|
74
|
+
|
75
|
+
rem Setcp subroutine
|
76
|
+
:setcp
|
77
|
+
if not "%CP%" == "" goto add
|
78
|
+
|
79
|
+
set CP=%*
|
80
|
+
goto :EOF
|
81
|
+
|
82
|
+
:add
|
83
|
+
set CP=%CP%;%*
|
84
|
+
|
85
|
+
goto :EOF
|
86
|
+
|
87
|
+
rem echo Using JRUBY_BASE: %JRUBY_BASE%
|
88
|
+
rem echo Using JRUBY_HOME: %JRUBY_HOME%
|
89
|
+
rem echo Using CLASSPATH: %CLASSPATH%
|
90
|
+
rem echo Using JAVA_HOME: %JAVA_HOME%
|
91
|
+
rem echo Using Args: %*
|
@@ -0,0 +1,81 @@
|
|
1
|
+
@echo off
|
2
|
+
set _MEM=-Xmx378m
|
3
|
+
set _STK=-Xss1024k
|
4
|
+
set _VM_OPTS=
|
5
|
+
set _RUBY_OPTS=
|
6
|
+
set _DFLT_VM_OPTS=%JAVA_OPTS%
|
7
|
+
|
8
|
+
rem
|
9
|
+
rem Can you believe I'm rewriting batch arg processing in batch files because batch
|
10
|
+
rem file arg processing sucks so bad? Can you believe this is even possible?
|
11
|
+
rem http://support.microsoft.com/kb/71247
|
12
|
+
|
13
|
+
rem escape any quotes. use -q == ", -d == -.
|
14
|
+
set _ARGS=%*
|
15
|
+
if not defined _ARGS goto vmoptsDone
|
16
|
+
set _ARGS=%_ARGS:-=-d%
|
17
|
+
set _ARGS=%_ARGS:"=-q%
|
18
|
+
rem prequote all args for 'for' statement
|
19
|
+
set _ARGS="%_ARGS%"
|
20
|
+
|
21
|
+
:vmoptsLoop
|
22
|
+
rem split args by spaces into first and rest
|
23
|
+
for /f "tokens=1,*" %%i in (%_ARGS%) do call :getarg "%%i" "%%j"
|
24
|
+
goto procarg
|
25
|
+
|
26
|
+
:getarg
|
27
|
+
rem remove quotes around first arg
|
28
|
+
for %%i in (%1) do set _CMP=%%~i
|
29
|
+
rem set the rest args (note, they're all quoted and ready to go)
|
30
|
+
set _ARGS=%2
|
31
|
+
rem return to line 18
|
32
|
+
goto :EOF
|
33
|
+
|
34
|
+
:procarg
|
35
|
+
if "%_CMP%" == "" goto vmoptsDone
|
36
|
+
|
37
|
+
rem now unescape -q and -d
|
38
|
+
set _CMP=%_CMP:-q="%
|
39
|
+
set _CMP=%_CMP:-d=-%
|
40
|
+
set _CMP1=%_CMP:~0,1%
|
41
|
+
set _CMP2=%_CMP:~0,2%
|
42
|
+
|
43
|
+
rem detect first character is a quote; skip directly to rubyarg
|
44
|
+
rem this avoids a batch syntax error
|
45
|
+
if "%_CMP1:"=\\%" == "\\" goto rubyarg
|
46
|
+
|
47
|
+
rem removing quote avoids a batch syntax error
|
48
|
+
if "%_CMP2:"=\\%" == "-J" goto jvmarg
|
49
|
+
|
50
|
+
:rubyarg
|
51
|
+
set _RUBY_OPTS=%_RUBY_OPTS% %_CMP%
|
52
|
+
goto vmoptsNext
|
53
|
+
|
54
|
+
:jvmarg
|
55
|
+
set _VAL=%_CMP:~2%
|
56
|
+
|
57
|
+
if "%_VAL:~0,4%" == "-Xmx" (
|
58
|
+
set _MEM=%_VAL%
|
59
|
+
goto vmoptsNext
|
60
|
+
)
|
61
|
+
|
62
|
+
if "%_VAL:~0,4%" == "-Xss" (
|
63
|
+
set _STK=%_VAL%
|
64
|
+
goto vmoptsNext
|
65
|
+
)
|
66
|
+
|
67
|
+
set _VM_OPTS=%_VM_OPTS% %_VAL%
|
68
|
+
|
69
|
+
:vmoptsNext
|
70
|
+
set _CMP=
|
71
|
+
goto vmoptsLoop
|
72
|
+
|
73
|
+
:vmoptsDone
|
74
|
+
set _VM_OPTS=%_VM_OPTS% %_MEM% %_STK% %_DFLT_VM_OPTS%
|
75
|
+
set _DFLT_VM_OPTS=
|
76
|
+
set _MEM=
|
77
|
+
set _STK=
|
78
|
+
set _ARGS=
|
79
|
+
set _VAL=
|
80
|
+
set _CMP=
|
81
|
+
set _CMP1=
|
@@ -0,0 +1,115 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
dir="`dirname $0`/.."
|
4
|
+
export CLASSPATH=$dir/lib
|
5
|
+
|
6
|
+
cygwin=false
|
7
|
+
|
8
|
+
# ----- Identify OS we are running under --------------------------------------
|
9
|
+
case "`uname`" in
|
10
|
+
CYGWIN*) cygwin=true
|
11
|
+
esac
|
12
|
+
|
13
|
+
# ----- Verify and Set Required Environment Variables -------------------------
|
14
|
+
|
15
|
+
if [ -z "$JRUBY_HOME" ] ; then
|
16
|
+
## resolve links - $0 may be a link to home
|
17
|
+
PRG=$0
|
18
|
+
progname=`basename "$0"`
|
19
|
+
|
20
|
+
while [ -h "$PRG" ] ; do
|
21
|
+
ls=`ls -ld "$PRG"`
|
22
|
+
link=`expr "$ls" : '.*-> \(.*\)$'`
|
23
|
+
if expr "$link" : '.*/.*' > /dev/null; then
|
24
|
+
PRG="$link"
|
25
|
+
else
|
26
|
+
PRG="`dirname $PRG`/$link"
|
27
|
+
fi
|
28
|
+
done
|
29
|
+
|
30
|
+
JRUBY_HOME_1=`dirname "$PRG"` # the ./bin dir
|
31
|
+
JRUBY_HOME_1=`dirname "$JRUBY_HOME_1"` # the . dir
|
32
|
+
if [ -d "${JRUBY_HOME_1}/lib" ] ; then
|
33
|
+
JRUBY_HOME="${JRUBY_HOME_1}"
|
34
|
+
fi
|
35
|
+
else
|
36
|
+
if $cygwin; then
|
37
|
+
JRUBY_HOME=`cygpath -u "$JRUBY_HOME"`
|
38
|
+
fi
|
39
|
+
fi
|
40
|
+
|
41
|
+
if [ -z "$JAVA_HOME" ] ; then
|
42
|
+
JAVA_CMD='java'
|
43
|
+
else
|
44
|
+
if $cygwin; then
|
45
|
+
JAVA_HOME=`cygpath -u "$JAVA_HOME"`
|
46
|
+
fi
|
47
|
+
JAVA_CMD="$JAVA_HOME/bin/java"
|
48
|
+
fi
|
49
|
+
|
50
|
+
JRUBY_SHELL=/bin/sh
|
51
|
+
|
52
|
+
# ----- Set Up The System Classpath -------------------------------------------
|
53
|
+
|
54
|
+
if [ "$JRUBY_PARENT_CLASSPATH" != "" ]; then
|
55
|
+
# Use same classpath propagated from parent jruby
|
56
|
+
CP=$JRUBY_PARENT_CLASSPATH
|
57
|
+
else
|
58
|
+
if [ "$CLASSPATH" != "" ]; then
|
59
|
+
CP="$CLASSPATH"
|
60
|
+
if $cygwin; then
|
61
|
+
CP=`cygpath -p -u "$CP"`
|
62
|
+
fi
|
63
|
+
else
|
64
|
+
CP=""
|
65
|
+
fi
|
66
|
+
|
67
|
+
CP_DELIMETER=":"
|
68
|
+
|
69
|
+
# add necessary jars for command-line execution
|
70
|
+
for j in "$JRUBY_HOME"/lib/*.jar; do
|
71
|
+
if [ "$CP" ]; then
|
72
|
+
CP="$CP$CP_DELIMETER$j"
|
73
|
+
else
|
74
|
+
CP="$j"
|
75
|
+
fi
|
76
|
+
done
|
77
|
+
|
78
|
+
if $cygwin; then
|
79
|
+
CP=`cygpath -p -w "$CP"`
|
80
|
+
fi
|
81
|
+
fi
|
82
|
+
|
83
|
+
|
84
|
+
# ----- Execute The Requested Command -----------------------------------------
|
85
|
+
|
86
|
+
DEBUG=""
|
87
|
+
if [ "$1" = "JAVA_DEBUG" ]; then
|
88
|
+
DEBUG="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y"
|
89
|
+
shift
|
90
|
+
else
|
91
|
+
if [ "$1" = "JPROFILER" ]; then
|
92
|
+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JPROFILER_PATH/bin/linux-x86
|
93
|
+
DEBUG="-Xrunjprofiler:port=8000,noexit -Xbootclasspath/a:/$JPROFILER_PATH/bin/agent.jar"
|
94
|
+
shift
|
95
|
+
else if [ "$1" = "HPROF" ]; then
|
96
|
+
DEBUG="-Xrunhprof:cpu=samples"
|
97
|
+
shift
|
98
|
+
fi
|
99
|
+
fi
|
100
|
+
fi
|
101
|
+
|
102
|
+
if $cygwin; then
|
103
|
+
JAVA_HOME=`cygpath --mixed "$JAVA_HOME"`
|
104
|
+
fi
|
105
|
+
|
106
|
+
if [ "$1" = "SERVER" ]; then
|
107
|
+
DEBUG="-server"
|
108
|
+
shift
|
109
|
+
fi
|
110
|
+
|
111
|
+
exec "$JAVA_CMD" $JAVA_OPTS $DEBUG -Xmx1024m -XX:MaxPermSize=128m -Xss1024k -Xverify:none -da -classpath "$CP" \
|
112
|
+
-XX:+HeapDumpOnOutOfMemoryError \
|
113
|
+
"-Djruby.jit.threshold=1000" \
|
114
|
+
"-Djruby.jit.logging=false" org.jruby.Main -S rake "$@"
|
115
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
@echo off
|
2
|
+
rem ---------------------------------------------------------------------------
|
3
|
+
rem jrake.bat - Start JRake -- build super star java version :-)
|
4
|
+
rem
|
5
|
+
rem for info on environment variables, see internal batch script _jrubyvars.bat
|
6
|
+
|
7
|
+
call "%~dp0_jrubyvars.bat" %*
|
8
|
+
|
9
|
+
"%_STARTJAVA%" %_VM_OPTS% -cp "%CLASSPATH%" -Djruby.shell="cmd.exe" org.jruby.Main %JRUBY_OPTS% -S rake %*
|
10
|
+
set E=%ERRORLEVEL%
|
11
|
+
|
12
|
+
call "%~dp0_jrubycleanup.bat"
|
@@ -0,0 +1,182 @@
|
|
1
|
+
require 'stringio'
|
2
|
+
require 'bigdecimal'
|
3
|
+
|
4
|
+
module ActiveRecord
|
5
|
+
# This class is used to dump the database schema for some connection to some
|
6
|
+
# output format (i.e., ActiveRecord::Schema).
|
7
|
+
class SchemaDumper #:nodoc:
|
8
|
+
private_class_method :new
|
9
|
+
|
10
|
+
##
|
11
|
+
# :singleton-method:
|
12
|
+
# A list of tables which should not be dumped to the schema.
|
13
|
+
# Acceptable values are strings as well as regexp.
|
14
|
+
# This setting is only used if ActiveRecord::Base.schema_format == :ruby
|
15
|
+
cattr_accessor :ignore_tables
|
16
|
+
@@ignore_tables = []
|
17
|
+
|
18
|
+
def self.dump(connection=ActiveRecord::Base.connection, stream=STDOUT)
|
19
|
+
new(connection).dump(stream)
|
20
|
+
stream
|
21
|
+
end
|
22
|
+
|
23
|
+
def dump(stream)
|
24
|
+
header(stream)
|
25
|
+
tables(stream)
|
26
|
+
trailer(stream)
|
27
|
+
stream
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def initialize(connection)
|
33
|
+
@connection = connection
|
34
|
+
@types = @connection.native_database_types
|
35
|
+
@version = Migrator::current_version rescue nil
|
36
|
+
end
|
37
|
+
|
38
|
+
def header(stream)
|
39
|
+
define_params = @version ? ":version => #{@version}" : ""
|
40
|
+
|
41
|
+
stream.puts <<HEADER
|
42
|
+
# This file is auto-generated from the current state of the database. Instead of editing this file,
|
43
|
+
# please use the migrations feature of Active Record to incrementally modify your database, and
|
44
|
+
# then regenerate this schema definition.
|
45
|
+
#
|
46
|
+
# Note that this schema.rb definition is the authoritative source for your database schema. If you need
|
47
|
+
# to create the application database on another system, you should be using db:schema:load, not running
|
48
|
+
# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
49
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
50
|
+
#
|
51
|
+
# It's strongly recommended to check this file into your version control system.
|
52
|
+
|
53
|
+
ActiveRecord::Schema.define(#{define_params}) do
|
54
|
+
|
55
|
+
HEADER
|
56
|
+
end
|
57
|
+
|
58
|
+
def trailer(stream)
|
59
|
+
stream.puts "end"
|
60
|
+
end
|
61
|
+
|
62
|
+
def tables(stream)
|
63
|
+
@connection.tables.sort.each do |tbl|
|
64
|
+
next if ['schema_migrations', ignore_tables].flatten.any? do |ignored|
|
65
|
+
case ignored
|
66
|
+
when String; tbl == ignored
|
67
|
+
when Regexp; tbl =~ ignored
|
68
|
+
else
|
69
|
+
raise StandardError, 'ActiveRecord::SchemaDumper.ignore_tables accepts an array of String and / or Regexp values.'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
table(tbl, stream)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def table(table, stream)
|
77
|
+
columns = @connection.columns(table)
|
78
|
+
begin
|
79
|
+
tbl = StringIO.new
|
80
|
+
|
81
|
+
if @connection.respond_to?(:pk_and_sequence_for)
|
82
|
+
pk, pk_seq = @connection.pk_and_sequence_for(table)
|
83
|
+
end
|
84
|
+
pk ||= 'id'
|
85
|
+
|
86
|
+
tbl.print " create_table #{table.inspect}"
|
87
|
+
if column = columns.detect { |c| c.name == pk } # changed line
|
88
|
+
if pk != 'id'
|
89
|
+
tbl.print %Q(, :primary_key => "#{pk}")
|
90
|
+
end
|
91
|
+
if column.type != :integer # added line
|
92
|
+
tbl.print ", :id => false" # added line
|
93
|
+
end # added line
|
94
|
+
else
|
95
|
+
tbl.print ", :id => false"
|
96
|
+
end
|
97
|
+
tbl.print ", :force => true"
|
98
|
+
tbl.puts " do |t|"
|
99
|
+
|
100
|
+
column_specs = columns.map do |column|
|
101
|
+
raise StandardError, "Unknown type '#{column.sql_type}' for column '#{column.name}'" if @types[column.type].nil?
|
102
|
+
next if column.name == pk && column.type == :integer # changed line
|
103
|
+
spec = {}
|
104
|
+
spec[:name] = column.name.inspect
|
105
|
+
spec[:type] = column.type.to_s
|
106
|
+
spec[:limit] = column.limit.inspect if column.limit != @types[column.type][:limit] && column.type != :decimal
|
107
|
+
spec[:precision] = column.precision.inspect if !column.precision.nil?
|
108
|
+
spec[:scale] = column.scale.inspect if !column.scale.nil?
|
109
|
+
spec[:null] = 'false' if !column.null
|
110
|
+
spec[:default] = default_string(column.default) if column.has_default?
|
111
|
+
(spec.keys - [:name, :type]).each{ |k| spec[k].insert(0, "#{k.inspect} => ")}
|
112
|
+
spec
|
113
|
+
end.compact
|
114
|
+
|
115
|
+
# find all migration keys used in this table
|
116
|
+
keys = [:name, :limit, :precision, :scale, :default, :null] & column_specs.map(&:keys).flatten
|
117
|
+
|
118
|
+
# figure out the lengths for each column based on above keys
|
119
|
+
lengths = keys.map{ |key| column_specs.map{ |spec| spec[key] ? spec[key].length + 2 : 0 }.max }
|
120
|
+
|
121
|
+
# the string we're going to sprintf our values against, with standardized column widths
|
122
|
+
format_string = lengths.map{ |len| "%-#{len}s" }
|
123
|
+
|
124
|
+
# find the max length for the 'type' column, which is special
|
125
|
+
type_length = column_specs.map{ |column| column[:type].length }.max
|
126
|
+
|
127
|
+
# add column type definition to our format string
|
128
|
+
format_string.unshift " t.%-#{type_length}s "
|
129
|
+
|
130
|
+
format_string *= ''
|
131
|
+
|
132
|
+
column_specs.each do |colspec|
|
133
|
+
values = keys.zip(lengths).map{ |key, len| colspec.key?(key) ? colspec[key] + ", " : " " * len }
|
134
|
+
values.unshift colspec[:type]
|
135
|
+
tbl.print((format_string % values).gsub(/,\s*$/, ''))
|
136
|
+
tbl.puts
|
137
|
+
end
|
138
|
+
|
139
|
+
tbl.puts " end"
|
140
|
+
tbl.puts
|
141
|
+
|
142
|
+
indexes(table, tbl)
|
143
|
+
|
144
|
+
tbl.rewind
|
145
|
+
stream.print tbl.read
|
146
|
+
rescue => e
|
147
|
+
stream.puts "# Could not dump table #{table.inspect} because of following #{e.class}"
|
148
|
+
stream.puts "# #{e.message}"
|
149
|
+
stream.puts
|
150
|
+
end
|
151
|
+
|
152
|
+
stream
|
153
|
+
end
|
154
|
+
|
155
|
+
def default_string(value)
|
156
|
+
case value
|
157
|
+
when BigDecimal
|
158
|
+
value.to_s
|
159
|
+
when Date, DateTime, Time
|
160
|
+
"'" + value.to_s(:db) + "'"
|
161
|
+
else
|
162
|
+
value.inspect
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def indexes(table, stream)
|
167
|
+
if (indexes = @connection.indexes(table)).any?
|
168
|
+
add_index_statements = indexes.map do |index|
|
169
|
+
statment_parts = [ ('add_index ' + index.table.inspect) ]
|
170
|
+
statment_parts << index.columns.inspect
|
171
|
+
statment_parts << (':name => ' + index.name.inspect)
|
172
|
+
statment_parts << ':unique => true' if index.unique
|
173
|
+
|
174
|
+
' ' + statment_parts.join(', ')
|
175
|
+
end
|
176
|
+
|
177
|
+
stream.puts add_index_statements.sort.join("\n")
|
178
|
+
stream.puts
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
def fix_postgres_db_connection(config)
|
3
|
+
if config['driver'] =~ /postgresql/i # changed line
|
4
|
+
if config['url']
|
5
|
+
db = config['url'][/\/([^\/]*)$/, 1]
|
6
|
+
config['url'] = config['url'].gsub(/\/([^\/]*)$/, "/postgres") if db # changed line
|
7
|
+
else
|
8
|
+
db = config['database']
|
9
|
+
config['database'] = 'postgres'
|
10
|
+
end
|
11
|
+
ActiveRecord::Base.establish_connection(config)
|
12
|
+
else
|
13
|
+
ActiveRecord::Base.establish_connection(config)
|
14
|
+
db = ActiveRecord::Base.connection.database_name
|
15
|
+
end
|
16
|
+
db
|
17
|
+
end
|
18
|
+
|
19
|
+
def drop_database(config)
|
20
|
+
db = fix_postgres_db_connection(config.dup)
|
21
|
+
ActiveRecord::Base.connection.drop_database(db)
|
22
|
+
ActiveRecord::Base.establish_connection(config)
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_database(config)
|
26
|
+
db = fix_postgres_db_connection(config.dup)
|
27
|
+
ActiveRecord::Base.connection.create_database(db)
|
28
|
+
ActiveRecord::Base.establish_connection(config)
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: flextao-arm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Li Xiao
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-05-16 00:00:00 -07:00
|
13
|
+
default_executable: arm
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: xli@flextao.com
|
18
|
+
executables:
|
19
|
+
- arm
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.rdoc
|
24
|
+
- MIT-LICENSE.txt
|
25
|
+
- TODO
|
26
|
+
- CHANGES
|
27
|
+
files:
|
28
|
+
- lib/arm
|
29
|
+
- lib/arm/facade.rb
|
30
|
+
- lib/arm/skeleton_generator.rb
|
31
|
+
- lib/arm/tasks
|
32
|
+
- lib/arm/tasks/arm.rake
|
33
|
+
- lib/arm/tasks/arm.rb
|
34
|
+
- lib/arm.rb
|
35
|
+
- skeleton/config
|
36
|
+
- skeleton/config/database.yml.example
|
37
|
+
- skeleton/config/environment.rb
|
38
|
+
- skeleton/Rakefile
|
39
|
+
- skeleton/script
|
40
|
+
- skeleton/script/_jrubycleanup.bat
|
41
|
+
- skeleton/script/_jrubysetcp.bat
|
42
|
+
- skeleton/script/_jrubyvars.bat
|
43
|
+
- skeleton/script/_jrubyvmopts.bat
|
44
|
+
- skeleton/script/jrake
|
45
|
+
- skeleton/script/jrake.bat
|
46
|
+
- skeleton/vendor
|
47
|
+
- skeleton/vendor/ext
|
48
|
+
- skeleton/vendor/ext/activerecord-2.3.2
|
49
|
+
- skeleton/vendor/ext/activerecord-2.3.2/lib
|
50
|
+
- skeleton/vendor/ext/activerecord-2.3.2/lib/active_record
|
51
|
+
- skeleton/vendor/ext/activerecord-2.3.2/lib/active_record/schema_dumper.rb
|
52
|
+
- skeleton/vendor/ext/jdbc_tasks_postgre_fix.rb
|
53
|
+
- bin/arm
|
54
|
+
- CHANGES
|
55
|
+
- arm.gemspec
|
56
|
+
- lib
|
57
|
+
- MIT-LICENSE.txt
|
58
|
+
- Rakefile
|
59
|
+
- README.rdoc
|
60
|
+
- TODO
|
61
|
+
has_rdoc: true
|
62
|
+
homepage: http://github.com/flextao/arm/tree/master
|
63
|
+
licenses:
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options:
|
66
|
+
- --line-numbers
|
67
|
+
- --inline-source
|
68
|
+
- --main
|
69
|
+
- README.rdoc
|
70
|
+
- --title
|
71
|
+
- "\"ARM -- ActiveRecord Migration"
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "0"
|
79
|
+
version:
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: "0"
|
85
|
+
version:
|
86
|
+
requirements: []
|
87
|
+
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 1.3.5
|
90
|
+
signing_key:
|
91
|
+
specification_version: 2
|
92
|
+
summary: ARM generates project skeleton for Java project to embed ActiveRecord Migration.
|
93
|
+
test_files: []
|
94
|
+
|