Method: Watobo::Gui::ChatDiffViewer#normalizeData

Defined in:
lib/watobo/gui/chat_diff.rb

#normalizeData(data) ⇒ Object

Raises:

  • (ArgumentError)


153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/watobo/gui/chat_diff.rb', line 153

def normalizeData(data)
  raise ArgumentError, "Bad data type. Need Request/Response." unless data.respond_to? :headers 
  dummy = []
  begin
    unless data.headers.nil?
      data.headers.each do |h|
        dummy.concat adjustLine(h)    
      end
      
      dummy.push ""
    end
    
    
    unless data.body.nil?
    #  puts "> clean up body #{data.body.length}"
      body =  data.body_encoded
      body.split("\n").each do |l|
       # puts "[#{i}] #{l}"
        dummy.concat adjustLine(l)
      end
    end
  rescue => bang
    puts bang
    dummy = data
  end
  #  puts dummy.join("\n")
 # return dummy.join("\n")
  return dummy
end