mack 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +16 -0
- data/bin/mack +5 -43
- data/lib/errors/errors.rb +3 -0
- data/lib/generators/genosaurus_helpers.rb +38 -0
- data/lib/generators/mack_application_generator/mack_application_generator.rb +7 -0
- data/lib/generators/mack_application_generator/manifest.yml +71 -0
- data/{bin → lib/generators/mack_application_generator}/templates/Rakefile.template +1 -1
- data/{bin → lib/generators/mack_application_generator}/templates/app/controllers/default_controller.rb.template +0 -0
- data/{bin → lib/generators/mack_application_generator}/templates/app/helpers/application_helper.rb.template +0 -0
- data/{bin → lib/generators/mack_application_generator}/templates/app/views/default/index.html.erb.template +0 -0
- data/{bin → lib/generators/mack_application_generator}/templates/app/views/layouts/application.html.erb.template +0 -0
- data/lib/generators/mack_application_generator/templates/config/app_config/default.yml.template +5 -0
- data/{bin → lib/generators/mack_application_generator}/templates/config/app_config/development.yml.template +0 -0
- data/{bin → lib/generators/mack_application_generator}/templates/config/app_config/production.yml.template +0 -0
- data/{bin → lib/generators/mack_application_generator}/templates/config/app_config/test.yml.template +0 -0
- data/{bin → lib/generators/mack_application_generator}/templates/config/database.yml.template +6 -6
- data/{bin → lib/generators/mack_application_generator}/templates/config/initializers/gems.rb.template +0 -0
- data/{bin → lib/generators/mack_application_generator}/templates/config/routes.rb.template +0 -0
- data/{bin → lib/generators/mack_application_generator}/templates/config/thin.ru.template +0 -0
- data/{bin → lib/generators/mack_application_generator}/templates/config/thin.yml.template +0 -0
- data/{bin/templates/public/favicon.ico → lib/generators/mack_application_generator/templates/public/favicon.ico.template} +0 -0
- data/{bin → lib/generators/mack_application_generator}/templates/public/stylesheets/scaffold.css.template +0 -0
- data/{bin → lib/generators/mack_application_generator}/templates/test/test_helper.rb.template +1 -1
- data/lib/generators/migration_generator/migration_generator.rb +3 -9
- data/lib/generators/migration_generator/templates/{migration.rb.template → db/migrations/<%=@migration_name%>.rb.template} +0 -0
- data/lib/generators/model_column.rb +1 -1
- data/lib/generators/model_generator/manifest.yml +11 -0
- data/lib/generators/model_generator/model_generator.rb +16 -19
- data/lib/generators/model_generator/templates/{app/models/active_record.rb.template → active_record.rb.template} +0 -0
- data/lib/generators/model_generator/templates/{app/models/data_mapper.rb.template → data_mapper.rb.template} +3 -1
- data/lib/generators/model_generator/templates/test.rb.template +9 -0
- data/lib/generators/plugin_generator/plugin_generator.rb +3 -17
- data/lib/generators/plugin_generator/templates/vendor/plugins/<%= @plugin_name %>/init.rb.template +1 -0
- data/lib/generators/plugin_generator/templates/vendor/plugins/<%= @plugin_name %>/lib/<%= @plugin_name %>.rb.template +1 -0
- data/lib/generators/plugin_generator/templates/vendor/plugins/<%= @plugin_name %>/lib/tasks/<%= @plugin_name %>_tasks.rake.template +1 -0
- data/lib/generators/scaffold_generator/manifest.yml +31 -0
- data/lib/generators/scaffold_generator/scaffold_generator.rb +13 -27
- data/lib/generators/scaffold_generator/templates/no_orm/{app/controllers/controller.rb.template → controller.rb.template} +0 -0
- data/lib/generators/scaffold_generator/templates/test.rb.template +9 -0
- data/lib/initialization/initializer.rb +16 -1
- data/lib/initialization/initializers/orm_support.rb +48 -33
- data/lib/mack.rb +12 -6
- data/lib/mack_tasks.rb +2 -2
- data/lib/routing/route_map.rb +2 -0
- data/lib/sea_level/helpers/view_helpers/html_helpers.rb +8 -0
- data/lib/sea_level/request.rb +21 -8
- data/lib/sea_level/uploaded_file.rb +56 -0
- data/lib/tasks/generator_tasks.rake +18 -0
- data/lib/tasks/rake_rules.rake +1 -2
- data/lib/utils/html.rb +8 -0
- metadata +49 -28
- data/bin/templates/config/app_config/default.yml.template +0 -7
- data/lib/generators/base.rb +0 -94
- data/lib/generators/migration/base.rb +0 -26
- data/lib/generators/plugin_generator/templates/init.rb.template +0 -1
- data/lib/generators/plugin_generator/templates/lib/plugin.rb.template +0 -1
data/lib/generators/plugin_generator/templates/vendor/plugins/<%= @plugin_name %>/init.rb.template
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require '<%= @plugin_name %>'
|
@@ -0,0 +1 @@
|
|
1
|
+
# Do work here for <%= @plugin_name %>
|
@@ -0,0 +1 @@
|
|
1
|
+
# Place any Rake tasks for your plugin here:
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<% if app_config.orm -%>
|
2
|
+
controller_template:
|
3
|
+
type: file
|
4
|
+
template_path: <%= File.join(templates_directory_path, "generic", "app", "controllers", "controller.rb.template") %>
|
5
|
+
output_path: <%= File.join("app", "controllers", "#{@name_plural}_controller.rb") %>
|
6
|
+
edit_template:
|
7
|
+
type: file
|
8
|
+
template_path: <%= File.join(templates_directory_path, "generic", "app", "views", "edit.html.erb.template") %>
|
9
|
+
output_path: <%= File.join("app", "views", @name_plural, "edit.html.erb") %>
|
10
|
+
index_template:
|
11
|
+
type: file
|
12
|
+
template_path: <%= File.join(templates_directory_path, "generic", "app", "views", "index.html.erb.template") %>
|
13
|
+
output_path: <%= File.join("app", "views", @name_plural, "index.html.erb") %>
|
14
|
+
new_template:
|
15
|
+
type: file
|
16
|
+
template_path: <%= File.join(templates_directory_path, "generic", "app", "views", "new.html.erb.template") %>
|
17
|
+
output_path: <%= File.join("app", "views", @name_plural, "new.html.erb") %>
|
18
|
+
show_template:
|
19
|
+
type: file
|
20
|
+
template_path: <%= File.join(templates_directory_path, "generic", "app", "views", "show.html.erb.template") %>
|
21
|
+
output_path: <%= File.join("app", "views", @name_plural, "show.html.erb") %>
|
22
|
+
<% else -%>
|
23
|
+
controller_template:
|
24
|
+
type: file
|
25
|
+
template_path: <%= File.join(templates_directory_path, "no_orm", "controller.rb.template") %>
|
26
|
+
output_path: <%= File.join("app", "controllers", "#{@name_plural}_controller.rb") %>
|
27
|
+
<% end -%>
|
28
|
+
functional_teat_template:
|
29
|
+
type: file
|
30
|
+
template_path: <%= File.join(templates_directory_path, "test.rb.template") %>
|
31
|
+
output_path: <%= File.join("test", "functional", "#{@name_plural}_controller_test.rb") %>
|
@@ -2,16 +2,25 @@
|
|
2
2
|
#
|
3
3
|
# Example:
|
4
4
|
# rake generate:scaffold name=post
|
5
|
-
class ScaffoldGenerator <
|
5
|
+
class ScaffoldGenerator < Genosaurus
|
6
6
|
|
7
7
|
require_param :name
|
8
8
|
|
9
|
-
def
|
9
|
+
def setup
|
10
10
|
@name_singular = param(:name).singular.underscore
|
11
11
|
@name_plural = param(:name).plural.underscore
|
12
12
|
@name_singular_camel = @name_singular.camelcase
|
13
|
-
@name_plural_camel = @name_plural.camelcase
|
14
|
-
|
13
|
+
@name_plural_camel = @name_plural.camelcase
|
14
|
+
end
|
15
|
+
|
16
|
+
def after_generate
|
17
|
+
if app_config.orm
|
18
|
+
ModelGenerator.run(@options)
|
19
|
+
end
|
20
|
+
update_routes_file
|
21
|
+
end
|
22
|
+
|
23
|
+
def update_routes_file
|
15
24
|
# update routes.rb
|
16
25
|
routes = File.join(MACK_CONFIG, "routes.rb")
|
17
26
|
rf = File.open(routes).read
|
@@ -28,30 +37,7 @@ class ScaffoldGenerator < Mack::Generator::Base
|
|
28
37
|
File.open(routes, "w") do |f|
|
29
38
|
f.puts nrf
|
30
39
|
end
|
31
|
-
end
|
32
|
-
|
33
|
-
app_cont_dir = File.join(MACK_APP, "controllers")
|
34
|
-
directory(app_cont_dir)
|
35
|
-
|
36
|
-
temp_dir = File.join(File.dirname(__FILE__), "templates")
|
37
|
-
|
38
|
-
if app_config.orm
|
39
|
-
app_model_dir = File.join(MACK_APP, "models")
|
40
|
-
directory(app_model_dir)
|
41
|
-
|
42
|
-
app_views_dir = File.join(MACK_APP, "views", @name_plural)
|
43
|
-
directory(app_views_dir)
|
44
|
-
|
45
|
-
template(File.join(temp_dir, "generic", "app", "controllers", "controller.rb.template"), File.join(app_cont_dir, "#{@name_plural}_controller.rb"), :force => param(:force))
|
46
|
-
template(File.join(temp_dir, "generic", "app", "views", "index.html.erb.template"), File.join(app_views_dir, "index.html.erb"), :force => param(:force))
|
47
|
-
template(File.join(temp_dir, "generic", "app", "views", "edit.html.erb.template"), File.join(app_views_dir, "edit.html.erb"), :force => param(:force))
|
48
|
-
template(File.join(temp_dir, "generic", "app", "views", "new.html.erb.template"), File.join(app_views_dir, "new.html.erb"), :force => param(:force))
|
49
|
-
template(File.join(temp_dir, "generic", "app", "views", "show.html.erb.template"), File.join(app_views_dir, "show.html.erb"), :force => param(:force))
|
50
|
-
ModelGenerator.new(@env).run
|
51
|
-
else
|
52
|
-
template(File.join(temp_dir, "no_orm", "app", "controllers", "controller.rb.template"), File.join(app_cont_dir, "#{@name_plural}_controller.rb"), :force => param(:force))
|
53
40
|
end
|
54
|
-
|
55
41
|
end
|
56
42
|
|
57
43
|
end
|
File without changes
|
@@ -15,6 +15,7 @@ require 'rinda/tuplespace'
|
|
15
15
|
require 'builder'
|
16
16
|
require 'erubis'
|
17
17
|
require 'erb'
|
18
|
+
require 'genosaurus'
|
18
19
|
|
19
20
|
# Set up Mack constants, if they haven't already been set up.
|
20
21
|
unless Object.const_defined?("MACK_ENV")
|
@@ -75,9 +76,23 @@ unless Object.const_defined?("MACK_INITIALIZED")
|
|
75
76
|
# require 'plugins':
|
76
77
|
require File.join(File.dirname(__FILE__), "initializers", "plugins.rb")
|
77
78
|
|
79
|
+
# make sure that default_controller is available to other controllers
|
80
|
+
path = File.join(MACK_APP, "controllers", "default_controller.rb")
|
81
|
+
require path if File.exists?(path)
|
82
|
+
|
78
83
|
# require 'app' files:
|
79
84
|
Dir.glob(File.join(MACK_APP, "**/*.rb")).each do |d|
|
80
|
-
|
85
|
+
begin
|
86
|
+
require d
|
87
|
+
rescue NameError => e
|
88
|
+
mod = e.message.gsub("uninitialized constant ", "")
|
89
|
+
x =%{
|
90
|
+
module ::#{mod}
|
91
|
+
end
|
92
|
+
}
|
93
|
+
eval(x)
|
94
|
+
require d
|
95
|
+
end
|
81
96
|
end
|
82
97
|
|
83
98
|
# require 'lib' files:
|
@@ -2,47 +2,62 @@
|
|
2
2
|
# setup ORM:
|
3
3
|
#++
|
4
4
|
|
5
|
-
$using_active_record = false
|
6
|
-
$using_data_mapper = false
|
7
|
-
|
8
|
-
# Returns true if the system is setup to use ActiveRecord
|
9
|
-
def using_active_record?
|
10
|
-
$using_active_record
|
11
|
-
end
|
12
|
-
|
13
|
-
# Returns true if the system is setup to use DataMapper
|
14
|
-
def using_data_mapper?
|
15
|
-
$using_data_mapper
|
16
|
-
end
|
17
|
-
|
18
|
-
module ActiveRecord # :nodoc:
|
19
|
-
end
|
20
|
-
module DataMapper # :nodoc:
|
21
|
-
end
|
22
|
-
|
23
5
|
unless app_config.orm.nil?
|
24
6
|
dbs = YAML::load(Erubis::Eruby.new(IO.read(File.join(MACK_CONFIG, "database.yml"))).result)
|
25
7
|
case app_config.orm
|
26
8
|
when 'active_record'
|
27
|
-
require 'activerecord'
|
28
|
-
ActiveRecord::Base.establish_connection(dbs[MACK_ENV])
|
29
|
-
class ArSchemaInfo < ActiveRecord::Base # :nodoc:
|
30
|
-
set_table_name :schema_info
|
31
|
-
end
|
32
|
-
$using_active_record = true
|
33
|
-
$using_data_mapper = false # set to false, in case we're flipping back and forth
|
34
9
|
when 'data_mapper'
|
35
|
-
require 'data_mapper'
|
36
|
-
DataMapper::Database.setup(dbs[MACK_ENV])
|
37
|
-
class DmSchemaInfo < DataMapper::Base # :nodoc:
|
38
|
-
set_table_name "schema_info"
|
39
|
-
property :version, :integer, :default => 0
|
40
|
-
end
|
41
|
-
$using_data_mapper = true
|
42
|
-
$using_active_record = false # set to false, in case we're flipping back and forth
|
43
10
|
else
|
44
11
|
MACK_DEFAULT_LOGGER.warn("Attempted to configure an unknown ORM: #{app_config.orm}")
|
45
12
|
end
|
46
13
|
else
|
47
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'
|
48
63
|
end
|
data/lib/mack.rb
CHANGED
@@ -22,12 +22,17 @@ module Mack
|
|
22
22
|
redirect_to(route)
|
23
23
|
else
|
24
24
|
# let's handle a normal request:
|
25
|
-
|
25
|
+
begin
|
26
|
+
cont = "#{route[:controller].to_s.camelcase}Controller".constantize
|
27
|
+
rescue NameError => e
|
28
|
+
raise Mack::Errors::ResourceNotFound.new(self.request.path_info)
|
29
|
+
end
|
30
|
+
c = cont.new(self.request, self.response, self.cookies)
|
26
31
|
self.response.controller = c
|
27
32
|
self.response.write(c.run)
|
28
33
|
end
|
29
34
|
rescue Mack::Errors::ResourceNotFound, Mack::Errors::UndefinedRoute => e
|
30
|
-
return try_to_find_resource(env,
|
35
|
+
return try_to_find_resource(env, e)
|
31
36
|
end
|
32
37
|
end # setup
|
33
38
|
rescue Exception => e
|
@@ -102,12 +107,13 @@ module Mack
|
|
102
107
|
id
|
103
108
|
end
|
104
109
|
|
105
|
-
def try_to_find_resource(env,
|
110
|
+
def try_to_find_resource(env, exception)
|
111
|
+
env = env.dup
|
106
112
|
# we can't find a route for this, so let's try and see if it's in the public directory:
|
107
|
-
if File.extname(
|
108
|
-
|
113
|
+
if File.extname(env["PATH_INFO"]).blank?
|
114
|
+
env["PATH_INFO"] << ".html"
|
109
115
|
end
|
110
|
-
if File.exists?(File.join(MACK_PUBLIC,
|
116
|
+
if File.exists?(File.join(MACK_PUBLIC, env["PATH_INFO"]))
|
111
117
|
return Rack::File.new(File.join(MACK_PUBLIC)).call(env)
|
112
118
|
else
|
113
119
|
raise exception
|
data/lib/mack_tasks.rb
CHANGED
@@ -2,12 +2,12 @@ require 'rake'
|
|
2
2
|
require 'rake/testtask'
|
3
3
|
require 'rake/rdoctask'
|
4
4
|
# Requires all rake tasks that ship with the Mack framework.
|
5
|
-
[File.join(File.dirname(__FILE__)), File.join(FileUtils.pwd, "lib")].each do |dir|
|
5
|
+
[File.join(File.dirname(__FILE__)), File.join(FileUtils.pwd, "lib"), File.join(FileUtils.pwd, "vendor", "plugins")].each do |dir|
|
6
6
|
begin
|
7
7
|
require File.join(dir, "tasks", "rake_helpers.rb")
|
8
8
|
rescue Exception => e
|
9
9
|
end
|
10
|
-
files = Dir.glob(File.join(dir, "
|
10
|
+
files = Dir.glob(File.join(dir, "**/*.rake"))
|
11
11
|
files.each do |f|
|
12
12
|
unless f == __FILE__
|
13
13
|
load f
|
data/lib/routing/route_map.rb
CHANGED
@@ -162,6 +162,7 @@ module Mack
|
|
162
162
|
|
163
163
|
# Sets up mappings and named routes for a resource.
|
164
164
|
def resource(controller)
|
165
|
+
|
165
166
|
connect_with_named_route("#{controller}_index", "/#{controller}", {:controller => controller, :action => :index, :method => :get})
|
166
167
|
connect_with_named_route("#{controller}_create", "/#{controller}", {:controller => controller, :action => :create, :method => :post})
|
167
168
|
connect_with_named_route("#{controller}_new", "/#{controller}/new", {:controller => controller, :action => :new, :method => :get})
|
@@ -206,6 +207,7 @@ module Mack
|
|
206
207
|
|
207
208
|
private
|
208
209
|
def connect_with_named_route(n_route, pattern, options = {})
|
210
|
+
n_route = n_route.methodize
|
209
211
|
route = connect(pattern, options)
|
210
212
|
|
211
213
|
url = %{
|
@@ -28,6 +28,14 @@ module Mack
|
|
28
28
|
Mack::Utils::Html
|
29
29
|
end
|
30
30
|
|
31
|
+
# A wrapper method for image link.
|
32
|
+
#
|
33
|
+
# Examples:
|
34
|
+
# <%= link_image_to("/images/foo.jpg", "#" %> # => <a href="#"><img src="/images/foo.jpg"></a>
|
35
|
+
def link_image_to(image_url, url, image_options = {}, html_options = {})
|
36
|
+
link_to(Mack::Utils::Html.image_tag(image_url, image_options), url, html_options)
|
37
|
+
end
|
38
|
+
|
31
39
|
# A wrapper to Mack::Utils::Html rss method.
|
32
40
|
#
|
33
41
|
# Example:
|
data/lib/sea_level/request.rb
CHANGED
@@ -53,16 +53,29 @@ module Mack
|
|
53
53
|
# route: '/users/:id' => {:controller => 'users', :action => 'show'}
|
54
54
|
# parameters: {:controller => 'users', :action => 'show', :id => 1, :foo => "bar"}
|
55
55
|
def params(key)
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
56
|
+
ivar_cache("params_#{key}") do
|
57
|
+
p = (@mack_params[key.to_sym] || @mack_params[key.to_s])
|
58
|
+
unless p.nil?
|
59
|
+
p = p.to_s if p.is_a?(Symbol)
|
60
|
+
if p.is_a?(String)
|
61
|
+
p = p.to_s.uri_unescape
|
62
|
+
elsif p.is_a?(Hash)
|
63
|
+
p.each_pair do |k,v|
|
64
|
+
if v.is_a?(String)
|
65
|
+
p[k] = v.to_s.uri_unescape
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
63
69
|
end
|
70
|
+
p
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# Returns a Mack::Request::UploadedFile object.
|
75
|
+
def file(key)
|
76
|
+
ivar_cache("file_#{key}") do
|
77
|
+
Mack::Request::UploadedFile.new(params(key))
|
64
78
|
end
|
65
|
-
p
|
66
79
|
end
|
67
80
|
|
68
81
|
private
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Mack
|
2
|
+
# Wraps the Hash that Rack creates when you post a file.
|
3
|
+
class Request::UploadedFile
|
4
|
+
|
5
|
+
# The name of the file uploaded
|
6
|
+
attr_reader :file_name
|
7
|
+
# The type of the file uploaded
|
8
|
+
attr_reader :file_type
|
9
|
+
# The name of the parameter used to upload the file
|
10
|
+
attr_reader :param_name
|
11
|
+
# A File object representing the uploaded file.
|
12
|
+
attr_reader :temp_file
|
13
|
+
attr_reader :head
|
14
|
+
# The destination path you want the file to be saved to.
|
15
|
+
attr_accessor :destination_path
|
16
|
+
|
17
|
+
def initialize(param, destination_path = nil)
|
18
|
+
@file_name = param[:filename]
|
19
|
+
@file_type = param[:type]
|
20
|
+
@param_name = param[:name]
|
21
|
+
@temp_file = param[:tempfile]
|
22
|
+
@head = param[:head]
|
23
|
+
@destination_path = nil
|
24
|
+
end
|
25
|
+
|
26
|
+
# Set the destination_path you want the file to be saved to.
|
27
|
+
# This can be a full path, or an array that will get joined with File.join.
|
28
|
+
#
|
29
|
+
# Examples:
|
30
|
+
# @uploaded_file.destination_path = "/path/to/my/destination/foo.jpg"
|
31
|
+
# @uploaded_file.destination_path = ["path", "to", "my", "destination", "foo.jpg"]
|
32
|
+
def destination_path=(path)
|
33
|
+
if path.is_a?(Array)
|
34
|
+
@destination_path = File.join(path)
|
35
|
+
else
|
36
|
+
@destination_path = path
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Takes/sets the destination_path and then calls the save method.
|
41
|
+
def save_to(*destination_path)
|
42
|
+
self.destination_path = *destination_path
|
43
|
+
save
|
44
|
+
end
|
45
|
+
|
46
|
+
# Saves the temp_file to the destination_path. This method will create the directory
|
47
|
+
# tree of the destination_path if it does not exists.
|
48
|
+
# Raises ArgumentError if the destination_path has not been set.
|
49
|
+
def save
|
50
|
+
raise ArgumentError.new("Destination path must be set!") if self.destination_path.blank?
|
51
|
+
FileUtils.mkdir_p(File.dirname(self.destination_path))
|
52
|
+
FileUtils.mv(self.temp_file.path, self.destination_path)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end # :nodoc:
|
@@ -0,0 +1,18 @@
|
|
1
|
+
namespace :generator do
|
2
|
+
|
3
|
+
desc "Lists all the generators available"
|
4
|
+
task :list => :environment do
|
5
|
+
list = "\nAvailable Generators:\n\n"
|
6
|
+
Object.constants.sort.each do |g|
|
7
|
+
g = g.constantize
|
8
|
+
if g.respond_to?(:superclass) && g.superclass == Genosaurus
|
9
|
+
list << g.name
|
10
|
+
list << "\n\t" << "rake generate:#{g.name.underscore}\n"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
list << "\n\n"
|
14
|
+
ENV["__generator_list"] = list
|
15
|
+
puts list
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|