lib/azure/table/batch_response.rb in azure-0.7.0 vs lib/azure/table/batch_response.rb in azure-0.7.1

- old
+ new

@@ -14,19 +14,19 @@ #-------------------------------------------------------------------------- module Azure module Table module BatchResponse def self.parse(data) - context = { + context = { :lines => data.lines.to_a, :index=> 0, :responses => [] } find(context) { |c| batch_boundary c } find(context) { |c| batch_headers c } - + while(find(context){ |c| changeset_boundary_or_end c } == :boundary) find(context) { |c| changeset_headers c } find(context) { |c| response c } find(context) { |c| response_headers c } find(context) { |c| response_body c } @@ -49,11 +49,11 @@ if end_of_body context[:responses].last[:body] ||= "" context[:responses].last[:body] << current_line(context) return context[:responses].last[:body] - else + else context[:responses].last[:body] ||= "" context[:responses].last[:body] << current_line(context) return nil end end @@ -77,11 +77,11 @@ match = /HTTP\/1.1 (\d*) (.*)/.match(current_line(context)) return nil unless match response = {:status_code => match[1], :message => match[2] } context[:responses].push response end - + def self.changeset_headers(context) current_line(context).strip == '' end def self.changeset_boundary_or_end(context) @@ -107,10 +107,10 @@ def self.batch_boundary(context) match = /--batchresponse_(.*)/.match(current_line(context)) match ? match[1] : nil end - + def self.current_line(context) context[:lines][context[:index]] end end end