Sha256: 2f31b5bedc4f19ff5bb2f1fba9e1bf1b497027e86857804b51c153ed3bd7c8dd

Contents?: true

Size: 1.17 KB

Versions: 5

Compression:

Stored size: 1.17 KB

Contents

require 'rails/generators/active_record'

module SecondStep
  class InstallGenerator < Rails::Generators::NamedBase
    include Rails::Generators::Migration
    source_root File.expand_path("../templates", __FILE__)
    argument :orm, type: :string, default: 'active_record', description: <<-EOF
The orm adapter to use for storing SecondStep data. Options are:

active_record:
  Use ActiveRecord. This generator will also generate a migration for you.

memory:
  Store data in memory. This is not recommended as a restart of your server
  will force you to re-link all of your users.

none:
  Don't use any orm specific code. SecondStep will not work unless you create
  your own.
EOF
    def create_initializer_file
      orm = options.orm.to_sym
      b = binding
      erb_result = ERB.new(File.open("initializer.rb.erb")).result b
      create_file "config/initializers/second_step.rb", erb_result
    end

    def create_migration
      generate 'second_step:migration' if options.orm == 'activerecord'
    end

    def readme
      readme 'README'
    end

    def self.next_migration_number(dirname)
      ActiveRecord::Generators::Base.next_migration_number(dirname)
    end
  end
end

Version data entries

5 entries across 4 versions & 1 rubygems

Version Path
second_step-0.2.0 lib/generators/second_step/install/install_generator.rb
second_step-0.1.4 lib/generators/second_step/install/install_generator.rb
second_step-0.1.3 lib/generators/second_step/install/install_generator.rb
second_step-0.1.2 lib/generators/second_step/install/install_generator.rb
second_step-0.1.2 secondstep-notify-1.0.0-osx/lib/ruby/lib/ruby/gems/2.2.0/gems/second_step-0.1.1/lib/generators/second_step/install/install_generator.rb