Sha256: 7ed673604777cb233d5ed4a66566ab7be2b69ad9bd606d5119c4040e97e484a6
Contents?: true
Size: 1.3 KB
Versions: 10
Compression:
Stored size: 1.3 KB
Contents
module Spread2RDF module Schema class Spreadsheet attr_reader :name attr_reader :worksheet def initialize(name, &block) @name = name @worksheet = {} @schema_spec = block end def spreadsheet self end def worksheets @worksheet.values end def sorted_worksheets unsorted_worksheets, sorted_worksheets = worksheets, [] unsorted_worksheets.reject! do |worksheet| worksheet.columns.empty? and sorted_worksheets << worksheet end while not unsorted_worksheets.empty? independent = unsorted_worksheets.find_index { |worksheet| unsorted_worksheets.none? do |other_worksheet| worksheet.depends_on? other_worksheet end } raise "schema contains cyclic dependencies" if independent.nil? sorted_worksheets << unsorted_worksheets.delete_at(independent) end sorted_worksheets end def map(input_file) mapping = Mapping::Spreadsheet.new(self, input_file) DSL.new(self, input_file).instance_exec(&@schema_spec) worksheets.each { |worksheet| worksheet.init } mapping.map mapping end end end end
Version data entries
10 entries across 10 versions & 1 rubygems