Class: InstallContactSyncGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/install_contact_sync/install_contact_sync_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(path) ⇒ Object



6
7
8
# File 'lib/generators/install_contact_sync/install_contact_sync_generator.rb', line 6

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

Instance Method Details

#generate_encrypted_strings_configObject



23
24
25
26
27
28
29
30
31
# File 'lib/generators/install_contact_sync/install_contact_sync_generator.rb', line 23

def generate_encrypted_strings_config
  inject_into_file 'config/environments/development.rb', before: "end\n" do "\nEncryptedStrings::SymmetricCipher.default_algorithm = 'aes-256-cbc'\nEncryptedStrings::SymmetricCipher.default_password = 'Replace This with some long alphanumeric string'\n\n"
  end
end

#generate_migrationObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/generators/install_contact_sync/install_contact_sync_generator.rb', line 12

def  generate_migration
  if !self.class.migration_exists?('db/migrate', 'create_contact_sync_schema')
    migration_template "create_contact_sync_schema.rb", "db/migrate/create_contact_sync_schema.rb"
  end

  if !self.class.migration_exists?('db/migrate', 'remove_device_id_from_contacts')
    migration_template "remove_device_id_from_contacts.rb", "db/migrate/remove_device_id_from_contacts.rb"
  end

end

#generate_modelsObject



33
34
35
36
37
38
39
# File 'lib/generators/install_contact_sync/install_contact_sync_generator.rb', line 33

def generate_models
  template "address.rb",  'app/models/address.rb'
  template 'email.rb',    'app/models/email.rb'
  template 'phone.rb',    'app/models/phone.rb'
  template 'user.rb',     'app/models/user.rb'
  template 'contact.rb',  'app/models/contact.rb'
end