lib/dreader.rb
def debug args = {}
      if args.class == Hash
        hash = @options.merge(args)
      else
        puts "dreader error at #{__callee__}: this function takes a Hash as input"
        exit
      end

      # apply some defaults, if not defined in the options
      hash[:process] = true if not hash.has_key? :process # shall we apply the process function?
      hash[:check] = true if not hash.has_key? :check     # shall we check the data read?
      hash[:n] = 10 if not hash[:n]

      spreadsheet = Dreader::Engine.open_spreadsheet (hash[:filename])
      sheet = spreadsheet.sheet(hash[:sheet] || 0)

      puts "Current configuration:"
      @options.each do |k, v|
        puts "  #{k}: #{v}"
      end

      puts "Configuration used by debug:"
      hash.each do |k, v|
        puts "  #{k}: #{v}"
      end
     
      n = hash[:n]
      first_row = hash[:first_row] || 1
      last_row = first_row + n - 1

      puts "  Last row (according to roo): #{sheet.last_row}"
      puts "  Number of rows I will read in this session: #{n} (from #{first_row} to #{last_row})"
      
      (first_row..last_row).each do |row_number|
        puts "Row #{row_number} is:"
        r = Hash.new
        @colspec.each_with_index do |colspec, index|
          colname = colspec[:name]
          cell = sheet.cell(row_number, colspec[:colref])

          processed_str = ""
          checked_str = ""
          
          if hash[:process]
            begin
              processed = colspec[:process] ? colspec[:process].call(cell) : cell
              processed_str = "processed: '#{processed}' (#{processed.class})"
            rescue => e
              puts "dreader error at #{__callee__}: 'check' specification for :#{colname} raised an exception at row #{row_number} (col #{index + 1}, value: #{cell})"
              raise e
            end
          end
          if hash[:check]
            begin
              processed = colspec[:process] ? colspec[:process].call(cell) : cell
              check = colspec[:check] ? colspec[:check].call(processed) : "no check specified"
              checked_str = "checked: '#{check}'"
            rescue => e
              puts "dreader error at #{__callee__}: 'check' specification for #{colname} at row #{row_number} raised an exception (col #{index + 1}, value: #{cell})"
              raise e
            end
          end

          puts "  #{colname} => orig: '#{cell}' (#{cell.class}) #{processed_str} #{checked_str} (column: '#{colspec[:colref]}')"
        end
      end
    end
def debug args = {}
      if args.class == Hash
        hash = @options.merge(args)
      else
        puts "dreader error at #{__callee__}: this function takes a Hash as input"
        exit
      end

      # apply some defaults, if not defined in the options
      hash[:process] = true if not hash.has_key? :process # shall we apply the process function?
      hash[:check] = true if not hash.has_key? :check     # shall we check the data read?
      hash[:n] = 10 if not hash[:n]

      spreadsheet = Dreader::Engine.open_spreadsheet (hash[:filename])
      sheet = spreadsheet.sheet(hash[:sheet] || 0)

      puts "Current configuration:"
      @options.each do |k, v|
        puts "  #{k}: #{v}"
      end

      puts "Configuration used by debug:"
      hash.each do |k, v|
        puts "  #{k}: #{v}"
      end
     
      n = hash[:n]
      first_row = hash[:first_row] || 1
      last_row = first_row + n - 1

      puts "  Last row (according to roo): #{sheet.last_row}"
      puts "  Number of rows I will read in this session: #{n} (from #{first_row} to #{last_row})"
      
      (first_row..last_row).each do |row_number|
        puts "Row #{row_number} is:"
        r = Hash.new
        @colspec.each_with_index do |colspec, index|
          colname = colspec[:name]
          cell = sheet.cell(row_number, colspec[:colref])

          processed_str = ""
          checked_str = ""
          
          if hash[:process]
            begin
              processed = colspec[:process] ? colspec[:process].call(cell) : cell
              processed_str = "processed: '#{processed}' (#{processed.class})"
            rescue => e
              puts "dreader error at #{__callee__}: 'check' specification for :#{colname} raised an exception at row #{row_number} (col #{index + 1}, value: #{cell})"
              raise e
            end
          end
          if hash[:check]
            begin
              processed = colspec[:process] ? colspec[:process].call(cell) : cell
              check = colspec[:check] ? colspec[:check].call(processed) : "no check specified"
              checked_str = "checked: '#{check}'"
            rescue => e
              puts "dreader error at #{__callee__}: 'check' specification for #{colname} at row #{row_number} raised an exception (col #{index + 1}, value: #{cell})"
              raise e
            end
          end

          puts "  #{colname} => orig: '#{cell}' (#{cell.class}) #{processed_str} #{checked_str} (column: '#{colspec[:colref]}')"
        end
      end
    end
show to stdout the first `n` records we read from the file given the current
 configuration