Class: PrivatePerson::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Generators::Utils, Rails::Generators::Migration
Defined in:
lib/generators/private_person/install/install_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Generators::Utils

#ask_for, #output

Class Method Details

.next_migration_number(dirname) ⇒ Object


18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/generators/private_person/install/install_generator.rb', line 18

def self.next_migration_number(dirname)
  if ActiveRecord::Base.timestamped_migrations
    unless @prev_migration_nr
      @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
    else
      @prev_migration_nr += 1
    end
    @prev_migration_nr.to_s
  else
    "%.3d" % (current_migration_number(dirname) + 1)
  end
end

Instance Method Details

#add_migrationsObject


12
13
14
15
16
# File 'lib/generators/private_person/install/install_generator.rb', line 12

def add_migrations
  unless ActiveRecord::Base.connection.table_exists? 'permissions'
    migration_template 'migrate/create_permissions_table.rb', 'db/migrate/create_permissions_table.rb' rescue output $!.message
  end
end

#helloObject


8
9
10
# File 'lib/generators/private_person/install/install_generator.rb', line 8

def hello
  output "With PrivatePerson, you can put your users in control of their own privacy policies.", :magenta
end