Sha256: 388e1265632fe5b1647dbfd42fba84d0b116380f9fdfea6e35be283cc80c4c11

Contents?: true

Size: 1.24 KB

Versions: 51

Compression:

Stored size: 1.24 KB

Contents

module EffectiveAssets
  module Generators
    class InstallGenerator < Rails::Generators::Base
      include Rails::Generators::Migration

      desc "Creates an EffectiveAssets initializer in your application."

      source_root File.expand_path("../../templates", __FILE__)

      def self.next_migration_number(dirname)
        if not ActiveRecord::Base.timestamped_migrations
          Time.new.utc.strftime("%Y%m%d%H%M%S")
        else
          "%.3d" % (current_migration_number(dirname) + 1)
        end
      end

      def copy_initializer
        template "effective_assets.rb", "config/initializers/effective_assets.rb"
      end

      def copy_uploader
        template "asset_uploader.rb", "app/uploaders/asset_uploader.rb"
      end

      def create_migration_file
        @assets_table_name = ':' + EffectiveAssets.assets_table_name.to_s
        @attachments_table_name = ':' + EffectiveAssets.attachments_table_name.to_s
        migration_template '../../../db/migrate/01_create_effective_assets.rb.erb', 'db/migrate/create_effective_assets.rb'
      end

      def install_delayed_jobs
        run "rails generate delayed_job:active_record"
      end

      def show_readme
        readme "README" if behavior == :invoke
      end
    end
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
effective_assets-1.3.0 lib/generators/effective_assets/install_generator.rb
effective_assets-1.2.5 lib/generators/effective_assets/install_generator.rb
effective_assets-1.2.4 lib/generators/effective_assets/install_generator.rb
effective_assets-1.2.3 lib/generators/effective_assets/install_generator.rb
effective_assets-1.2.2 lib/generators/effective_assets/install_generator.rb
effective_assets-1.2.0 lib/generators/effective_assets/install_generator.rb
effective_assets-1.1.2 lib/generators/effective_assets/install_generator.rb
effective_assets-1.1.1 lib/generators/effective_assets/install_generator.rb
effective_assets-1.1.0 lib/generators/effective_assets/install_generator.rb
effective_assets-1.0.0 lib/generators/effective_assets/install_generator.rb
effective_assets-0.1 lib/generators/effective_assets/install_generator.rb