Repository URL to install this package:
|
Version:
0.3.3 ▾
|
module NeotericAssets
class InstallGenerator < Rails::Generators::Base
desc "Installs Neoteric Assets and generates the necessary migrations"
include Rails::Generators::Migration
def self.source_root
@_neoteric_assets_source_root ||= File.expand_path("../templates", __FILE__)
end
def self.next_migration_number(dirname)
Time.now.strftime("%Y%m%d%H%M%S")
end
def copy_classes
copy_file "image.rb", "app/models/image.rb"
copy_file "images_controller.rb", "app/controllers/images_controller.rb"
end
def create_initializer
initializer "neoteric-assets.rb", "NEOTERIC_ASSETS_URL_PREFIX='http://s3-bucket.com/images/'"
end
def create_migrations
Dir["#{self.class.source_root}/migrations/*.rb"].sort.each do |filepath|
name = File.basename(filepath)
migration_template "migrations/#{name}", "db/migrate/#{name.gsub(/^\d+_/,'')}"
sleep 1
end
generate("neoteric_swfupload:install")
rake("db:migrate db:test:prepare")
end
end
end