class Rake::Migrations::Manifest

Constants

DEFAULT_FILE_PATH

Attributes

file_path[R]
tasks[R]

Public Class Methods

load(file_path = DEFAULT_FILE_PATH) click to toggle source
# File lib/rake/migrations/manifest.rb, line 5
def self.load(file_path = DEFAULT_FILE_PATH)
  manifest = new(file_path)
  manifest.load
  manifest
end
new(file_path) click to toggle source
# File lib/rake/migrations/manifest.rb, line 13
def initialize(file_path)
  @file_path = file_path
  @tasks     = []
end

Public Instance Methods

add_task(task) click to toggle source
# File lib/rake/migrations/manifest.rb, line 18
def add_task(task)
  @tasks << task unless @tasks.include?(task)
end
load() click to toggle source
# File lib/rake/migrations/manifest.rb, line 26
def load
  manifest = YAML.load_file(file_path).with_indifferent_access
  (manifest[:tasks] || []).each do |task|
    add_task Rake::Migrations::Task.new(*task)
  end
rescue Errno::ENOENT
end
save() click to toggle source
# File lib/rake/migrations/manifest.rb, line 34
def save
  File.open(file_path, 'w') { |f| f.write to_yaml  }
end
to_h() click to toggle source
# File lib/rake/migrations/manifest.rb, line 38
def to_h
  {
    tasks: tasks.map(&:name)
  }
end
Also aliased as: to_hash
to_hash()
Alias for: to_h
to_yaml() click to toggle source
# File lib/rake/migrations/manifest.rb, line 45
def to_yaml
  to_hash.to_yaml
end
update(task) click to toggle source
# File lib/rake/migrations/manifest.rb, line 22
def update(task)
  add_task(task) && save
end