Sha256: a966eaf95bd21c1551605847b64ba7032364566f50d7d2f82865e6d008764000

Contents?: true

Size: 982 Bytes

Versions: 1

Compression:

Stored size: 982 Bytes

Contents

module DataForge
  module File

    autoload :CSV, 'data_forge/file/csv'
    autoload :RecordFileDefinition, 'data_forge/file/record_file_definition'
    autoload :RecordFileReader, 'data_forge/file/record_file_reader'
    autoload :RecordFileWriter, 'data_forge/file/record_file_writer'


    @file_definitions = {}

    class << self

      def register_file_definition(name, &initialization_block)
        @file_definitions[name] = File::RecordFileDefinition.from_input name, &initialization_block
      end



      def reader_for(definition_name)
        raise "Unknown file reference '#{definition_name}'" unless @file_definitions.has_key? definition_name

        RecordFileReader.for @file_definitions[definition_name]
      end



      def writer_for(definition_name)
        raise "Unknown file reference '#{definition_name}'" unless @file_definitions.has_key? definition_name

        RecordFileWriter.for @file_definitions[definition_name]
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
data_forge-0.1 lib/data_forge/file.rb