class DataKeeper::Loader::InflatedFiles

Attributes

errors[R]

Public Class Methods

new(dump, paths) click to toggle source
# File lib/data_keeper/loader.rb, line 123
def initialize(dump, paths)
  @dump = dump
  @paths = paths
  @errors = []
end

Public Instance Methods

schema_path() click to toggle source
# File lib/data_keeper/loader.rb, line 139
def schema_path
  @schema_path ||= @paths.find { |x| File.basename(x) == "schema.dump" }
end
sql_dumps() click to toggle source
# File lib/data_keeper/loader.rb, line 147
def sql_dumps
  @sql_dumps ||= @dump.sqls.map do |name, (table, _proc)|
    path = @paths.find { |x| File.basename(x) == "#{name}.csv" }
    next unless path

    [table, path]
  end.compact
end
tables_path() click to toggle source
# File lib/data_keeper/loader.rb, line 143
def tables_path
  @tables_path ||= @paths.find { |x| File.basename(x) == "tables.dump" }
end
valid?() click to toggle source
# File lib/data_keeper/loader.rb, line 129
def valid?
  @errors = []

  validate("Schema file is missing") { !!schema_path } &&
    validate("Tables file is missing") { !!tables_path } &&
    validate("Not all sql custom dumps are present") do
      sql_dumps.size == @dump.sqls.keys.size
    end
end

Private Instance Methods

validate(error_message) { || ... } click to toggle source
# File lib/data_keeper/loader.rb, line 158
def validate(error_message)
  result = yield
  @errors << error_message unless result
  result
end