jumpstart 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. data/.gitignore +1 -0
  2. data/Gemfile +2 -1
  3. data/VERSION +1 -1
  4. data/config/jumpstart_setup.yml +1 -0
  5. data/jumpstart.gemspec +15 -89
  6. data/jumpstart_templates/{i0n_rails_3/lib/generators/formtastic_erb/controller/templates/view.html.erb → .gitignore} +0 -0
  7. data/lib/jumpstart.rb +15 -39
  8. data/lib/jumpstart/base.rb +111 -111
  9. data/lib/jumpstart/filetools.rb +11 -7
  10. data/lib/jumpstart/stringtools.rb +41 -0
  11. data/test/helper.rb +12 -6
  12. data/test/jumpstart/test_base.rb +848 -106
  13. data/test/jumpstart/test_filetools.rb +42 -10
  14. data/test/jumpstart/test_stringutils.rb +67 -0
  15. data/test/test_jumpstart_templates/test_base/current_files_and_dirs_test_file.txt +1 -0
  16. data/{jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/controller/templates/view.html.haml → test/test_jumpstart_templates/test_fileutils/sort_contained_files_and_dirs_test/file_1.txt} +0 -0
  17. data/{jumpstart_templates/i0n_rails_3/lib/generators/haml/controller/templates/view.html.haml → test/test_jumpstart_templates/test_fileutils/sort_contained_files_and_dirs_test/file_2} +0 -0
  18. data/test/test_jumpstart_templates/test_fileutils/sort_contained_files_and_dirs_test/folder_1/file_3.txt +0 -0
  19. data/test/test_jumpstart_templates/test_fileutils/sort_contained_files_and_dirs_test/folder_1/folder_2/file_4.txt +0 -0
  20. data/test/test_jumpstart_templates/test_fileutils/sort_contained_files_and_dirs_test/folder_1/folder_2/folder_3/file_5.txt +0 -0
  21. data/test/test_jumpstart_templates/test_fileutils/sort_contained_files_and_dirs_test/folder_1/folder_2/folder_4/file_6.txt +0 -0
  22. data/test/test_jumpstart_templates/test_template_1/_20._test_line_file_without_extension +1 -1
  23. data/test/test_jumpstart_templates/test_template_2/jumpstart_config/test_template_2.yml +83 -1
  24. metadata +15 -89
  25. data/.bundle/config +0 -2
  26. data/jumpstart_templates/i0n_rails_3/.gitignore +0 -11
  27. data/jumpstart_templates/i0n_rails_3/_._Gemfile +0 -5
  28. data/jumpstart_templates/i0n_rails_3/app/views/home/index.haml +0 -4
  29. data/jumpstart_templates/i0n_rails_3/app/views/layouts/application.haml +0 -32
  30. data/jumpstart_templates/i0n_rails_3/config/_2._routes.rb +0 -1
  31. data/jumpstart_templates/i0n_rails_3/config/_L._database.yml +0 -1
  32. data/jumpstart_templates/i0n_rails_3/config/deploy.rb +0 -62
  33. data/jumpstart_templates/i0n_rails_3/config/environments/_18._development.rb +0 -5
  34. data/jumpstart_templates/i0n_rails_3/config/environments/_27._test.rb +0 -1
  35. data/jumpstart_templates/i0n_rails_3/config/environments/_41._production.rb +0 -3
  36. data/jumpstart_templates/i0n_rails_3/config/initializers/setup_mail.rb +0 -14
  37. data/jumpstart_templates/i0n_rails_3/jumpstart_config/i0n_rails_3.yml +0 -40
  38. data/jumpstart_templates/i0n_rails_3/jumpstart_config/nginx.local.conf +0 -11
  39. data/jumpstart_templates/i0n_rails_3/jumpstart_config/nginx.remote.conf +0 -37
  40. data/jumpstart_templates/i0n_rails_3/lib/development_mail_interceptor.rb +0 -8
  41. data/jumpstart_templates/i0n_rails_3/lib/generators/authlogic.rb +0 -11
  42. data/jumpstart_templates/i0n_rails_3/lib/generators/authlogic/session/session_generator.rb +0 -18
  43. data/jumpstart_templates/i0n_rails_3/lib/generators/authlogic/session/templates/session.rb +0 -2
  44. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper.rb +0 -80
  45. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/migration/migration_generator.rb +0 -26
  46. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/migration/templates/migration.rb +0 -21
  47. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/model/model_generator.rb +0 -29
  48. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/model/templates/migration.rb +0 -17
  49. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/model/templates/model.rb +0 -10
  50. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/observer/observer_generator.rb +0 -15
  51. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/observer/templates/observer.rb +0 -5
  52. data/jumpstart_templates/i0n_rails_3/lib/generators/factory_girl.rb +0 -11
  53. data/jumpstart_templates/i0n_rails_3/lib/generators/factory_girl/model/model_generator.rb +0 -14
  54. data/jumpstart_templates/i0n_rails_3/lib/generators/factory_girl/model/templates/fixtures.rb +0 -7
  55. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb.rb +0 -9
  56. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/USAGE +0 -8
  57. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/controller/controller_generator.rb +0 -24
  58. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/scaffold_generator.rb +0 -27
  59. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/_form.html.erb +0 -12
  60. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/edit.html.erb +0 -6
  61. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/index.html.erb +0 -27
  62. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/layout.html.erb +0 -16
  63. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/new.html.erb +0 -5
  64. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/show.html.erb +0 -10
  65. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml.rb +0 -9
  66. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/USAGE +0 -8
  67. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/controller/controller_generator.rb +0 -24
  68. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/scaffold_generator.rb +0 -23
  69. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/_form.haml.erb +0 -9
  70. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/edit.haml.erb +0 -7
  71. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/index.haml.erb +0 -23
  72. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/layout.haml.erb +0 -9
  73. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/new.haml.erb +0 -5
  74. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/show.haml.erb +0 -9
  75. data/jumpstart_templates/i0n_rails_3/lib/generators/haml.rb +0 -9
  76. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/controller/controller_generator.rb +0 -24
  77. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/scaffold_generator.rb +0 -26
  78. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/_form.haml.erb +0 -9
  79. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/edit.haml.erb +0 -7
  80. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/index.haml.erb +0 -23
  81. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/layout.haml.erb +0 -9
  82. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/new.haml.erb +0 -5
  83. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/show.haml.erb +0 -9
  84. data/jumpstart_templates/i0n_rails_3/lib/generators/machinist.rb +0 -11
  85. data/jumpstart_templates/i0n_rails_3/lib/generators/machinist/model/model_generator.rb +0 -19
  86. data/jumpstart_templates/i0n_rails_3/lib/generators/machinist/model/templates/blueprint.rb +0 -5
  87. data/jumpstart_templates/i0n_rails_3/lib/generators/machinist/model/templates/machinist_initializer.rb +0 -19
  88. data/jumpstart_templates/i0n_rails_3/lib/generators/mongomapper.rb +0 -80
  89. data/jumpstart_templates/i0n_rails_3/lib/generators/mongomapper/model/model_generator.rb +0 -29
  90. data/jumpstart_templates/i0n_rails_3/lib/generators/mongomapper/model/templates/model.rb +0 -24
  91. data/jumpstart_templates/i0n_rails_3/lib/generators/mongomapper/observer/observer_generator.rb +0 -15
  92. data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda.rb +0 -11
  93. data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/controller/controller_generator.rb +0 -16
  94. data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/controller/templates/controller.rb +0 -84
  95. data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/model/model_generator.rb +0 -16
  96. data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/model/templates/model.rb +0 -7
  97. data/jumpstart_templates/i0n_rails_3/lib/tasks/populate.rake +0 -91
  98. data/jumpstart_templates/i0n_rails_3/public/javascripts/init.js +0 -6
  99. data/jumpstart_templates/i0n_rails_3/public/javascripts/jquery-1.4.2.min.js +0 -154
  100. data/jumpstart_templates/i0n_rails_3/public/javascripts/jquery-ui-1.8.custom.min.js +0 -404
  101. data/jumpstart_templates/i0n_rails_3/public/javascripts/rails.js +0 -126
  102. data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/_setup.sass +0 -86
  103. data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/global.sass +0 -58
  104. data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/handheld.sass +0 -7
  105. data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/ie.sass +0 -40
  106. data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/print.sass +0 -57
  107. data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/screen.sass +0 -170
@@ -1,2 +0,0 @@
1
- ---
2
- BUNDLE_WITHOUT: ""
@@ -1,11 +0,0 @@
1
- .DS_Store
2
- log/*.log
3
- tmp/*/*
4
- db/*.sqlite3
5
- public/system/photos/*
6
- public/stylesheets/global.css
7
- public/stylesheets/handheld.css
8
- public/stylesheets/ie.css
9
- public/stylesheets/print.css
10
- public/stylesheets/screen.css
11
- mkmf.log
@@ -1,5 +0,0 @@
1
- gem 'haml'
2
-
3
- group :development do
4
- # gem "rails-footnotes"
5
- end
@@ -1,4 +0,0 @@
1
- - content_for :title do
2
- Home Index Page
3
- %p
4
- Holding page for Home Index action
@@ -1,32 +0,0 @@
1
- !!! 5
2
- %html
3
- %head
4
- %meta{ :content => "text/html;charset=UTF-8", "http-equiv" => "content-type" }
5
- %meta{:name => 'description', :content => ''}
6
- %meta{:name => 'keywords', :content => ''}
7
- = csrf_meta_tag
8
- %title
9
- #{yield :title}
10
- = stylesheet_link_tag 'global', :media => :all
11
- = stylesheet_link_tag 'screen', :media => :screen
12
- = stylesheet_link_tag 'print', :media => :print
13
- = stylesheet_link_tag 'handheld', :media => :handheld
14
- /
15
- [if IE 7]>
16
- = stylesheet_link_tag 'ie', :media => 'screen, projection'
17
- = stylesheet_link_tag 'print', :media => 'print'
18
- <![endif]
19
- %body
20
- - if flash[:notice] != nil
21
- %p{:class => "flash_notice"}
22
- = flash[:notice]
23
- - elsif flash[:error] != nil
24
- %p{:class => "flash_error"}
25
- = flash[:error]
26
- =yield
27
- = javascript_include_tag "jquery-1.4.2.min.js"
28
- / = javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"
29
- = javascript_include_tag "jquery-ui-1.8.custom.min.js"
30
- / = javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js"
31
- = javascript_include_tag 'rails'
32
- = javascript_include_tag "init.js"
@@ -1 +0,0 @@
1
- root :to => 'home#index'
@@ -1 +0,0 @@
1
- socket: /var/run/mysqld/mysqld.sock
@@ -1,62 +0,0 @@
1
- set :application, 'PROJECT_NAME'
2
- set :domain, 'REMOTE_SERVER'
3
- set :user, 'i0n'
4
-
5
- set :repository, "#{user}@#{domain}:/home/#{user}/git/#{application}.git"
6
-
7
- role :app, domain # This may be the same as the `Web` server
8
- role :web, domain # Your HTTP server, Apache/etc
9
- role :db, domain , :primary => true # This is where Rails migrations will run
10
-
11
- set :scm_verbose, true
12
-
13
- set :scm, :git
14
- set :scm_username, user
15
- set :runner, user
16
- set :use_sudo, false
17
- set :branch, "master"
18
- set :deploy_via, :checkout
19
- set :git_shallow_clone, 1
20
- set :deploy_to, "/home/#{user}/sites/#{application}"
21
- default_run_options[:pty] = true
22
-
23
- namespace :deploy do
24
- #task which causes Passenger to initiate a restart
25
- task :restart do
26
- run "mkdir -p #{release_path}/tmp && touch #{release_path}/tmp/restart.txt"
27
- end
28
-
29
- namespace :db do
30
-
31
- desc "Create database for the production environment using the servers rake db:setup task.\n Loads the schema, and initializes with the seed data"
32
- task :setup do
33
- run "cd #{current_path}; rake db:setup RAILS_ENV=production"
34
- end
35
-
36
- desc "Populates the production database using lib/tasks/populate which I will use as my own internal convention for this process"
37
- task :populate do
38
- run "cd #{current_path}; rake db:populate RAILS_ENV=production"
39
- end
40
-
41
- end
42
-
43
- desc "Task to set up the remote Nginx server for app deployment"
44
- task :nginx do
45
- run "#{sudo} nginx_auto_config /usr/local/bin/nginx.remote.conf /opt/nginx/conf/nginx.conf PROJECT_NAME"
46
- end
47
-
48
- desc "Create bare remote git repo then add remote origin to local git repo and push to remote"
49
- task :git do
50
- run "cd /home/#{user}/git; mkdir #{application}.git; cd #{application}.git; git init --bare"
51
- `git remote add origin ssh://#{user}@#{domain}/~/git/#{application}.git`
52
- `git push origin master`
53
- end
54
-
55
- end
56
-
57
- # Reminder of default actions for cap deploy:
58
- # deploy:update_code
59
- # deploy:symlink
60
- # deploy:restart
61
-
62
- # eg: after 'deploy:symlink', 'deploy:restart'
@@ -1,5 +0,0 @@
1
- config.action_mailer.default_url_options = {:host => "PROJECT_NAME.local"}
2
-
3
- # Remember that sending email through local postfix/sendmail will not work when trying to deliver directly to a googlemail address.
4
- # Use an alternative address that forwards to googlemail
5
- config.action_mailer.delivery_method = :sendmail
@@ -1 +0,0 @@
1
- config.action_mailer.default_url_options = { :host => "PROJECT_NAME.local" }
@@ -1,3 +0,0 @@
1
- config.action_mailer.default_url_options = {:host => "PROJECT_NAME.com"}
2
- config.action_mailer.delivery_method = :sendmail
3
- Sass::Plugin.options[:style] = :compressed
@@ -1,14 +0,0 @@
1
- # Settings for using gmail in development
2
-
3
- # ActionMailer::Base.smtp_settings = {
4
- # :address => "smtp.gmail.com",
5
- # :port => 587,
6
- # :domain => 'gmail.com',
7
- # :user_name => 'user_name_goes_here',
8
- # :password => 'password_goes_here',
9
- # :authentication => 'plain',
10
- # :enable_starttls_auto => true
11
- # }
12
-
13
- # Sets up an interceptor in lib/development_mail_interceptor.rb that redirects all mail to a specific address in development
14
- ActionMailer::Base.register_interceptor(DevelopmentMailInterceptor) if Rails.env.development?
@@ -1,40 +0,0 @@
1
- ---
2
-
3
- :install_path: /Users/i0n/Sites
4
-
5
- :install_command: rails
6
- :install_command_args: -d mysql -J -T
7
-
8
- :run_after_install_command:
9
- - rails g controller home
10
-
11
- :remove_files:
12
- - /app/views/layouts/application.html.erb
13
- - /public/index.html
14
- - /public/favicon.ico
15
- - /public/images/rails.png
16
-
17
- :run_after_jumpstart:
18
- - rake db:create
19
- - capify .
20
- - git init
21
- - git add .
22
- - git commit -q -v -a -m "Initial commit"
23
-
24
- :replace_strings:
25
- - :target_path: /config/deploy.rb
26
- :symbols:
27
- :project_name: name_of_my_app
28
- :remote_server: thoughtplant
29
- - :target_path: /config/environments/development.rb
30
- :symbols:
31
- :project_name: name_of_my_app
32
- - :target_path: /config/environments/test.rb
33
- :symbols:
34
- :project_name: name_of_my_app
35
- - :target_path: /config/environments/production.rb
36
- :symbols:
37
- :project_name: name_of_my_app
38
-
39
- :local_nginx_conf: /usr/local/nginx/conf/nginx.conf
40
- :remote_nginx_conf: /opt/nginx/conf/nginx.conf
@@ -1,11 +0,0 @@
1
- server {
2
- listen 80;
3
- server_name #{app_name}.local;
4
- rails_env development;
5
- client_max_body_size 10M;
6
- client_body_buffer_size 128k;
7
- location / {
8
- passenger_enabled on;
9
- root /Users/i0n/Sites/#{app_name}/public;
10
- }
11
- }
@@ -1,37 +0,0 @@
1
- server {
2
- listen 80;
3
- server_name #{app_name}.com;
4
- rails_env production;
5
- gzip on;
6
- gzip_proxied any;
7
- gzip_vary on;
8
- gzip_disable 'MSIE [1-6]\.';
9
- gzip_http_version 1.1;
10
- gzip_min_length 10;
11
- gzip_comp_level 9;
12
- gzip_types text/plain application/xhtml+xml text/css application/x-javascript text/xml application/xml;
13
- location / {
14
- root /home/i0n/sites/#{app_name}/current/public/;
15
- passenger_enabled on;
16
- if ($request_filename ~ '.+\.(jpg|jpeg|gif|css|png|js|ico|html)$') { access_log off; expires 30d; }
17
- }
18
- }
19
- server {
20
- listen 80;
21
- server_name www.#{app_name}.com;
22
- rewrite ^ http://#{app_name}.com$request_uri?;
23
- rails_env production;
24
- gzip on;
25
- gzip_proxied any;
26
- gzip_vary on;
27
- gzip_disable 'MSIE [1-6]\.';
28
- gzip_http_version 1.1;
29
- gzip_min_length 10;
30
- gzip_comp_level 9;
31
- gzip_types text/plain application/xhtml+xml text/css application/x-javascript text/xml application/xml;
32
- location / {
33
- root /home/i0n/sites/#{app_name}/current/public/;
34
- passenger_enabled on;
35
- if ($request_filename ~ '.+\.(jpg|jpeg|gif|css|png|js|ico|html)$') { access_log off; expires 30d; }
36
- }
37
- }
@@ -1,8 +0,0 @@
1
- class DevelopmentMailInterceptor
2
-
3
- def self.delivering_email(message)
4
- message.subject = "#{message.to} #{message.subject}"
5
- message.to = "ian@ubeats.com"
6
- end
7
-
8
- end
@@ -1,11 +0,0 @@
1
- require 'rails/generators/named_base'
2
-
3
- module Authlogic
4
- module Generators
5
- class Base < Rails::Generators::NamedBase
6
- def self.source_root
7
- @_authlogic_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'authlogic', generator_name, 'templates'))
8
- end
9
- end
10
- end
11
- end
@@ -1,18 +0,0 @@
1
- require 'generators/authlogic'
2
-
3
- module Authlogic
4
- module Generators
5
- class SessionGenerator < Base
6
- desc "Builds an Authlogic session model"
7
-
8
- check_class_collision
9
-
10
- def create_session_file
11
- template 'session.rb', File.join('app', 'models', class_path, "#{file_name}.rb")
12
- end
13
-
14
- hook_for :test_framework
15
- end
16
- end
17
- end
18
-
@@ -1,2 +0,0 @@
1
- class <%= class_name %> < Authlogic::Session::Base
2
- end
@@ -1,80 +0,0 @@
1
- require 'rails/generators/named_base'
2
- require 'rails/generators/migration'
3
- require 'rails/generators/active_model'
4
-
5
- module Datamapper
6
- module Generators
7
- class Base < Rails::Generators::NamedBase #:nodoc:
8
- include Rails::Generators::Migration
9
-
10
- def self.source_root
11
- @_datamapper_source_root ||= File.expand_path(File.join(File.dirname(__FILE__),
12
- 'datamapper', generator_name, 'templates'))
13
- end
14
-
15
- protected
16
-
17
- # Datamapper does not care if migrations have the same name as long as
18
- # they have different ids.
19
- #
20
- def migration_exists?(dirname, file_name) #:nodoc:
21
- false
22
- end
23
-
24
- # Implement the required interface for Rails::Generators::Migration.
25
- #
26
- def next_migration_number(dirname) #:nodoc:
27
- if options[:id]
28
- "%.3d" % options[:id]
29
- else
30
- "%.3d" % (current_migration_number(dirname) + 1)
31
- end
32
- end
33
- end
34
-
35
- class ActiveModel < Rails::Generators::ActiveModel #:nodoc:
36
- def self.all(klass)
37
- "#{klass}.all"
38
- end
39
-
40
- def self.find(klass, params=nil)
41
- "#{klass}.get(#{params})"
42
- end
43
-
44
- def self.build(klass, params=nil)
45
- if params
46
- "#{klass}.new(#{params})"
47
- else
48
- "#{klass}.new"
49
- end
50
- end
51
-
52
- def save
53
- "#{name}.save"
54
- end
55
-
56
- def update_attributes(params=nil)
57
- "#{name}.update(#{params})"
58
- end
59
-
60
- def errors
61
- "#{name}.errors"
62
- end
63
-
64
- def destroy
65
- "#{name}.destroy"
66
- end
67
- end
68
- end
69
- end
70
-
71
- module Rails
72
- module Generators
73
- class GeneratedAttribute #:nodoc:
74
- def type_class
75
- return 'DateTime' if type.to_s == 'datetime'
76
- return type.to_s.camelcase
77
- end
78
- end
79
- end
80
- end
@@ -1,26 +0,0 @@
1
- require 'generators/datamapper'
2
-
3
- module Datamapper
4
- module Generators
5
- class MigrationGenerator < Base
6
- argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
7
- class_option :id, :type => :numeric, :desc => "The id to be used in this migration"
8
-
9
- def create_migration_file
10
- set_local_assigns!
11
- migration_template "migration.rb", "db/migrate/#{file_name}.rb"
12
- end
13
-
14
- protected
15
- attr_reader :migration_action
16
-
17
- def set_local_assigns!
18
- if file_name =~ /^(add|remove|drop)_.*_(?:to|from)_(.*)/
19
- @migration_action = $1 == 'add' ? 'add' : 'drop'
20
- @table_name = $2.pluralize
21
- end
22
- end
23
-
24
- end
25
- end
26
- end
@@ -1,21 +0,0 @@
1
- migration <%= migration_number.to_i %>, :<%= migration_file_name %> do
2
- up do
3
- <% unless attributes.empty? -%>
4
- modify_table :<%= table_name %> do
5
- <% attributes.each do |attribute| -%>
6
- <%= migration_action %>_column :<%= attribute.name %><% if migration_action == 'add' %>, :<%= attribute.type_class %><% end -%>
7
- <% end -%>
8
- end
9
- <% end -%>
10
- end
11
-
12
- down do
13
- <% unless attributes.empty? -%>
14
- modify_table :<%= table_name %> do
15
- <% attributes.reverse.each do |attribute| -%>
16
- <%= migration_action == 'add' ? 'drop' : 'add' %>_column :<%= attribute.name %><% if migration_action == 'drop' %>, :<%= attribute.type_class %><% end -%>
17
- <% end -%>
18
- end
19
- <% end -%>
20
- end
21
- end
@@ -1,29 +0,0 @@
1
- require 'generators/datamapper'
2
-
3
- module Datamapper
4
- module Generators
5
- class ModelGenerator < Base
6
- argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
7
- class_option :id, :type => :numeric, :desc => "The id to be used in the migration"
8
-
9
- check_class_collision
10
-
11
- class_option :migration, :type => :boolean
12
- class_option :timestamps, :type => :boolean
13
- class_option :parent, :type => :string, :desc => "The parent class for the generated model"
14
-
15
- def create_migration_file
16
- if options[:migration] && options[:parent].nil?
17
- file_name = "create_#{file_path.gsub(/\//, '_').pluralize}"
18
- migration_template "migration.rb", "db/migrate/#{file_name}.rb"
19
- end
20
- end
21
-
22
- def create_model_file
23
- template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
24
- end
25
-
26
- hook_for :test_framework
27
- end
28
- end
29
- end