class Rake::Migrations::Migrator
Attributes
task[R]
Public Class Methods
config()
click to toggle source
# File lib/rake/migrations/migrator.rb, line 20 def self.config @config ||= Rake::Migrations::Configuration.load end
get_task_migrations()
click to toggle source
tasks to run every time + tasks that haven’t been run yet
# File lib/rake/migrations/migrator.rb, line 10 def self.get_task_migrations config.tasks.select do |task| task.run_every_time? || manifest.tasks.exclude?(task) end end
invoke(task)
click to toggle source
# File lib/rake/migrations/migrator.rb, line 24 def self.invoke(task) new(task).invoke end
manifest()
click to toggle source
# File lib/rake/migrations/migrator.rb, line 16 def self.manifest @manifest ||= Rake::Migrations::Manifest.load end
new(task)
click to toggle source
# File lib/rake/migrations/migrator.rb, line 30 def initialize(task) @task = task end
run_task_migrations()
click to toggle source
# File lib/rake/migrations/migrator.rb, line 3 def self.run_task_migrations get_task_migrations.each do |task| invoke task end end
Public Instance Methods
invoke()
click to toggle source
# File lib/rake/migrations/migrator.rb, line 34 def invoke with_handler do Rake::Task[task.command].invoke end end
manifest()
click to toggle source
# File lib/rake/migrations/migrator.rb, line 40 def manifest self.class.manifest end
Private Instance Methods
announce(message)
click to toggle source
# File lib/rake/migrations/migrator.rb, line 66 def announce(message) text = "#{task.name}: #{message}" length = [0, 75 - text.length].max write "== %s %s" % [text, "=" * length] end
say(message, subitem=false)
click to toggle source
# File lib/rake/migrations/migrator.rb, line 62 def say(message, subitem=false) write "#{subitem ? " ->" : "--"} #{message}" end
with_handler(&block)
click to toggle source
# File lib/rake/migrations/migrator.rb, line 46 def with_handler(&block) announce "migrating" time = Benchmark.measure do block.call end announce "migrated (%.4fs)" % time.real; manifest.update(task) end
write(text)
click to toggle source
# File lib/rake/migrations/migrator.rb, line 58 def write(text) puts(text) end