Class: Dust::Generators::AlbumsGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/dust/albums/albums_generator.rb
Class Method Summary collapse
-
.next_migration_number(dirname) ⇒ Object
FIXME: Should be proxied to ActiveRecord::Generators::Base Implement the required interface for Rails::Generators::Migration.
Instance Method Summary collapse
- #app ⇒ Object
- #child ⇒ Object
- #child_class_name ⇒ Object
- #child_plural_class_name ⇒ Object
- #child_plural_name ⇒ Object
- #child_singular_name ⇒ Object
- #create_migration ⇒ Object
- #css ⇒ Object
- #images ⇒ Object
- #initializers ⇒ Object
- #javascript ⇒ Object
-
#parent ⇒ Object
NAMING METHODS.
- #parent_class_name ⇒ Object
- #parent_plural_class_name ⇒ Object
- #parent_plural_name ⇒ Object
- #parent_singular_name ⇒ Object
- #rake_migrations ⇒ Object
- #routes ⇒ Object
- #source_root ⇒ Object
Methods inherited from Base
Class Method Details
.next_migration_number(dirname) ⇒ Object
FIXME: Should be proxied to ActiveRecord::Generators::Base Implement the required interface for Rails::Generators::Migration.
144 145 146 147 148 149 150 |
# File 'lib/generators/dust/albums/albums_generator.rb', line 144 def self.next_migration_number(dirname) #:nodoc: if ActiveRecord::Base. Time.now.utc.strftime("%Y%m%d%H%M%S") else "%.3d" % (current_migration_number(dirname) + 1) end end |
Instance Method Details
#app ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/generators/dust/albums/albums_generator.rb', line 33 def app template "app/controllers/albums_controller.rb", "app/controllers/#{parent_plural_name}_controller.rb" template "app/controllers/photos_controller.rb", "app/controllers/#{child_plural_name}_controller.rb" template "app/controllers/view_albums_controller.rb", "app/controllers/view_#{parent_plural_name}_controller.rb" template "app/helpers/albums_helper.rb", "app/helpers/#{parent_plural_name}_helper.rb" template "app/helpers/photos_helper.rb", "app/helpers/#{child_plural_name}_helper.rb" template "app/helpers/view_albums_helper.rb", "app/helpers/view_#{parent_plural_name}_helper.rb" template "app/models/album.rb", "app/models/#{parent_singular_name}.rb" template "app/models/photo.rb", "app/models/#{child_singular_name}.rb" template "app/views/albums/_form.html.haml", "app/views/#{parent_plural_name}/_form.html.haml" template "app/views/albums/_search.html.haml", "app/views/#{parent_plural_name}/_search.html.haml" template "app/views/albums/_upload_script.html.haml", "app/views/#{parent_plural_name}/_upload_script.html.haml" template "app/views/albums/edit.html.haml", "app/views/#{parent_plural_name}/edit.html.haml" template "app/views/albums/index.html.haml", "app/views/#{parent_plural_name}/index.html.haml" template "app/views/albums/manage.html.haml", "app/views/#{parent_plural_name}/manage.html.haml" template "app/views/albums/new.html.haml", "app/views/#{parent_plural_name}/new.html.haml" template "app/views/albums/show.html.haml", "app/views/#{parent_plural_name}/show.html.haml" template "app/views/albums/show.js.haml", "app/views/#{parent_plural_name}/show.js.haml" template "app/views/photos/_form.html.haml", "app/views/#{child_plural_name}/_form.html.haml" template "app/views/photos/_search.html.haml", "app/views/#{child_plural_name}/_search.html.haml" template "app/views/photos/_photo.html.haml", "app/views/#{child_plural_name}/_#{child_singular_name}.html.haml" template "app/views/photos/array.js.haml", "app/views/#{child_plural_name}/array.js.haml" template "app/views/photos/edit.html.haml", "app/views/#{child_plural_name}/edit.html.haml" template "app/views/photos/index.html.haml", "app/views/#{child_plural_name}/index.html.haml" template "app/views/photos/new.html.haml", "app/views/#{child_plural_name}/new.html.haml" template "app/views/photos/show.html.haml", "app/views/#{child_plural_name}/show.html.haml" template "app/views/photos/show.js.haml", "app/views/#{child_plural_name}/show.js.haml" template "app/views/view_albums/index.html.haml", "app/views/view_#{parent_plural_name}/index.html.haml" template "app/views/view_albums/show.html.haml", "app/views/view_#{parent_plural_name}/show.html.haml" end |
#child ⇒ Object
106 107 108 |
# File 'lib/generators/dust/albums/albums_generator.rb', line 106 def child child_model_name.downcase.singularize end |
#child_class_name ⇒ Object
130 131 132 |
# File 'lib/generators/dust/albums/albums_generator.rb', line 130 def child_class_name child.camelize end |
#child_plural_class_name ⇒ Object
138 139 140 |
# File 'lib/generators/dust/albums/albums_generator.rb', line 138 def child_plural_class_name child_plural_name.camelize end |
#child_plural_name ⇒ Object
122 123 124 |
# File 'lib/generators/dust/albums/albums_generator.rb', line 122 def child_plural_name child.underscore.pluralize end |
#child_singular_name ⇒ Object
114 115 116 |
# File 'lib/generators/dust/albums/albums_generator.rb', line 114 def child_singular_name child.underscore end |
#create_migration ⇒ Object
18 19 20 |
# File 'lib/generators/dust/albums/albums_generator.rb', line 18 def create_migration migration_template "migration/albums_migration.rb", "db/migrate/create_#{parent_plural_name}.rb" end |
#css ⇒ Object
69 70 71 72 73 |
# File 'lib/generators/dust/albums/albums_generator.rb', line 69 def css template "stylesheets/dust_album.css", "public/stylesheets/dust_#{parent_singular_name}.css" template "stylesheets/uploadify.css", "public/stylesheets/#{parent_singular_name}_uploadify.css" template "stylesheets/dust_album_app.css", "public/stylesheets/dust_#{parent_singular_name}_app.css" end |
#images ⇒ Object
85 86 87 88 89 90 |
# File 'lib/generators/dust/albums/albums_generator.rb', line 85 def images template "images/cancel.png", "public/images/cancel.png" template "images/browse.png", "public/images/browse.png" template "images/upload.png", "public/images/upload.png" template "images/save_position.png", "public/images/save_position.png" end |
#initializers ⇒ Object
92 93 94 95 |
# File 'lib/generators/dust/albums/albums_generator.rb', line 92 def initializers template "initializers/flash_session_cookie_middleware.rb", "config/initializers/flash_session_cookie_middleware.rb" template "initializers/session_store_middleware.rb", "config/initializers/session_store_middleware.rb" end |
#javascript ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/generators/dust/albums/albums_generator.rb', line 75 def javascript template "javascripts/dragsort.js", "public/javascripts/dragsort.js" template "javascripts/dust_album.js", "public/javascripts/dust_#{parent_singular_name}.js" src_dir = File.join(source_root, 'javascripts', 'uploadify') dst_dir = File.join(RAILS_ROOT, 'public', 'javascripts') FileUtils.cp_r src_dir, dst_dir, :verbose => true end |
#parent ⇒ Object
NAMING METHODS
102 103 104 |
# File 'lib/generators/dust/albums/albums_generator.rb', line 102 def parent parent_model_name.downcase.singularize end |
#parent_class_name ⇒ Object
126 127 128 |
# File 'lib/generators/dust/albums/albums_generator.rb', line 126 def parent_class_name parent.camelize end |
#parent_plural_class_name ⇒ Object
134 135 136 |
# File 'lib/generators/dust/albums/albums_generator.rb', line 134 def parent_plural_class_name parent_plural_name.camelize end |
#parent_plural_name ⇒ Object
118 119 120 |
# File 'lib/generators/dust/albums/albums_generator.rb', line 118 def parent_plural_name parent.underscore.pluralize end |
#parent_singular_name ⇒ Object
110 111 112 |
# File 'lib/generators/dust/albums/albums_generator.rb', line 110 def parent_singular_name parent.underscore end |
#rake_migrations ⇒ Object
97 98 99 |
# File 'lib/generators/dust/albums/albums_generator.rb', line 97 def rake_migrations rake("db:migrate") end |
#routes ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/generators/dust/albums/albums_generator.rb', line 22 def routes route("match \"all/#{parent_plural_name}\" => \"view_#{parent_plural_name}#index\", :as => :view_#{parent_plural_name}") route("match \"#{child_plural_name}-for/:filename\" => \"view_#{parent_plural_name}#show\", :as => :view_#{parent_singular_name}") route("match \"manage-#{child_plural_name}/:id\" => \"#{parent_plural_name}#manage\", :as => :manage_#{child_plural_name}") route("match \"#{child_plural_name}/array\" => \"#{child_plural_name}#array\", :as => :#{child_plural_name}_sort") route("match \"destroy-#{child_plural_name}\" => \"#{child_plural_name}#destroy\", :as => :#{child_plural_name}_bulk_delete") route("resources :#{parent_plural_name}") route("resources :#{child_plural_name}") end |
#source_root ⇒ Object
14 15 16 |
# File 'lib/generators/dust/albums/albums_generator.rb', line 14 def source_root @source_root ||= File.('../templates', __FILE__) end |