Class: MigrationWriter
- Inherits:
-
Object
- Object
- MigrationWriter
- Defined in:
- app/writers/migration_writer.rb
Instance Attribute Summary collapse
-
#data_table ⇒ Object
readonly
Returns the value of attribute data_table.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data_table) ⇒ MigrationWriter
constructor
A new instance of MigrationWriter.
- #write ⇒ Object
Constructor Details
#initialize(data_table) ⇒ MigrationWriter
Returns a new instance of MigrationWriter.
4 5 6 |
# File 'app/writers/migration_writer.rb', line 4 def initialize(data_table) @data_table = data_table end |
Instance Attribute Details
#data_table ⇒ Object (readonly)
Returns the value of attribute data_table.
2 3 4 |
# File 'app/writers/migration_writer.rb', line 2 def data_table @data_table end |
Class Method Details
.write_schema_migration ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/writers/migration_writer.rb', line 8 def self.write_schema_migration FileUtils.mkdir_p('db/migrate') return if schema_migration_created? File.open(schema_migration, 'w') do |f| f.puts <<-schema_migration class CreateGatherableSchema < ActiveRecord::Migration def up create_schema '#{Gatherable.config.schema_name}' end def down drop_schema '#{Gatherable.config.schema_name}' end end schema_migration end puts "created #{schema_migration}" if File.exists?(schema_migration) end |
Instance Method Details
#write ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/writers/migration_writer.rb', line 27 def write if matching_migrations.present? puts return end FileUtils.mkdir_p('db/migrate') filename = "db/migrate/#{self.class.}_#{file_suffix}" File.open(filename, 'w') do |f| f.puts file_template end puts "created #{filename}" if File.exists?(filename) end |