mack 0.4.7 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +21 -2
- data/README +1 -4
- data/bin/mack +2 -2
- data/lib/errors/errors.rb +1 -10
- data/lib/generators/mack_application_generator/manifest.yml +5 -1
- data/lib/generators/mack_application_generator/templates/config/database.yml.template +45 -1
- data/lib/generators/mack_application_generator/templates/test/test_helper.rb.template +1 -1
- data/lib/generators/plugin_generator/templates/vendor/plugins/{<%= @plugin_name %> → %=@plugin_name%}/init.rb.template +0 -0
- data/lib/generators/plugin_generator/templates/vendor/plugins/{<%= @plugin_name %>/lib/<%= @plugin_name %>.rb.template → %=@plugin_name%/lib/%=@plugin_name%.rb.template} +0 -0
- data/lib/generators/plugin_generator/templates/vendor/plugins/{<%= @plugin_name %>/lib/tasks/<%= @plugin_name %>_tasks.rake.template → %=@plugin_name%/lib/tasks/%=@plugin_name%_tasks.rake.template} +0 -0
- data/lib/initialization/configuration.rb +28 -6
- data/lib/initialization/console.rb +2 -0
- data/lib/initialization/initializer.rb +23 -36
- data/lib/initialization/initializers/logging.rb +2 -2
- data/lib/initialization/initializers/orm_support.rb +4 -63
- data/lib/initialization/initializers/plugins.rb +1 -1
- data/lib/initialization/server/simple_server.rb +0 -2
- data/lib/mack.rb +2 -2
- data/lib/mack_tasks.rb +6 -0
- data/lib/rendering/base.rb +1 -1
- data/lib/rendering/classes/action.rb +1 -1
- data/lib/rendering/classes/public.rb +1 -1
- data/lib/rendering/classes/url.rb +1 -0
- data/lib/rendering/classes/xml.rb +1 -1
- data/lib/sea_level/controller_base.rb +19 -10
- data/lib/sea_level/helpers/view_helpers/html_helpers.rb +96 -11
- data/lib/sea_level/helpers/view_helpers/string_helpers.rb +22 -0
- data/lib/sea_level/uploaded_file.rb +1 -0
- data/lib/sea_level/view_binder.rb +14 -11
- data/lib/tasks/cachetastic_tasks.rake +11 -11
- data/lib/tasks/mack_server_tasks.rake +3 -3
- data/lib/tasks/mack_tasks.rake +2 -5
- data/lib/tasks/rake_rules.rake +1 -2
- data/lib/tasks/test_tasks.rake +22 -1
- data/lib/test_extensions/test_case.rb +50 -0
- data/lib/test_extensions/test_helpers.rb +22 -5
- metadata +30 -30
- data/lib/generators/genosaurus_helpers.rb +0 -38
- data/lib/generators/migration_generator/migration_generator.rb +0 -67
- data/lib/generators/migration_generator/templates/db/migrations/<%=@migration_name%>.rb.template +0 -31
- data/lib/generators/model_column.rb +0 -55
- data/lib/generators/model_generator/manifest.yml +0 -11
- data/lib/generators/model_generator/model_generator.rb +0 -93
- data/lib/generators/model_generator/templates/active_record.rb.template +0 -2
- data/lib/generators/model_generator/templates/data_mapper.rb.template +0 -11
- data/lib/generators/model_generator/templates/test.rb.template +0 -9
- data/lib/generators/scaffold_generator/manifest.yml +0 -31
- data/lib/generators/scaffold_generator/scaffold_generator.rb +0 -43
- data/lib/generators/scaffold_generator/templates/generic/app/controllers/controller.rb.template +0 -50
- data/lib/generators/scaffold_generator/templates/generic/app/views/edit.html.erb.template +0 -20
- data/lib/generators/scaffold_generator/templates/generic/app/views/index.html.erb.template +0 -41
- data/lib/generators/scaffold_generator/templates/generic/app/views/new.html.erb.template +0 -19
- data/lib/generators/scaffold_generator/templates/generic/app/views/show.html.erb.template +0 -12
- data/lib/generators/scaffold_generator/templates/no_orm/controller.rb.template +0 -38
- data/lib/generators/scaffold_generator/templates/test.rb.template +0 -9
- data/lib/sea_level/helpers/view_helpers/orm_helpers.rb +0 -87
- data/lib/tasks/db_tasks.rake +0 -94
- data/lib/utils/html.rb +0 -104
data/CHANGELOG
CHANGED
@@ -1,5 +1,24 @@
|
|
1
|
+
===0.5.0
|
2
|
+
* Added rake db:create and db:create:all rake tasks.
|
3
|
+
* Refactored out constants, such as MACK_ROOT and MACK_ENV and made them into Mack::Configuration.env, Mack::Configuration.root, etc...
|
4
|
+
* Added test:stats and test:coverage Rake tasks.
|
5
|
+
* Removed support for ActiveRecord and DataMapper and moved them into their own gems.
|
6
|
+
* Fixed a bug where yields in ERB weren't giving the desired results.
|
7
|
+
* DataMapper database.yml file can now be nested, and is generated as such.
|
8
|
+
* Cleaned up some tests, and refactored the HTML generation stuff.
|
9
|
+
* Fixed a bug with the scaffold generating 'bad' methods instead of 'post'
|
10
|
+
* Made error_messages_for more compatible with DataMapper.
|
11
|
+
* Fixed a bug loading url.rb and uploaded_file.rb found by Phil Darnowsky
|
12
|
+
* [dsutedja] Render method (in controller_base) now accepts response status code.
|
13
|
+
* gem: mack_ruby_core_extensions 0.1.23
|
14
|
+
* gem: genosaurus 1.1.4
|
15
|
+
* gem: datamapper 0.3.2
|
16
|
+
* gem: rcov 0.8.1.2.0
|
17
|
+
* gem: mack-data_mapper 0.5.0
|
18
|
+
* gem: erubis 2.6.0
|
19
|
+
|
1
20
|
===0.4.7
|
2
|
-
* Added Mack::Request::
|
21
|
+
* Added Mack::Request::UploadedFile class to make dealing with file uploads easy.
|
3
22
|
* Fixed bug where if a controller didn't exist it wasn't checking the public directory.
|
4
23
|
* Generated DataMapper models no longer extend DataMapper::Base, but rather 'include DataMapper::Persistence'. This corresponds to the 0.9.0 upcoming release of DataMapper.
|
5
24
|
* Fixed a bug in request.params that was making file uploads into strings.
|
@@ -9,7 +28,7 @@
|
|
9
28
|
* model generator now creates a stub unit test.
|
10
29
|
* Rake tasks in plugins now show up in the Rake tasks list.
|
11
30
|
* All generators, including the 'mack' binary are now using Genosaurus.
|
12
|
-
* [dsutedja] initializer will load
|
31
|
+
* [dsutedja] initializer will load Mack::Configuration.app_directory/controllers/default_controller.rb if it exists
|
13
32
|
* [dsutedja] added link_image_to and image_tag to html helper.
|
14
33
|
* gem: thin 0.8.1
|
15
34
|
* gem: genosaurus 1.1.1
|
data/README
CHANGED
@@ -10,9 +10,6 @@ Mack is also about performance. Because Mack uses technologies like Thin[http://
|
|
10
10
|
==Getting Started
|
11
11
|
First things first, let's generate your application:
|
12
12
|
$ mack <app_name>
|
13
|
-
|
14
|
-
If you'd like to configure your application to use an ORM, then when you generate it, use the following command:
|
15
|
-
$ mack <app_name> -o <data_mapper|active_record>
|
16
13
|
|
17
14
|
To run a Mack application:
|
18
15
|
$ rake script:server
|
@@ -23,7 +20,7 @@ It will try and run the app using the following servers in this order:
|
|
23
20
|
* WEBrick
|
24
21
|
|
25
22
|
rake script:server takes the following options:
|
26
|
-
$ rake script:server PORT=<port>
|
23
|
+
$ rake script:server PORT=<port> Mack::Configuration.env=<environment> HANDLER=<rack_handler>
|
27
24
|
|
28
25
|
The port and rack_handler flags don't apply if you're using Thin[http://code.macournoyer.com/thin] to run the app, which is the default if it is installed. Use the thin.yml file in your application's config directory to configure Thin. The rack_handler one will allow you to switch which server is used to run the app. See Rack for more Rack::Handlers.
|
29
26
|
|
data/bin/mack
CHANGED
@@ -13,7 +13,7 @@ raise "You must specify a name for this application!" if app.nil?
|
|
13
13
|
|
14
14
|
options = OpenStruct.new
|
15
15
|
options.orm = "data_mapper"
|
16
|
-
options.version = "0.
|
16
|
+
options.version = "0.5.0"
|
17
17
|
|
18
18
|
opts = OptionParser.new do |opts|
|
19
19
|
|
@@ -25,4 +25,4 @@ end
|
|
25
25
|
|
26
26
|
opts.parse!(ARGV)
|
27
27
|
|
28
|
-
MackApplicationGenerator.run({"
|
28
|
+
MackApplicationGenerator.run({"version" => options.version, "app" => app, "orm" => options.orm})
|
data/lib/errors/errors.rb
CHANGED
@@ -58,7 +58,7 @@ module Mack
|
|
58
58
|
class UnknownLayout < StandardError
|
59
59
|
# Takes a layout name.
|
60
60
|
def initialize(layout)
|
61
|
-
super("Could not find layout in: #{File.join(
|
61
|
+
super("Could not find layout in: #{File.join(Mack::Configuration.root, "app", "views", layout.to_s + ".html.erb")}")
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -103,14 +103,5 @@ module Mack
|
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
-
# Raised if there are migrations that need to be run before a task is performed.
|
107
|
-
class UnrunMigrations < StandardError
|
108
|
-
# Taks the number of migrations that need to be run.
|
109
|
-
def initialize(number)
|
110
|
-
super("You currently have #{number} #{number == 1 ? "migration" : "migrations"} that #{number == 1 ? "needs" : "need"} to be run.")
|
111
|
-
end
|
112
|
-
|
113
|
-
end
|
114
|
-
|
115
106
|
end # Errors
|
116
107
|
end # Mack
|
@@ -21,7 +21,11 @@ application_layout:
|
|
21
21
|
template_path: <%= File.join(templates_directory_path, "config", "app_config", "#{env}.yml.template") %>
|
22
22
|
output_path: <%= File.join(app_name, "config", "app_config", "#{env}.yml") %>
|
23
23
|
<% end -%>
|
24
|
-
|
24
|
+
database_yml:
|
25
|
+
type: file
|
26
|
+
template_path: <%= File.join(templates_directory_path, "config", "database.yml.template") %>
|
27
|
+
output_path: <%= File.join(app_name, "config", "database.yml") %>
|
28
|
+
<% ["routes.rb", "thin.ru", "thin.yml"].each do |f| -%>
|
25
29
|
<%= f %>_config_file:
|
26
30
|
type: file
|
27
31
|
template_path: <%= File.join(templates_directory_path, "config", "#{f}.template") %>
|
@@ -1,3 +1,46 @@
|
|
1
|
+
<%
|
2
|
+
case @options["orm"]
|
3
|
+
when "data_mapper"
|
4
|
+
-%>
|
5
|
+
# development:
|
6
|
+
# default:
|
7
|
+
# adapter: mysql
|
8
|
+
# database: <%= @options["app"].downcase %>_development
|
9
|
+
# host: localhost
|
10
|
+
# username: root
|
11
|
+
# password:
|
12
|
+
#
|
13
|
+
# test:
|
14
|
+
# default:
|
15
|
+
# adapter: mysql
|
16
|
+
# database: <%= @options["app"].downcase %>_test
|
17
|
+
# host: localhost
|
18
|
+
# username: root
|
19
|
+
# password:
|
20
|
+
#
|
21
|
+
# production:
|
22
|
+
# default:
|
23
|
+
# adapter: mysql
|
24
|
+
# database: <%= @options["app"].downcase %>_production
|
25
|
+
# host: localhost
|
26
|
+
# username: root
|
27
|
+
# password:
|
28
|
+
|
29
|
+
development:
|
30
|
+
default:
|
31
|
+
adapter: sqlite3
|
32
|
+
database: db/<%= @options["app"].downcase %>_development.db
|
33
|
+
|
34
|
+
test:
|
35
|
+
default:
|
36
|
+
adapter: sqlite3
|
37
|
+
database: db/<%= @options["app"].downcase %>_test.db
|
38
|
+
|
39
|
+
production:
|
40
|
+
default:
|
41
|
+
adapter: sqlite3
|
42
|
+
database: db/<%= @options["app"].downcase %>_production.db
|
43
|
+
<% else -%>
|
1
44
|
# development:
|
2
45
|
# adapter: mysql
|
3
46
|
# database: <%= @options["app"].downcase %>_development
|
@@ -29,4 +72,5 @@ test:
|
|
29
72
|
|
30
73
|
production:
|
31
74
|
adapter: sqlite3
|
32
|
-
database: db/<%= @options["app"].downcase %>_production.db
|
75
|
+
database: db/<%= @options["app"].downcase %>_production.db
|
76
|
+
<% end -%>
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,9 +1,31 @@
|
|
1
1
|
module Mack
|
2
|
+
|
2
3
|
# All configuration for the Mack subsystem happens here. Each of the default environments,
|
3
4
|
# production, development, and test have their own default configuration options. These
|
4
5
|
# get merged with overall default options.
|
5
6
|
module Configuration # :nodoc:
|
6
7
|
|
8
|
+
def self.method_missing(sym, *args)
|
9
|
+
ev = "_mack_#{sym}".downcase
|
10
|
+
return ENV[ev]
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.set(name, value)
|
14
|
+
ENV["_mack_#{name.to_s.downcase}"] = value
|
15
|
+
end
|
16
|
+
|
17
|
+
self.set(:env, "development") if self.env.nil?
|
18
|
+
self.set(:root, FileUtils.pwd) if self.root.nil?
|
19
|
+
self.set(:public_directory, File.join(self.root, "public")) if self.public_directory.nil?
|
20
|
+
self.set(:app_directory, File.join(self.root, "app")) if self.app_directory.nil?
|
21
|
+
self.set(:lib_directory, File.join(self.root, "lib")) if self.lib_directory.nil?
|
22
|
+
self.set(:config_directory, File.join(self.root, "config")) if self.config_directory.nil?
|
23
|
+
self.set(:views_directory, File.join(self.app_directory, "views")) if self.views_directory.nil?
|
24
|
+
self.set(:layouts_directory, File.join(self.views_directory, "layouts")) if self.layouts_directory.nil?
|
25
|
+
self.set(:plugins, File.join(self.root, "vendor", "plugins")) if self.plugins.nil?
|
26
|
+
|
27
|
+
|
28
|
+
|
7
29
|
# use local memory and store stuff for 24 hours:
|
8
30
|
# use file for sessions and store them for 4 hours:
|
9
31
|
DEFAULTS_PRODUCTION = {
|
@@ -15,12 +37,12 @@ module Mack
|
|
15
37
|
"debug" => false,
|
16
38
|
"adapter" => "file",
|
17
39
|
"store_options" =>
|
18
|
-
{"dir" => File.join(
|
40
|
+
{"dir" => File.join(Mack::Configuration.root, "tmp")},
|
19
41
|
"expiry_time" => 14400,
|
20
42
|
"logging" => {
|
21
43
|
"logger_1" => {
|
22
44
|
"type" => "file",
|
23
|
-
"file" => File.join(
|
45
|
+
"file" => File.join(Mack::Configuration.root, "log", "cachetastic_caches_mack_session_cache.log")
|
24
46
|
}
|
25
47
|
}
|
26
48
|
}
|
@@ -58,7 +80,7 @@ module Mack
|
|
58
80
|
"logging" => {
|
59
81
|
"logger_1" => {
|
60
82
|
"type" => "file",
|
61
|
-
"file" => File.join(
|
83
|
+
"file" => File.join(Mack::Configuration.root, "log", "cachetastic.log")
|
62
84
|
}
|
63
85
|
}
|
64
86
|
},
|
@@ -73,12 +95,12 @@ module Mack
|
|
73
95
|
"log::file" => true,
|
74
96
|
"log::console_format" => "%l:\t[%d]\t%M",
|
75
97
|
"log::file_format" => "%l:\t[%d]\t%M"
|
76
|
-
}.merge(eval("DEFAULTS_#{
|
98
|
+
}.merge(eval("DEFAULTS_#{Mack::Configuration.env.upcase}"))
|
77
99
|
end
|
78
100
|
|
79
101
|
app_config.load_hash(DEFAULTS, "mack_defaults")
|
80
|
-
app_config.load_file(File.join(
|
81
|
-
app_config.load_file(File.join(
|
102
|
+
app_config.load_file(File.join(Mack::Configuration.config_directory, "app_config", "default.yml"))
|
103
|
+
app_config.load_file(File.join(Mack::Configuration.config_directory, "app_config", "#{Mack::Configuration.env}.yml"))
|
82
104
|
# app_config.reload
|
83
105
|
|
84
106
|
end
|
@@ -17,33 +17,13 @@ require 'erubis'
|
|
17
17
|
require 'erb'
|
18
18
|
require 'genosaurus'
|
19
19
|
|
20
|
-
|
21
|
-
unless Object.const_defined?("MACK_ENV")
|
22
|
-
(Object::MACK_ENV = (ENV["MACK_ENV"] ||= "development")).to_sym
|
23
|
-
end
|
24
|
-
(Object::MACK_ROOT = (ENV["MACK_ROOT"] ||= FileUtils.pwd)) unless Object.const_defined?("MACK_ROOT")
|
20
|
+
require File.join(File.dirname(__FILE__), "configuration.rb")
|
25
21
|
|
26
|
-
|
27
|
-
Object::MACK_APP = File.join(MACK_ROOT, "app") unless Object.const_defined?("MACK_APP")
|
28
|
-
Object::MACK_LIB = File.join(MACK_ROOT, "lib") unless Object.const_defined?("MACK_LIB")
|
29
|
-
Object::MACK_CONFIG = File.join(MACK_ROOT, "config") unless Object.const_defined?("MACK_CONFIG")
|
30
|
-
Object::MACK_VIEWS = File.join(MACK_APP, "views") unless Object.const_defined?("MACK_VIEWS")
|
31
|
-
Object::MACK_LAYOUTS = File.join(MACK_VIEWS, "layouts") unless Object.const_defined?("MACK_LAYOUTS")
|
32
|
-
Object::MACK_PLUGINS = File.join(MACK_ROOT, "vendor", "plugins") unless Object.const_defined?("MACK_PLUGINS")
|
33
|
-
|
34
|
-
unless Object.const_defined?("MACK_INITIALIZED")
|
35
|
-
puts "Starting application in #{MACK_ENV} mode."
|
36
|
-
puts "Mack root: #{MACK_ROOT}"
|
22
|
+
unless Mack::Configuration.initialized
|
37
23
|
|
38
|
-
|
24
|
+
puts "Starting application in #{Mack::Configuration.env} mode."
|
25
|
+
puts "Mack root: #{Mack::Configuration.root}"
|
39
26
|
|
40
|
-
# Set up 'Rails' constants to allow for easier use of existing gems/plugins like application_configuration.
|
41
|
-
# I would like to take these out eventually, but for right now, it's not doing too much harm.
|
42
|
-
# Object::RAILS_ENV = MACK_ENV unless Object.const_defined?("RAILS_ENV")
|
43
|
-
# Object::RAILS_ROOT = MACK_ROOT unless Object.const_defined?("RAILS_ROOT")
|
44
|
-
|
45
|
-
require File.join(File.dirname(__FILE__), "configuration.rb")
|
46
|
-
|
47
27
|
require File.join(File.dirname(__FILE__), "initializers", "logging.rb")
|
48
28
|
|
49
29
|
require File.join(File.dirname(__FILE__), "initializers", "orm_support.rb")
|
@@ -65,10 +45,10 @@ unless Object.const_defined?("MACK_INITIALIZED")
|
|
65
45
|
# set up application stuff:
|
66
46
|
|
67
47
|
# set up routes:
|
68
|
-
require File.join(
|
48
|
+
require File.join(Mack::Configuration.config_directory, "routes")
|
69
49
|
|
70
50
|
# set up initializers:
|
71
|
-
Dir.glob(File.join(
|
51
|
+
Dir.glob(File.join(Mack::Configuration.config_directory, "initializers", "**/*.rb")) do |d|
|
72
52
|
require d
|
73
53
|
end
|
74
54
|
Mack::Utils::GemManager.instance.do_requires
|
@@ -77,26 +57,31 @@ unless Object.const_defined?("MACK_INITIALIZED")
|
|
77
57
|
require File.join(File.dirname(__FILE__), "initializers", "plugins.rb")
|
78
58
|
|
79
59
|
# make sure that default_controller is available to other controllers
|
80
|
-
path = File.join(
|
60
|
+
path = File.join(Mack::Configuration.app_directory, "controllers", "default_controller.rb")
|
81
61
|
require path if File.exists?(path)
|
82
62
|
|
83
63
|
# require 'app' files:
|
84
|
-
Dir.glob(File.join(
|
64
|
+
Dir.glob(File.join(Mack::Configuration.app_directory, "**/*.rb")).each do |d|
|
65
|
+
# puts "d: #{d}"
|
85
66
|
begin
|
86
67
|
require d
|
87
68
|
rescue NameError => e
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
69
|
+
if e.message.match("uninitialized constant")
|
70
|
+
mod = e.message.gsub("uninitialized constant ", "")
|
71
|
+
x =%{
|
72
|
+
module ::#{mod}
|
73
|
+
end
|
74
|
+
}
|
75
|
+
eval(x)
|
76
|
+
require d
|
77
|
+
else
|
78
|
+
raise e
|
79
|
+
end
|
95
80
|
end
|
96
81
|
end
|
97
82
|
|
98
83
|
# require 'lib' files:
|
99
|
-
Dir.glob(File.join(
|
84
|
+
Dir.glob(File.join(Mack::Configuration.lib_directory, "**/*.rb")).each do |d|
|
100
85
|
require d
|
101
86
|
end
|
102
87
|
|
@@ -120,4 +105,6 @@ unless Object.const_defined?("MACK_INITIALIZED")
|
|
120
105
|
h = "Mack::ViewHelpers::#{cont}".constantize
|
121
106
|
h.include_safely_into(Mack::ViewBinder)
|
122
107
|
end
|
108
|
+
|
109
|
+
Mack::Configuration.set(:initialized, "true") if Mack::Configuration.initialized.nil?
|
123
110
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
#++
|
4
4
|
include Log4r
|
5
5
|
|
6
|
-
log_dir_loc = File.join(
|
6
|
+
log_dir_loc = File.join(Mack::Configuration.root, "log")
|
7
7
|
FileUtils.mkdir_p(log_dir_loc)
|
8
8
|
|
9
9
|
unless Object.const_defined?("MACK_DEFAULT_LOGGER")
|
@@ -17,7 +17,7 @@ unless Object.const_defined?("MACK_DEFAULT_LOGGER")
|
|
17
17
|
# file:
|
18
18
|
if app_config.log.file
|
19
19
|
file_format = PatternFormatter.new(:pattern => app_config.log.file_format)
|
20
|
-
log.add(FileOutputter.new('fileOutputter', :filename => File.join(log_dir_loc, "#{
|
20
|
+
log.add(FileOutputter.new('fileOutputter', :filename => File.join(log_dir_loc, "#{Mack::Configuration.env}.log"), :trunc => false, :formatter => file_format))
|
21
21
|
end
|
22
22
|
|
23
23
|
Object::MACK_DEFAULT_LOGGER = log
|
@@ -1,63 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
unless app_config.orm.nil?
|
6
|
-
dbs = YAML::load(Erubis::Eruby.new(IO.read(File.join(MACK_CONFIG, "database.yml"))).result)
|
7
|
-
case app_config.orm
|
8
|
-
when 'active_record'
|
9
|
-
when 'data_mapper'
|
10
|
-
else
|
11
|
-
MACK_DEFAULT_LOGGER.warn("Attempted to configure an unknown ORM: #{app_config.orm}")
|
12
|
-
end
|
13
|
-
else
|
14
|
-
MACK_DEFAULT_LOGGER.warn("No ORM has been configured!")
|
15
|
-
end
|
16
|
-
|
17
|
-
if app_config.orm == 'active_record'
|
18
|
-
|
19
|
-
begin
|
20
|
-
|
21
|
-
module ActiveRecord # :nodoc:
|
22
|
-
end
|
23
|
-
|
24
|
-
require 'activerecord'
|
25
|
-
|
26
|
-
ActiveRecord::Base.establish_connection(dbs[MACK_ENV])
|
27
|
-
class ArSchemaInfo < ActiveRecord::Base # :nodoc:
|
28
|
-
set_table_name :schema_info
|
29
|
-
end
|
30
|
-
|
31
|
-
rescue Exception => e
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
begin
|
37
|
-
|
38
|
-
module DataMapper # :nodoc:
|
39
|
-
end
|
40
|
-
|
41
|
-
require 'data_mapper'
|
42
|
-
|
43
|
-
DataMapper::Database.setup(dbs[MACK_ENV])
|
44
|
-
class DmSchemaInfo # :nodoc:
|
45
|
-
include DataMapper::Persistence
|
46
|
-
|
47
|
-
set_table_name "schema_info"
|
48
|
-
property :version, :integer, :default => 0
|
49
|
-
end
|
50
|
-
|
51
|
-
rescue Exception => e
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
# Returns true if the system is setup to use ActiveRecord
|
56
|
-
def using_active_record?
|
57
|
-
app_config.orm == 'active_record'
|
58
|
-
end
|
59
|
-
|
60
|
-
# Returns true if the system is setup to use DataMapper
|
61
|
-
def using_data_mapper?
|
62
|
-
app_config.orm == 'data_mapper'
|
63
|
-
end
|
1
|
+
orm = app_config.orm || 'data_mapper'
|
2
|
+
|
3
|
+
require "mack-#{orm}"
|
4
|
+
require "mack-#{orm}_tasks"
|