class Dust::Generators::AlbumsGenerator

Public Instance Methods

app() click to toggle source
# 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() click to toggle source
# File lib/generators/dust/albums/albums_generator.rb, line 106
def child
  child_model_name.downcase.singularize
end
child_class_name() click to toggle source
# File lib/generators/dust/albums/albums_generator.rb, line 130
def child_class_name
  child.camelize
end
child_plural_class_name() click to toggle source
# File lib/generators/dust/albums/albums_generator.rb, line 138
def child_plural_class_name
  child_plural_name.camelize
end
child_plural_name() click to toggle source
# File lib/generators/dust/albums/albums_generator.rb, line 122
def child_plural_name
  child.underscore.pluralize
end
child_singular_name() click to toggle source
# File lib/generators/dust/albums/albums_generator.rb, line 114
def child_singular_name
  child.underscore
end
create_migration() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source

NAMING METHODS

# File lib/generators/dust/albums/albums_generator.rb, line 102
def parent
  parent_model_name.downcase.singularize
end
parent_class_name() click to toggle source
# File lib/generators/dust/albums/albums_generator.rb, line 126
def parent_class_name
  parent.camelize
end
parent_plural_class_name() click to toggle source
# File lib/generators/dust/albums/albums_generator.rb, line 134
def parent_plural_class_name
  parent_plural_name.camelize
end
parent_plural_name() click to toggle source
# File lib/generators/dust/albums/albums_generator.rb, line 118
def parent_plural_name
  parent.underscore.pluralize
end
parent_singular_name() click to toggle source
# File lib/generators/dust/albums/albums_generator.rb, line 110
def parent_singular_name
  parent.underscore
end
rake_migrations() click to toggle source
# File lib/generators/dust/albums/albums_generator.rb, line 97
def rake_migrations
  rake("db:migrate")
end
routes() click to toggle source
# 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() click to toggle source
# File lib/generators/dust/albums/albums_generator.rb, line 14
def source_root
  @source_root ||= File.expand_path('../templates', __FILE__)
end