class Migrate::Controller
Constants
- ROOT
Public Class Methods
new(root = ROOT)
click to toggle source
# File lib/migrate/controller.rb, line 30 def initialize(root = ROOT) @root = root end
Public Instance Methods
create!(name, &block)
click to toggle source
# File lib/migrate/controller.rb, line 45 def create!(name, &block) prefix = Time.now.strftime("%Y%m%d%H%M%S") path = @root / "#{prefix}-#{name}.rb" path.parent.mkpath path.open(File::CREAT|File::TRUNC|File::WRONLY, &block) return path end
migrate!()
click to toggle source
# File lib/migrate/controller.rb, line 38 def migrate! migrations.each do |migration| Console.logger.debug(self, "Applying #{migration}...") migration.call(self) end end
migrations()
click to toggle source
# File lib/migrate/controller.rb, line 34 def migrations @root.glob("**/*.rb").map{|path| Migration.new(path)}.sort end