Sha256: f65bb158d5c80494999e5ee3d4be994aeebe9f20a34cc04c8d02d7627f0ca978
Contents?: true
Size: 1.07 KB
Versions: 3
Compression:
Stored size: 1.07 KB
Contents
module MinceMigrator require 'fileutils' require_relative 'migrations/versioned_file' require_relative 'migrations/name' require_relative 'config' class Creator attr_reader :name, :migration_name def initialize(name=nil) @migration_name = Migrations::Name.new(name) @name = migration_name.value end def can_create_migration? migration_name.valid? end def reasons_for_failure migration_name.reasons_for_failure end def create_migration FileUtils.mkdir_p(Config.migration_dir) file = ::File.open(migration_file.full_path, 'w+') file.write migration_file.body file.close end def migration_file @migration_file ||= versioned_file.next_unused_version end def versioned_file @versioned_file ||= Migrations::VersionedFile.new(name) end def migration_file_relative_path migration_file.full_relative_path end def self.create(name) new(name).tap do |creator| creator.create_migration if creator.can_create_migration? end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mince_migrator-1.0.2 | lib/mince_migrator/creator.rb |
mince_migrator-1.0.1 | lib/mince_migrator/creator.rb |
mince_migrator-1.0.0 | lib/mince_migrator/creator.rb |