Class: PlatformGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object

Implement the required interface for Rails::Generators::Migration.



35
36
37
38
39
40
41
# File 'lib/generators/platform/platform_generator.rb', line 35

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

.source_rootObject



30
31
32
# File 'lib/generators/platform/platform_generator.rb', line 30

def self.source_root
  @source_root ||= File.expand_path('../templates', __FILE__)
end

Instance Method Details

#copy_configurationObject



47
48
49
50
# File 'lib/generators/platform/platform_generator.rb', line 47

def copy_configuration
  config_source = File.expand_path("#{self.class.source_root}/config", __FILE__)
  system "rsync -ruv #{config_source} #{Rails.root}/config"
end

#copy_layoutsObject



52
53
54
55
# File 'lib/generators/platform/platform_generator.rb', line 52

def copy_layouts
  layouts_source = File.expand_path("#{self.class.source_root}/layouts", __FILE__)
  system "rsync -ruv #{layouts_source} #{Rails.root}/app/views"
end

#create_migration_fileObject



43
44
45
# File 'lib/generators/platform/platform_generator.rb', line 43

def create_migration_file
  migration_template 'db/create_platform_tables.rb', 'db/migrate/create_platform_tables.rb'
end