doozer 0.2.6 → 0.3.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.
- data/VERSION +1 -1
- data/doozer.gemspec +6 -2
- data/lib/doozer.rb +1 -0
- data/lib/doozer/app.rb +4 -4
- data/lib/doozer/configs.rb +6 -8
- data/lib/doozer/initializer.rb +14 -6
- data/lib/doozer/lib.rb +2 -1
- data/lib/doozer/orm/active_record.rb +1 -2
- data/lib/doozer/orm/data_mapper.rb +1 -1
- data/lib/doozer/orm/sequel.rb +1 -1
- data/lib/doozer/partial.rb +2 -2
- data/lib/doozer/route.rb +1 -1
- data/lib/doozer/scripts/cluster.rb +12 -11
- data/lib/doozer/scripts/migrate.rb +4 -5
- data/lib/doozer/scripts/plugin.rb +115 -0
- data/lib/doozer/scripts/task.rb +43 -14
- data/lib/doozer/task.rb +11 -0
- data/lib/doozer/version.rb +2 -2
- data/lib/doozer/view_helpers.rb +7 -0
- data/lib/generator/generator.rb +93 -74
- data/templates/skeleton/config/boot.erb +54 -5
- data/templates/skeleton/config/environment.rb +1 -1
- data/templates/skeleton/gems/plugins/init.rb +26 -0
- data/templates/skeleton/script/console +1 -1
- data/templates/skeleton/script/plugin +4 -0
- data/test/project/config/environment.rb +1 -1
- data/test/project/script/console +1 -1
- data/test/test_helper.rb +1 -1
- metadata +6 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/doozer.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{doozer}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["grippy"]
|
12
|
-
s.date = %q{2009-10-
|
12
|
+
s.date = %q{2009-10-29}
|
13
13
|
s.default_executable = %q{doozer}
|
14
14
|
s.description = %q{This GEM provides a small, barebones framework for creating MVC Rack applications.}
|
15
15
|
s.email = %q{gmelton@whorde.com}
|
@@ -57,8 +57,10 @@ Gem::Specification.new do |s|
|
|
57
57
|
"lib/doozer/scripts/cluster.rb",
|
58
58
|
"lib/doozer/scripts/console.rb",
|
59
59
|
"lib/doozer/scripts/migrate.rb",
|
60
|
+
"lib/doozer/scripts/plugin.rb",
|
60
61
|
"lib/doozer/scripts/task.rb",
|
61
62
|
"lib/doozer/scripts/test.rb",
|
63
|
+
"lib/doozer/task.rb",
|
62
64
|
"lib/doozer/version.rb",
|
63
65
|
"lib/doozer/view_helpers.rb",
|
64
66
|
"lib/doozer/watcher.rb",
|
@@ -77,9 +79,11 @@ Gem::Specification.new do |s|
|
|
77
79
|
"templates/skeleton/config/environment.rb",
|
78
80
|
"templates/skeleton/config/rack.rb",
|
79
81
|
"templates/skeleton/config/routes.rb",
|
82
|
+
"templates/skeleton/gems/plugins/init.rb",
|
80
83
|
"templates/skeleton/script/cluster",
|
81
84
|
"templates/skeleton/script/console",
|
82
85
|
"templates/skeleton/script/migrate",
|
86
|
+
"templates/skeleton/script/plugin",
|
83
87
|
"templates/skeleton/script/task",
|
84
88
|
"templates/skeleton/script/test",
|
85
89
|
"templates/skeleton/static/404.html",
|
data/lib/doozer.rb
CHANGED
data/lib/doozer/app.rb
CHANGED
@@ -15,7 +15,7 @@ module Doozer
|
|
15
15
|
# attach the file watcher for the mvc/lib/etc in development mode
|
16
16
|
load_watcher if Doozer::Configs.rack_env != :deployment
|
17
17
|
|
18
|
-
|
18
|
+
puts "=> Doozer racked up"
|
19
19
|
end
|
20
20
|
|
21
21
|
# This method is called along the rackup chain and maps the request path to the route, controller, and view for the format type.
|
@@ -121,7 +121,7 @@ module Doozer
|
|
121
121
|
def load_files
|
122
122
|
# load models
|
123
123
|
load_models
|
124
|
-
|
124
|
+
puts "=> Caching files"
|
125
125
|
@@controllers = {}
|
126
126
|
@@layouts={}
|
127
127
|
@@views={}
|
@@ -223,7 +223,7 @@ module Doozer
|
|
223
223
|
|
224
224
|
# Load all application models in app/models
|
225
225
|
def load_models
|
226
|
-
|
226
|
+
puts "=> Loading models"
|
227
227
|
Dir.glob(File.join(app_path,'app/models/*.rb')).each { | model |
|
228
228
|
require model
|
229
229
|
}
|
@@ -235,7 +235,7 @@ module Doozer
|
|
235
235
|
def load_watcher
|
236
236
|
require 'doozer/watcher'
|
237
237
|
|
238
|
-
|
238
|
+
puts "=> Watching files for changes"
|
239
239
|
watcher = FileSystemWatcher.new()
|
240
240
|
|
241
241
|
# watcher.addDirectory(File.join(File.dirname(__FILE__),'../doozer/'), "*.rb")
|
data/lib/doozer/configs.rb
CHANGED
@@ -15,8 +15,8 @@ module Doozer
|
|
15
15
|
|
16
16
|
# Load all the config files for the application. Also instantiates a default application Logger.
|
17
17
|
def self.load(rack_env)
|
18
|
-
|
19
|
-
|
18
|
+
puts "=> App path #{app_path}"
|
19
|
+
puts "=> Loading configs for #{rack_env}"
|
20
20
|
|
21
21
|
@@config = Config::CONFIG
|
22
22
|
rack_env = (rack_env.kind_of? String) ? rack_env.to_sym : rack_env
|
@@ -37,18 +37,16 @@ module Doozer
|
|
37
37
|
end
|
38
38
|
|
39
39
|
@@config[:rack_env] = rack_env
|
40
|
-
# p ":rack_env set to #{@@config[:rack_env]}"
|
41
|
-
|
42
40
|
begin
|
43
41
|
@@config[:database] = Configs.symbolize_keys( YAML.load(File.read(File.join(app_path,'config/database.yml'))) )
|
44
42
|
rescue
|
45
|
-
|
43
|
+
puts "ERROR => Failed to load config/database.yml"
|
46
44
|
end
|
47
45
|
|
48
46
|
begin
|
49
47
|
@@config[:app] = Configs.symbolize_keys( YAML.load(File.read(File.join(app_path,'config/app.yml'))) )
|
50
48
|
rescue
|
51
|
-
|
49
|
+
puts "ERROR => Failed to load config/app.yml"
|
52
50
|
end
|
53
51
|
|
54
52
|
end
|
@@ -133,8 +131,8 @@ module Doozer
|
|
133
131
|
def self.app_name
|
134
132
|
self.app["name"] || ""
|
135
133
|
end
|
136
|
-
|
137
|
-
# Return the
|
134
|
+
|
135
|
+
# Return the static root
|
138
136
|
def self.static_root
|
139
137
|
self.app["static_root"] || ""
|
140
138
|
end
|
data/lib/doozer/initializer.rb
CHANGED
@@ -5,10 +5,12 @@ module Doozer
|
|
5
5
|
# Calling boot initializes Doozer in the following order:
|
6
6
|
# 1. Doozer::Configs
|
7
7
|
# 2. require ORM
|
8
|
-
# 3. require
|
9
|
-
# 4. call after_orm_init
|
10
|
-
# 5.
|
11
|
-
# 6. call
|
8
|
+
# 3. require app_path/config/environment.rb
|
9
|
+
# 4. call Doozer::Initializer.after_orm_init
|
10
|
+
# 5. call Doozer.init_after_orm_gems - initialized in app_path/gems/plugins/init.rb
|
11
|
+
# 6. call Doozer.init_after_orm_plugins - initialized in app_path/gems/plugins/init.rb
|
12
|
+
# 7. require Doozer::App
|
13
|
+
# 8. call Doozer::Initializer.before_rackup_init
|
12
14
|
class Initializer
|
13
15
|
@@after_orm = []
|
14
16
|
@@before_rackup = []
|
@@ -30,6 +32,12 @@ module Doozer
|
|
30
32
|
#--call the after_orm_init features
|
31
33
|
Doozer::Initializer.after_orm_init
|
32
34
|
|
35
|
+
#--load the after orm gems
|
36
|
+
Doozer.init_after_orm_gems
|
37
|
+
|
38
|
+
#--load the after orm plugins
|
39
|
+
Doozer.init_after_orm_plugins
|
40
|
+
|
33
41
|
#--load app
|
34
42
|
require 'doozer/app'
|
35
43
|
|
@@ -53,7 +61,7 @@ module Doozer
|
|
53
61
|
|
54
62
|
# Requires the root/config/environment.rb hooks.
|
55
63
|
#
|
56
|
-
# This is where you can place your code to initialize additional plugins for models, extend ruby, or whatever else
|
64
|
+
# This is where you can place your code to initialize additional plugins for models, extend ruby, or whatever else your app requires.
|
57
65
|
#
|
58
66
|
#=== Example environment.rb
|
59
67
|
# Time::DATE_FORMATS[:month_and_year] = "%B %Y"
|
@@ -88,7 +96,7 @@ module Doozer
|
|
88
96
|
|
89
97
|
# Primary hook for adding/overriding Doozer::ViewHelpers methods. Code block is pushed onto an array which allows for multiple hooks throughtout different files.
|
90
98
|
#
|
91
|
-
# &block - code to execute
|
99
|
+
# &block - code to execute prior to Doozer.App.new being intialized.
|
92
100
|
def self.before_rackup(&block)
|
93
101
|
@@before_rackup.push(block) if block_given?
|
94
102
|
end
|
data/lib/doozer/lib.rb
CHANGED
@@ -15,8 +15,7 @@ module Doozer
|
|
15
15
|
config[:reconnect] = db_config["reconnect"] if db_config["reconnect"]
|
16
16
|
|
17
17
|
ActiveRecord::Base.establish_connection(config)
|
18
|
-
|
19
|
-
# printf "ORM: logging initialized"
|
18
|
+
puts "=> #{Doozer::Configs.orm()} initialized"
|
20
19
|
ActiveRecord::Base.logger = Doozer::Configs.logger
|
21
20
|
end
|
22
21
|
|
data/lib/doozer/orm/sequel.rb
CHANGED
data/lib/doozer/partial.rb
CHANGED
@@ -56,7 +56,7 @@ module Doozer
|
|
56
56
|
partial = Doozer::Partial.new(erb, locals, route)
|
57
57
|
partial.bind()
|
58
58
|
else
|
59
|
-
|
59
|
+
puts "ERROR => no partial exists for #{file}\n"
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -81,7 +81,7 @@ module Doozer
|
|
81
81
|
# TODO: throw error if doesn't exist
|
82
82
|
@@partials[name] = ERB.new(results.join(""))
|
83
83
|
rescue
|
84
|
-
|
84
|
+
puts "ERROR => sorry couldn't load partial #{name} (#{file})"
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
data/lib/doozer/route.rb
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
# -C command (start || stop || restart || test)
|
8
8
|
# -E environment (default: development || deployment)
|
9
9
|
# -D (daemonize) - This is automatically initialized in deployment mode. There should be no need to pass this unless you want to test it out in development mode.
|
10
|
+
# -c config file - This is used to pass a config file for starting up unicorn
|
10
11
|
# -h Hellllpppp!!!
|
11
12
|
require 'optparse'
|
12
13
|
|
@@ -32,7 +33,7 @@ end
|
|
32
33
|
# Automatically starts a test instance of your appserver on http://localhost:5000. (No -E flag is required for this command).
|
33
34
|
def test
|
34
35
|
cmd = "rackup #{@test_config}"
|
35
|
-
|
36
|
+
puts "=> #{cmd} -p 5000 -E test -o 127.0.0.1"
|
36
37
|
system(cmd)
|
37
38
|
end
|
38
39
|
|
@@ -40,23 +41,23 @@ end
|
|
40
41
|
#
|
41
42
|
# <b>deployment</b>: Automatically starts a new instance of your appserver for each defined cluster address:port
|
42
43
|
def start
|
43
|
-
|
44
|
+
puts "Starting clusters..."
|
44
45
|
for app in @apps
|
45
46
|
if @env == :deployment
|
46
47
|
#need to check if application has a pid file so we don't start
|
47
48
|
pid_file = "#{APP_PATH}/log/doozer.#{app[:port]}.pid"
|
48
49
|
raise "pid file already exists for #{pid_file}" if File.exist?(pid_file)
|
49
50
|
cmd = "rackup #{@config} -p #{app[:port]} -E #{@env.to_s} -s #{@server} -o #{app[:ip]} #{@daemonize} -P #{pid_file}"
|
50
|
-
|
51
|
+
puts "=> #{cmd}"
|
51
52
|
system(cmd)
|
52
53
|
else
|
53
54
|
cmd = "rackup #{@config} -p #{app[:port]} -E #{@env.to_s} -s #{@server} -o #{app[:ip]}"
|
54
|
-
|
55
|
+
puts "=> #{cmd}"
|
55
56
|
system(cmd)
|
56
57
|
break
|
57
58
|
end
|
58
59
|
end
|
59
|
-
|
60
|
+
puts "Did they start?"
|
60
61
|
system("ps -aux | grep rackup")
|
61
62
|
end
|
62
63
|
|
@@ -72,12 +73,12 @@ end
|
|
72
73
|
#
|
73
74
|
# See this page for details => http://unicorn.bogomips.org/SIGNALS.html
|
74
75
|
def start_unicorn
|
75
|
-
|
76
|
+
puts "Starting unicorn..."
|
76
77
|
for app in @apps
|
77
78
|
# unicorn
|
78
79
|
@config_file = "-c #{@config_file}" if @config_file != ''
|
79
80
|
cmd = "unicorn -p #{app[:port]} -E #{@env.to_s} -o #{app[:ip]} #{@daemonize} #{@config_file} #{@config}"
|
80
|
-
|
81
|
+
puts "=> #{cmd}"
|
81
82
|
system(cmd)
|
82
83
|
break
|
83
84
|
end
|
@@ -94,21 +95,21 @@ end
|
|
94
95
|
# <b>deployment</b>: Automatically stops all instances of your appserver for each defined cluster address:port
|
95
96
|
def stop
|
96
97
|
system("ps -aux | grep rackup")
|
97
|
-
|
98
|
+
puts "Stoping clusters..."
|
98
99
|
for app in @apps
|
99
100
|
if @env == :deployment
|
100
101
|
pid_file = "#{APP_PATH}/log/doozer.#{app[:port]}.pid"
|
101
|
-
|
102
|
+
puts "=> Reading pid from #{pid_file}"
|
102
103
|
if File.exist?(pid_file)
|
103
104
|
File.open(pid_file, 'r'){ | f |
|
104
105
|
pid = f.gets.to_i
|
105
|
-
|
106
|
+
puts "=> Shutting down process #{pid}"
|
106
107
|
system("kill -9 #{pid}")
|
107
108
|
|
108
109
|
}
|
109
110
|
File.delete(pid_file)
|
110
111
|
else
|
111
|
-
|
112
|
+
puts "ERROR => pid file doesn't exist"
|
112
113
|
end
|
113
114
|
end
|
114
115
|
end
|
@@ -86,19 +86,18 @@ Doozer::Initializer.boot(@env)
|
|
86
86
|
# need to grab all the current migrations. assumes there isn't a migration with 000_*_.rb
|
87
87
|
migrations = [nil].concat( Dir.glob(File.join(APP_PATH,'db/*_*.rb')) )
|
88
88
|
|
89
|
-
|
90
|
-
|
91
|
-
|
89
|
+
puts "Loading migration files..."
|
90
|
+
puts "=> Version: #{@version}"
|
91
|
+
puts "=> Direction: #{@direction}"
|
92
92
|
|
93
93
|
if @version > 0
|
94
94
|
file = migrations[@version]
|
95
95
|
raise "Can't find file for this migration" if file.nil?
|
96
96
|
require file
|
97
|
-
|
97
|
+
puts "=> Migrating #{file}"
|
98
98
|
klass = file.split("/").last.gsub(/\.rb/,"").split('_')
|
99
99
|
klass = Doozer::Lib.classify(klass.slice(1, klass.length).join('_'))
|
100
100
|
obj = Object.const_get(klass)
|
101
|
-
|
102
101
|
case @direction
|
103
102
|
when :up
|
104
103
|
obj.up
|
@@ -0,0 +1,115 @@
|
|
1
|
+
#= Plugin
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
@freeze = nil
|
5
|
+
@path = nil
|
6
|
+
@version = nil
|
7
|
+
@force = false
|
8
|
+
|
9
|
+
|
10
|
+
opts = OptionParser.new("", 24, ' ') { |opts|
|
11
|
+
opts.banner = "Usage:\n script/plugin -F gem -V version -f\n script/plugin -P path -V version -f"
|
12
|
+
opts.separator ""
|
13
|
+
opts.separator "Command options:"
|
14
|
+
|
15
|
+
opts.on("-P", "--path PATH", "Turn the path into a plugin.\n\n Possible options:\n 1. git repos\n2. Local path") { | p |
|
16
|
+
@path = p
|
17
|
+
}
|
18
|
+
|
19
|
+
opts.on("-F", "--freeze gem", "Freeze gem to gems/doozer or gems/plugin directory if match is found. Use -V or --version to locate exact version") { | name |
|
20
|
+
@freeze = name
|
21
|
+
}
|
22
|
+
|
23
|
+
opts.on("-V", "--version VERSION", "version of the gem/path to freeze") { | v |
|
24
|
+
@version = v
|
25
|
+
}
|
26
|
+
|
27
|
+
opts.on("-f", "--force", "Remove current plugin before installing") {
|
28
|
+
@force = true
|
29
|
+
}
|
30
|
+
|
31
|
+
opts.on("-h", "--help", "Show help") do
|
32
|
+
puts opts
|
33
|
+
exit
|
34
|
+
end
|
35
|
+
|
36
|
+
opts.parse! ARGV
|
37
|
+
}
|
38
|
+
|
39
|
+
def git(path, version, force)
|
40
|
+
puts "Checking out remote git repo..."
|
41
|
+
name = path.split('/').last.gsub(/\.git/,'')
|
42
|
+
name += "-#{version}" if version
|
43
|
+
plugin_dir = "#{APP_PATH}/gems/plugins"
|
44
|
+
plugin = "#{plugin_dir}/#{name}"
|
45
|
+
puts "=> #{path} to #{plugin}"
|
46
|
+
system("rm -rf #{plugin}") if force
|
47
|
+
system("git clone #{path} #{plugin}")
|
48
|
+
if version
|
49
|
+
system("cd #{plugin}; git checkout #{version}")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def freeze(gem_name, version, force)
|
54
|
+
# locate the gem to freeze
|
55
|
+
puts "Freezing gem..."
|
56
|
+
path = `gem which #{gem_name} -a`
|
57
|
+
source = gem_name
|
58
|
+
if path.downcase.index('can\'t find')
|
59
|
+
puts path
|
60
|
+
exit
|
61
|
+
end
|
62
|
+
path.gsub!(/\n/, '')
|
63
|
+
gem_path = nil
|
64
|
+
if version
|
65
|
+
name = "#{gem_name}-#{version}"
|
66
|
+
# check if the return from the which statement is actually the correct gem
|
67
|
+
if path.index(name)
|
68
|
+
gem_path=path.split(name)[0]
|
69
|
+
else
|
70
|
+
# attempt to locate the gem+version specified
|
71
|
+
gem_path = path.split(gem_name)[0]
|
72
|
+
if not File.directory?("#{gem_path}#{name}")
|
73
|
+
puts "=> Can't find #{gem_path}#{name}"
|
74
|
+
system("gem list #{gem_name}")
|
75
|
+
exit
|
76
|
+
end
|
77
|
+
end
|
78
|
+
gem_name = name
|
79
|
+
end
|
80
|
+
if gem_path.nil?
|
81
|
+
parts = path.split(gem_name)
|
82
|
+
gem_path = parts[0]
|
83
|
+
gem_name += parts[1].split('/')[0]
|
84
|
+
end
|
85
|
+
gem_path += gem_name
|
86
|
+
copy(gem_path, force)
|
87
|
+
end
|
88
|
+
|
89
|
+
def copy(path, force)
|
90
|
+
if File.directory?("#{path}")
|
91
|
+
cp_to_path = "#{APP_PATH}/gems/"
|
92
|
+
if path.index('doozer')
|
93
|
+
cp_to_path += 'doozer'
|
94
|
+
else
|
95
|
+
cp_to_path += 'plugins'
|
96
|
+
end
|
97
|
+
puts "=> Copying: #{path}..."
|
98
|
+
puts "=> To: #{cp_to_path}"
|
99
|
+
system("cp -R #{'-f' if force} #{path} #{cp_to_path}")
|
100
|
+
puts "=> Completed!"
|
101
|
+
puts "=> Don't forget to initialize your plugin in gems/plugins/init.rb"
|
102
|
+
else
|
103
|
+
puts "ERROR => #{path} doesn't appear to be a valid path"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
if @freeze
|
108
|
+
freeze(@freeze, @version, @force)
|
109
|
+
elsif @path
|
110
|
+
if @path.index('.git')
|
111
|
+
git(@path, @version, @force)
|
112
|
+
else
|
113
|
+
copy(@path, @force)
|
114
|
+
end
|
115
|
+
end
|
data/lib/doozer/scripts/task.rb
CHANGED
@@ -1,19 +1,26 @@
|
|
1
1
|
#= Tasks
|
2
2
|
# This file is required in script/task.
|
3
3
|
# Add files to /tasks where the specified task_name contains a class with TaskName and a 'run' class method.
|
4
|
-
# Running a task automatically loads Doozer::Config and the specified ORM.
|
4
|
+
# Running a task automatically loads Doozer::Config and the specified ORM.
|
5
5
|
# Navigate to your app root and run it with the following commands.
|
6
6
|
#
|
7
7
|
# script/clusters
|
8
8
|
# -T task_name
|
9
9
|
# -E environment (default: development || deployment)
|
10
|
+
# -A args
|
10
11
|
# -h Hellllpppp!!!
|
11
12
|
#
|
12
13
|
#== Example
|
13
14
|
# Suppose you have this file tasks/who_rocks.rb
|
14
15
|
#
|
15
16
|
# class WhoRocks
|
16
|
-
# def
|
17
|
+
# def description
|
18
|
+
# """ description """
|
19
|
+
# end
|
20
|
+
# def help
|
21
|
+
# """ help me! """
|
22
|
+
# end
|
23
|
+
# def run
|
17
24
|
# p "You Do!"
|
18
25
|
# end
|
19
26
|
# end
|
@@ -22,6 +29,8 @@
|
|
22
29
|
require 'optparse'
|
23
30
|
@env = :development
|
24
31
|
@task = nil
|
32
|
+
@args = nil
|
33
|
+
@help = false
|
25
34
|
|
26
35
|
opts = OptionParser.new("", 24, ' ') { |opts|
|
27
36
|
opts.banner = "Usage: script/task -T task_name -E (default: development || deployment || test)"
|
@@ -36,25 +45,45 @@ opts = OptionParser.new("", 24, ' ') { |opts|
|
|
36
45
|
@task = t
|
37
46
|
}
|
38
47
|
|
39
|
-
opts.
|
40
|
-
|
41
|
-
|
48
|
+
opts.on("-A", "--args ARGS", "args") { |a|
|
49
|
+
@args = eval(a) if a and a.length
|
50
|
+
}
|
51
|
+
|
52
|
+
opts.on("-h", "--help", "Show this message") do
|
53
|
+
@help = true
|
42
54
|
end
|
43
55
|
|
44
56
|
opts.parse! ARGV
|
45
57
|
}
|
46
58
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
Doozer::
|
59
|
+
def file_to_task(f, args=nil)
|
60
|
+
require f
|
61
|
+
file_name = f.split("/").last.gsub(/\.rb/,"")
|
62
|
+
klass = Doozer::Lib.classify(file_name)
|
63
|
+
return Object.const_get(klass).new(args), file_name
|
64
|
+
end
|
51
65
|
|
52
66
|
if @task
|
53
67
|
file = File.join(APP_PATH, "tasks/#{@task}.rb")
|
54
68
|
raise "Can't find this task file #{@task}" if file.nil?
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
69
|
+
task, file_name = file_to_task(file, @args)
|
70
|
+
if not @help
|
71
|
+
puts "Running #{@task}.."
|
72
|
+
Doozer::Initializer.boot(@env)
|
73
|
+
task.run
|
74
|
+
else
|
75
|
+
puts ""
|
76
|
+
puts "Task\n #{@task}\n"
|
77
|
+
puts "Description\n #{task.description}\n"
|
78
|
+
puts "Help\n #{task.help}\n"
|
79
|
+
end
|
80
|
+
elsif @help
|
81
|
+
puts opts;
|
82
|
+
puts "Loading all tasks.."
|
83
|
+
puts "Task | Description"
|
84
|
+
tasks = Dir.glob(File.join(APP_PATH,'tasks/*.rb'))
|
85
|
+
tasks.each { | f |
|
86
|
+
task, file_name = file_to_task(f, nil)
|
87
|
+
puts "=> #{file_name}: #{task.description}"
|
88
|
+
}
|
60
89
|
end
|
data/lib/doozer/task.rb
ADDED
data/lib/doozer/version.rb
CHANGED
data/lib/doozer/view_helpers.rb
CHANGED
@@ -126,6 +126,13 @@ module Doozer
|
|
126
126
|
Doozer::Configs.static_url(path)
|
127
127
|
end
|
128
128
|
|
129
|
+
# Render the page title
|
130
|
+
#
|
131
|
+
# retuns page title if it was set in a controller
|
132
|
+
def title
|
133
|
+
return @view[:title] ? @view[:title] : ""
|
134
|
+
end
|
135
|
+
|
129
136
|
# Creates metatags
|
130
137
|
#
|
131
138
|
# retuns a differnt metatag for each key/value added to @view[:meta] hash. See Doozer::Controller#meta for adding examples.
|
data/lib/generator/generator.rb
CHANGED
@@ -68,7 +68,7 @@ module Doozer
|
|
68
68
|
help_all
|
69
69
|
end
|
70
70
|
elsif ['-v', '--version'].include?(action)
|
71
|
-
|
71
|
+
puts "Doozer #{Doozer::Version::STRING}"
|
72
72
|
else
|
73
73
|
help_all
|
74
74
|
end
|
@@ -76,8 +76,8 @@ module Doozer
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def self.help_all
|
79
|
-
|
80
|
-
|
79
|
+
puts "Doozer Version: #{Doozer::Version::STRING}"
|
80
|
+
puts "Commands"
|
81
81
|
help(:project)
|
82
82
|
help(:model)
|
83
83
|
help(:view)
|
@@ -89,10 +89,10 @@ module Doozer
|
|
89
89
|
|
90
90
|
def self.controller(name)
|
91
91
|
return if help?(name, :controller)
|
92
|
-
|
92
|
+
puts "Generating File(s)..."
|
93
93
|
path = "#{APP_PATH}/app/controllers/#{name.downcase}_controller.rb"
|
94
94
|
if not File.exist?(path)
|
95
|
-
|
95
|
+
puts "=> Generating controller: #{path}"
|
96
96
|
file = File.new(path, "w+")
|
97
97
|
if file
|
98
98
|
template = "class #{Doozer::Lib.classify(name)}Controller < ApplicationController\nend"
|
@@ -100,33 +100,33 @@ module Doozer
|
|
100
100
|
#make the view directory for this controller
|
101
101
|
path = "#{APP_PATH}/app/views/#{name.downcase}"
|
102
102
|
if not File.exist?(path)
|
103
|
-
|
103
|
+
puts "=> Generating view folder: #{path}"
|
104
104
|
FileUtils.mkdir path
|
105
105
|
end
|
106
106
|
else
|
107
|
-
|
107
|
+
puts "ERROR => Unable to open file!"
|
108
108
|
end
|
109
109
|
else
|
110
|
-
|
110
|
+
puts "Skipping: #{path} (already exists)"
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
114
|
def self.model(orm, name)
|
115
115
|
return if help?(name, :model)
|
116
116
|
raise "No ORM is defined. Please set this in database.yml" if orm.nil?
|
117
|
-
|
117
|
+
puts "=> Loaded ORM: #{orm}"
|
118
118
|
path = "#{APP_PATH}/app/models/#{name}.rb"
|
119
119
|
if not File.exist?(path)
|
120
|
-
|
120
|
+
puts "=> Generating model: #{path}"
|
121
121
|
file = File.new(path, "w+")
|
122
122
|
if file
|
123
123
|
template = eval("model_#{orm}('#{name}')")
|
124
124
|
file.syswrite(template)
|
125
125
|
else
|
126
|
-
|
126
|
+
puts "ERROR => Unable to open file!"
|
127
127
|
end
|
128
128
|
else
|
129
|
-
|
129
|
+
puts "Skipping: #{path} (already exists)"
|
130
130
|
end
|
131
131
|
end
|
132
132
|
def self.model_active_record(name)
|
@@ -156,15 +156,15 @@ end
|
|
156
156
|
|
157
157
|
def self.view(view, formats)
|
158
158
|
return if help?(view, :view)
|
159
|
-
|
159
|
+
puts "Generating View File(s)..."
|
160
160
|
raise "Not sure which controller to associate this view with. Needs to be controller_name/action_name. Example: index/login" if not view.index('/')
|
161
161
|
formats.each{|f|
|
162
162
|
file="#{APP_PATH}/app/views/#{view}.#{f.strip}.erb"
|
163
163
|
if not File.exist?(file)
|
164
|
-
|
164
|
+
puts "=> Generating view: #{file}"
|
165
165
|
FileUtils.touch file
|
166
166
|
else
|
167
|
-
|
167
|
+
puts "Skipping: #{file} (already exists)"
|
168
168
|
end
|
169
169
|
}
|
170
170
|
end
|
@@ -174,19 +174,19 @@ end
|
|
174
174
|
|
175
175
|
raise "No ORM is defined. Please set this in database.yml" if orm.nil?
|
176
176
|
version = migrate_next
|
177
|
-
|
177
|
+
puts "=> Loaded ORM: #{orm}"
|
178
178
|
path = "#{APP_PATH}/db/#{version}_#{name.downcase}.rb"
|
179
179
|
if not File.exist?(path)
|
180
|
-
|
180
|
+
puts "=> Generating migration: #{path}"
|
181
181
|
file = File.new(path, "w+")
|
182
182
|
if file
|
183
183
|
template = eval("migrate_#{orm}('#{name}')")
|
184
184
|
file.syswrite(template)
|
185
185
|
else
|
186
|
-
|
186
|
+
puts "ERROR => Unable to open file!"
|
187
187
|
end
|
188
188
|
else
|
189
|
-
|
189
|
+
puts "Skipping: #{path} (already exists)"
|
190
190
|
end
|
191
191
|
end
|
192
192
|
def self.migrate_next
|
@@ -251,36 +251,46 @@ end
|
|
251
251
|
|
252
252
|
def self.task(name)
|
253
253
|
return if help?(name, :task)
|
254
|
-
|
254
|
+
puts "Generating file..."
|
255
255
|
path = "#{APP_PATH}/tasks/#{name}.rb"
|
256
256
|
if not File.exist?(path)
|
257
|
-
|
257
|
+
puts "=> Generating task: #{path}"
|
258
258
|
file = File.new(path, "w+")
|
259
259
|
if file
|
260
260
|
klass = Doozer::Lib.classify(name)
|
261
261
|
template = """
|
262
262
|
#= Task #{klass}
|
263
|
-
|
264
|
-
|
265
|
-
|
263
|
+
#
|
264
|
+
class #{klass} < Doozer::Task
|
265
|
+
def description
|
266
|
+
\"\"\"Place your task description here\"\"\"
|
267
|
+
end
|
268
|
+
|
269
|
+
def help
|
270
|
+
\"\"\"Place your task help here\"\"\"
|
271
|
+
end
|
272
|
+
|
273
|
+
def run
|
274
|
+
# Place your task here
|
275
|
+
# @args holds evaluated args string
|
266
276
|
end
|
267
277
|
end
|
268
278
|
"""
|
269
279
|
file.syswrite(template)
|
270
280
|
else
|
271
|
-
|
281
|
+
puts "ERROR => Unable to open file!"
|
272
282
|
end
|
273
283
|
else
|
274
|
-
|
284
|
+
puts "Skipping: #{path} (already exists)"
|
275
285
|
end
|
276
286
|
end
|
277
287
|
|
278
288
|
def self.helper(name)
|
279
289
|
return if help?(name, :helper)
|
280
|
-
|
290
|
+
puts "Generating file..."
|
281
291
|
path = "#{APP_PATH}/app/helpers/#{name}_helper.rb"
|
282
292
|
if not File.exist?(path)
|
283
|
-
|
293
|
+
puts "=> Generating helper: #{path}"
|
284
294
|
file = File.new(path, "w+")
|
285
295
|
if file
|
286
296
|
klass = Doozer::Lib.classify(name)
|
@@ -291,16 +301,16 @@ end
|
|
291
301
|
"""
|
292
302
|
file.syswrite(template)
|
293
303
|
else
|
294
|
-
|
304
|
+
puts "ERROR => Unable to open file!"
|
295
305
|
end
|
296
306
|
else
|
297
|
-
|
307
|
+
puts "Skipping: #{path} (already exists)"
|
298
308
|
end
|
299
309
|
end
|
300
310
|
|
301
311
|
def self.help?(name, action=nil)
|
302
312
|
if name.to_sym == :"-h" or name == :help
|
303
|
-
|
313
|
+
puts "Commands:"
|
304
314
|
help(action)
|
305
315
|
return true
|
306
316
|
end
|
@@ -346,7 +356,7 @@ Task - Create a task file in project/tasks with the class name of TaskName.
|
|
346
356
|
Command: doozer generate (task or -T) task_name
|
347
357
|
Example: doozer generate task task_name\n"""
|
348
358
|
end
|
349
|
-
|
359
|
+
puts h
|
350
360
|
end
|
351
361
|
|
352
362
|
# TODO: Dry this up...
|
@@ -354,84 +364,84 @@ Task - Create a task file in project/tasks with the class name of TaskName.
|
|
354
364
|
|
355
365
|
# create application skeleton
|
356
366
|
if not File.exist?(name)
|
357
|
-
|
367
|
+
puts "Creating #{name}/"
|
358
368
|
system("mkdir #{name}")
|
359
369
|
else
|
360
|
-
|
370
|
+
puts "Skipping application directory (already exists)"
|
361
371
|
end
|
362
372
|
|
363
373
|
#create app folder
|
364
374
|
if not File.exist?("#{name}/app")
|
365
|
-
|
375
|
+
puts "=> Creating app directory"
|
366
376
|
system("mkdir #{name}/app")
|
367
377
|
else
|
368
|
-
|
378
|
+
puts "Skipping #{name}/app directory (already exists)"
|
369
379
|
end
|
370
380
|
|
371
381
|
#copy controllers
|
372
382
|
if not File.exist?("#{name}/app/controllers")
|
373
|
-
|
383
|
+
puts "=> Creating #{name}/app/controllers directory and files"
|
374
384
|
system("mkdir #{name}/app/controllers")
|
375
385
|
system("cp #{skeleton_path 'app/controllers/*.rb'} #{name}/app/controllers")
|
376
386
|
else
|
377
|
-
|
387
|
+
puts "Skipping #{name}/app/controllers directory (already exists)"
|
378
388
|
end
|
379
389
|
|
380
390
|
#copy models
|
381
391
|
if not File.exist?("#{name}/app/models")
|
382
|
-
|
392
|
+
puts "=> Creating #{name}/app/models directory and files"
|
383
393
|
system("mkdir #{name}/app/models")
|
384
394
|
else
|
385
|
-
|
395
|
+
puts "Skipping #{name}/app/models directory (already exists)"
|
386
396
|
end
|
387
397
|
|
388
398
|
#copy views
|
389
399
|
if not File.exist?("#{name}/app/views")
|
390
|
-
|
400
|
+
puts "=> Creating #{name}/app/views directory and files"
|
391
401
|
system("mkdir #{name}/app/views")
|
392
402
|
else
|
393
|
-
|
403
|
+
puts "Skipping #{name}/app/views directory (already exists)"
|
394
404
|
end
|
395
405
|
|
396
406
|
#copy views/layouts
|
397
407
|
if not File.exist?("#{name}/app/views/layouts")
|
398
|
-
|
408
|
+
puts "=> Creating #{name}/app/views/layouts directory and files"
|
399
409
|
system("mkdir #{name}/app/views/layouts")
|
400
410
|
system("cp #{skeleton_path 'app/views/layouts/*.erb'} #{name}/app/views/layouts")
|
401
411
|
else
|
402
|
-
|
412
|
+
puts "Skipping #{name}/app/views/layouts directory (already exists)"
|
403
413
|
end
|
404
414
|
|
405
415
|
#copy views/index
|
406
416
|
if not File.exist?("#{name}/app/views/index")
|
407
|
-
|
417
|
+
puts "=> Creating #{name}/app/views/index directory and files"
|
408
418
|
system("mkdir #{name}/app/views/index")
|
409
419
|
system("cp #{skeleton_path 'app/views/index/*.erb'} #{name}/app/views/index")
|
410
420
|
else
|
411
|
-
|
421
|
+
puts "Skipping #{name}/app/views/index directory (already exists)"
|
412
422
|
end
|
413
423
|
|
414
424
|
#copy views/global
|
415
425
|
if not File.exist?("#{name}/app/views/global")
|
416
|
-
|
426
|
+
puts "=> Creating #{name}/app/views/global directory and files"
|
417
427
|
system("mkdir #{name}/app/views/global")
|
418
428
|
system("cp #{skeleton_path 'app/views/global/*.erb'} #{name}/app/views/global")
|
419
429
|
else
|
420
|
-
|
430
|
+
puts "Skipping #{name}/app/views/global directory (already exists)"
|
421
431
|
end
|
422
432
|
|
423
433
|
#copy helpers
|
424
434
|
if not File.exist?("#{name}/app/helpers")
|
425
|
-
|
435
|
+
puts "=> Creating #{name}/app/helpers directory and files"
|
426
436
|
system("mkdir #{name}/app/helpers")
|
427
437
|
system("cp #{skeleton_path 'app/helpers/*.rb'} #{name}/app/helpers")
|
428
438
|
else
|
429
|
-
|
439
|
+
puts "Skipping #{name}/app/helpers directory (already exists)"
|
430
440
|
end
|
431
441
|
|
432
442
|
#copy configs
|
433
443
|
if not File.exist?("#{name}/config")
|
434
|
-
|
444
|
+
puts "=> Creating #{name}/config directory and files"
|
435
445
|
system("mkdir #{name}/config")
|
436
446
|
system("cp #{skeleton_path 'config/*.yml'} #{name}/config")
|
437
447
|
system("cp #{skeleton_path 'config/*.rb'} #{name}/config")
|
@@ -444,102 +454,111 @@ Task - Create a task file in project/tasks with the class name of TaskName.
|
|
444
454
|
boot = ERB.new(results.join(""))
|
445
455
|
File.open("#{name}/config/boot.rb", 'w') {|f| f.write(boot.result(binding)) }
|
446
456
|
else
|
447
|
-
|
457
|
+
puts "Skipping #{name}/config directory (already exists)"
|
458
|
+
end
|
459
|
+
|
460
|
+
# create gems folder
|
461
|
+
if not File.exist?("#{name}/gems")
|
462
|
+
puts "=> Creating #{name}/gems directory"
|
463
|
+
system("cp -R #{skeleton_path 'gems'} #{name}")
|
464
|
+
system("mkdir #{name}/gems/doozer")
|
465
|
+
else
|
466
|
+
puts "Skipping #{name}/gems directory (already exists)"
|
448
467
|
end
|
449
468
|
|
450
469
|
# create log folder
|
451
470
|
if not File.exist?("#{name}/log")
|
452
|
-
|
471
|
+
puts "=> Creating #{name}/log directory"
|
453
472
|
system("mkdir #{name}/log")
|
454
473
|
else
|
455
|
-
|
474
|
+
puts "Skipping #{name}/log directory (already exists)"
|
456
475
|
end
|
457
476
|
|
458
477
|
#copy db
|
459
478
|
if not File.exist?("#{name}/db")
|
460
|
-
|
479
|
+
puts "=> Creating #{name}/db directory and files"
|
461
480
|
system("mkdir #{name}/db")
|
462
481
|
else
|
463
|
-
|
482
|
+
puts "Skipping #{name}/db directory (already exists)"
|
464
483
|
end
|
465
484
|
|
466
485
|
#copy lib
|
467
486
|
if not File.exist?("#{name}/lib")
|
468
|
-
|
487
|
+
puts "=> Creating #{name}/lib directory and files"
|
469
488
|
system("mkdir #{name}/lib")
|
470
489
|
else
|
471
|
-
|
490
|
+
puts "Skipping #{name}/lib directory (already exists)"
|
472
491
|
end
|
473
492
|
|
474
493
|
#copy script
|
475
494
|
if not File.exist?("#{name}/script")
|
476
|
-
|
495
|
+
puts "=> Creating #{name}/script directory and files"
|
477
496
|
system("mkdir #{name}/script")
|
478
497
|
system("cp #{skeleton_path 'script/*'} #{name}/script")
|
479
498
|
else
|
480
|
-
|
499
|
+
puts "Skipping #{name}/script directory (already exists)"
|
481
500
|
end
|
482
501
|
|
483
502
|
#copy static
|
484
503
|
if not File.exist?("#{name}/static")
|
485
|
-
|
504
|
+
puts "=> Creating #{name}/static directory and files"
|
486
505
|
system("mkdir #{name}/static")
|
487
506
|
system("cp #{skeleton_path 'static/*.*'} #{name}/static/")
|
488
507
|
else
|
489
|
-
|
508
|
+
puts "Skipping #{name}/static directory (already exists)"
|
490
509
|
end
|
491
510
|
|
492
511
|
#copy static/images
|
493
512
|
if not File.exist?("#{name}/static/images")
|
494
|
-
|
513
|
+
puts "=> Creating #{name}/script/images directory and files"
|
495
514
|
system("mkdir #{name}/static/images")
|
496
515
|
else
|
497
|
-
|
516
|
+
puts "Skipping #{name}/static/images directory (already exists)"
|
498
517
|
end
|
499
518
|
|
500
519
|
#copy static/css
|
501
520
|
if not File.exist?("#{name}/static/css")
|
502
|
-
|
521
|
+
puts "=> Creating #{name}/script/css directory and files"
|
503
522
|
system("mkdir #{name}/static/css")
|
504
523
|
system("cp #{skeleton_path 'static/css/*.css'} #{name}/static/css")
|
505
524
|
else
|
506
|
-
|
525
|
+
puts "Skipping #{name}/static/css directory (already exists)"
|
507
526
|
end
|
508
527
|
|
509
528
|
#copy static/images
|
510
529
|
if not File.exist?("#{name}/static/html")
|
511
|
-
|
530
|
+
puts "=> Creating #{name}/script/html directory and files"
|
512
531
|
system("mkdir #{name}/static/html")
|
513
532
|
else
|
514
|
-
|
533
|
+
puts "Skipping #{name}/static/html directory (already exists)"
|
515
534
|
end
|
516
535
|
|
517
536
|
#copy static/images
|
518
537
|
if not File.exist?("#{name}/static/js")
|
519
|
-
|
538
|
+
puts "=> Creating #{name}/script/js directory and files"
|
520
539
|
system("mkdir #{name}/static/js")
|
521
540
|
system("cp #{skeleton_path 'static/js/*.js'} #{name}/static/js")
|
522
541
|
else
|
523
|
-
|
542
|
+
puts "Skipping #{name}/static/js directory (already exists)"
|
524
543
|
end
|
525
544
|
|
526
545
|
#copy test
|
527
546
|
if not File.exist?("#{name}/test")
|
528
|
-
|
547
|
+
puts "=> Creating #{name}/test directory and files"
|
529
548
|
system("mkdir #{name}/test")
|
530
549
|
system("cp #{skeleton_path 'test/*.rb'} #{name}/test")
|
531
550
|
system("mkdir #{name}/test/fixtures")
|
532
551
|
system("cp #{skeleton_path 'test/fixtures/*.rb'} #{name}/test/fixtures")
|
533
552
|
else
|
534
|
-
|
553
|
+
puts "Skipping test directory (already exists)"
|
535
554
|
end
|
536
555
|
|
537
556
|
#copy test
|
538
557
|
if not File.exist?("#{name}/tasks")
|
539
|
-
|
558
|
+
puts "=> Creating #{name}/tasks directory and files"
|
540
559
|
system("mkdir #{name}/tasks")
|
541
560
|
else
|
542
|
-
|
561
|
+
puts "Skipping #{name}/test directory (already exists)"
|
543
562
|
end
|
544
563
|
|
545
564
|
#copy rakefile
|
@@ -3,9 +3,58 @@ DOOZER_GEM_VERSION='<%=@version%>'
|
|
3
3
|
require 'date'
|
4
4
|
require 'rubygems'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
module Doozer
|
7
|
+
class << self
|
8
|
+
@@after_orm_plugins = []
|
9
|
+
@@after_orm_gems = []
|
10
|
+
def load!
|
11
|
+
init_doozer
|
12
|
+
init_plugins
|
13
|
+
end
|
14
|
+
def init_doozer
|
15
|
+
path = "#{APP_PATH}/gems/doozer/doozer-#{DOOZER_GEM_VERSION}"
|
16
|
+
if File.exist?(path)
|
17
|
+
$:.unshift "#{path}/lib"
|
18
|
+
require "#{path}/lib/doozer"
|
19
|
+
else
|
20
|
+
begin
|
21
|
+
gem 'doozer', "= #{DOOZER_GEM_VERSION}"
|
22
|
+
require 'doozer'
|
23
|
+
rescue Gem::LoadError
|
24
|
+
raise "doozer-#{DOOZER_GEM_VERSION} gem not installed"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
def init_plugins
|
29
|
+
begin
|
30
|
+
require 'gems/plugins/init'
|
31
|
+
rescue => e
|
32
|
+
end
|
33
|
+
end
|
34
|
+
def init_after_orm_plugins
|
35
|
+
@@after_orm_plugins.each { | p |
|
36
|
+
plugin(p[:folder], p[:init_file])
|
37
|
+
}
|
38
|
+
end
|
39
|
+
def init_after_orm_gems
|
40
|
+
@@after_orm_gems.each { | g |
|
41
|
+
require_gem(g[:name], g[:version])
|
42
|
+
}
|
43
|
+
end
|
44
|
+
def require_gem(name, version=nil)
|
45
|
+
gem name, version if not version.nil?
|
46
|
+
require name
|
47
|
+
end
|
48
|
+
def require_gem_after_orm(name, version=nil)
|
49
|
+
@@after_orm_gems.push({:name=>name, :version=>version})
|
50
|
+
end
|
51
|
+
def plugin(folder, init_file)
|
52
|
+
$:.unshift "#{APP_PATH}/gems/plugins/#{folder}/lib"
|
53
|
+
require "#{APP_PATH}/gems/plugins/#{folder}/lib/#{init_file}"
|
54
|
+
end
|
55
|
+
def plugin_after_orm(folder, init_file)
|
56
|
+
@@after_orm_plugins.push({:folder=>folder, :init_file=>init_file})
|
57
|
+
end
|
58
|
+
end
|
11
59
|
end
|
60
|
+
Doozer.load!
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# This file is loaded right after orm is initialized and right before app, controllers and models
|
2
2
|
# place code here which is used throughout the application
|
3
|
-
|
3
|
+
puts "=> Loading environment"
|
4
4
|
|
5
5
|
Doozer::Initializer.after_orm do | config |
|
6
6
|
# require 'doozer/plugins/paginate/init'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"""
|
2
|
+
There are a few different methods you can call to load plugins and gems from this file.
|
3
|
+
|
4
|
+
1. Doozer.plugin('folder', 'init_file') - Instantly loads the plugin during the boot process.
|
5
|
+
2. Doozer.plugin_after_orm('folder', 'init_file') - Delays loading the plugin until after the ORM is initialized.
|
6
|
+
3. Doozer.require_gem('gem_name', 'version') - Instantly loads the gem during the boot process.
|
7
|
+
4. Doozer.require_gem_after_orm('gem_name', 'version') - Delays loading the gem until after the ORM is initialized.
|
8
|
+
|
9
|
+
To queue a plugin or gem to be loaded, follow these examples.
|
10
|
+
|
11
|
+
To load the following plugins:
|
12
|
+
gems/plugins
|
13
|
+
/plugin1
|
14
|
+
/init.rb
|
15
|
+
/plugin2
|
16
|
+
/init.rb
|
17
|
+
|
18
|
+
You would place the following method calls in this file:
|
19
|
+
Doozer.plugin('plugin1', 'init')
|
20
|
+
Doozer.plugin_after_orm('plugin2', 'init')
|
21
|
+
|
22
|
+
To load the following gems, follow these examples:
|
23
|
+
Doozer.require_gem('example', '= 0.1.0')
|
24
|
+
Doozer.require_gem_after_orm('example', '>= 0.1.0')
|
25
|
+
|
26
|
+
"""
|
@@ -7,7 +7,7 @@ require boot
|
|
7
7
|
@env = (ARGV.length > 0) ? ARGV[0] : 'development'
|
8
8
|
ARGV.delete(@env) if ARGV.include?(@env)
|
9
9
|
@env = @env.to_sym
|
10
|
-
|
10
|
+
puts "[Doozer #{Doozer::Version::STRING}]"
|
11
11
|
# see http://ruby-doc.org/core/ for more options
|
12
12
|
IRB.conf[:LOAD_MODULES] = ["irb/completion", boot, "#{DOOZER_PATH}/doozer/scripts/console"]
|
13
13
|
IRB.conf[:USE_READLINE] = true
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# This file is loaded right after orm is initialized and right before app, controllers and models
|
2
2
|
# place code here which is used throughout the application
|
3
|
-
|
3
|
+
puts "=> Loading environment"
|
4
4
|
|
5
5
|
Doozer::Initializer.after_orm do | config |
|
6
6
|
# require 'doozer/plugins/paginate/init'
|
data/test/project/script/console
CHANGED
@@ -6,7 +6,7 @@ require File.join(APP_PATH, 'config/boot')
|
|
6
6
|
@env = (ARGV.length > 0) ? ARGV[0] : 'development'
|
7
7
|
ARGV.delete(@env) if ARGV.include?(@env)
|
8
8
|
@env = @env.to_sym
|
9
|
-
|
9
|
+
puts "[Doozer #{Doozer::Version::STRING}]"
|
10
10
|
# see http://ruby-doc.org/core/ for more options
|
11
11
|
IRB.conf[:LOAD_MODULES] = ["irb/completion", "#{DOOZER_PATH}/doozer/scripts/console"]
|
12
12
|
IRB.conf[:USE_READLINE] = true
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doozer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- grippy
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-29 00:00:00 -07:00
|
13
13
|
default_executable: doozer
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -61,8 +61,10 @@ files:
|
|
61
61
|
- lib/doozer/scripts/cluster.rb
|
62
62
|
- lib/doozer/scripts/console.rb
|
63
63
|
- lib/doozer/scripts/migrate.rb
|
64
|
+
- lib/doozer/scripts/plugin.rb
|
64
65
|
- lib/doozer/scripts/task.rb
|
65
66
|
- lib/doozer/scripts/test.rb
|
67
|
+
- lib/doozer/task.rb
|
66
68
|
- lib/doozer/version.rb
|
67
69
|
- lib/doozer/view_helpers.rb
|
68
70
|
- lib/doozer/watcher.rb
|
@@ -81,9 +83,11 @@ files:
|
|
81
83
|
- templates/skeleton/config/environment.rb
|
82
84
|
- templates/skeleton/config/rack.rb
|
83
85
|
- templates/skeleton/config/routes.rb
|
86
|
+
- templates/skeleton/gems/plugins/init.rb
|
84
87
|
- templates/skeleton/script/cluster
|
85
88
|
- templates/skeleton/script/console
|
86
89
|
- templates/skeleton/script/migrate
|
90
|
+
- templates/skeleton/script/plugin
|
87
91
|
- templates/skeleton/script/task
|
88
92
|
- templates/skeleton/script/test
|
89
93
|
- templates/skeleton/static/404.html
|