bin/extract-request-response.rb
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# Split trace org file into separate files each containing a request/response by name
usr/bin/env ruby
coding: utf-8
Split trace org file into separate files each containing a request/response by name
usr / bin / env ruby coding : utf - 8 Split trace org file into separate files each containing a request / response by name
def extract_sections(text)
  in_section = false
  sections = []
  text.each_line do |line|
    line = line.chomp
    case line
    when /^\** (Request|Response)+/
      in_section = true
      section_name = line
      sections << [section_name, []]
    when /^\*+/
      in_section = false
      section_name = nil
    else
      if in_section
        sections[-1][-1] << line
      end
    end
  end
  sections
end
def extract_sections ( text ) in_section = false sections = [ ] text . each_line do | line | line = line . chomp case line when / ^ \* * (Request|Response)+ / in_section = true section_name = line sections << [ section_name , [ ] ] when / ^ \* + / in_section = false section_name = nil else if in_section sections [ - 1 ] [ - 1 ] << line end end end sections end
usr/bin/env ruby
 coding: utf-8
Split trace org file into separate files each containing a request/response by name
usr / bin / env ruby coding : utf - 8 Split trace org file into separate files each containing a request / response by name
# request/response header # some other header
text
<not_specific>