Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
neoteric-assets / lib / generators / neoteric_assets / install / install_generator.rb
Size: Mime:
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