Class: IfreeSms::Generators::InstallGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.current_timeObject



30
31
32
33
# File 'lib/generators/ifree_sms/install_generator.rb', line 30

def self.current_time
  @current_time ||= Time.now
  @current_time += 1.minute
end

.next_migration_number(dirname) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/generators/ifree_sms/install_generator.rb', line 22

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

Instance Method Details

#copy_configurationsObject

copy configurations



18
19
20
# File 'lib/generators/ifree_sms/install_generator.rb', line 18

def copy_configurations
  copy_file('config/ifree_sms.rb', 'config/initializers/ifree_sms.rb')
end

#create_migrationsObject

copy migration files



13
14
15
# File 'lib/generators/ifree_sms/install_generator.rb', line 13

def create_migrations
  migration_template "migrate/create_messages.rb", File.join('db/migrate', "ifree_sms_create_messages.rb")
end