vendor/bundle/ruby/2.7.0/gems/faraday-1.3.0/spec/support/helper_methods.rb
# parse a multipart MIME message, returning a hash of any multipart errors
parse a multipart MIME message, returning a hash of any multipart errors
parse a multipart MIME message returning a hash of any multipart errors
def parse_multipart(boundary, body)
      reader = MultipartParser::Reader.new(boundary)
      result = { errors: [], parts: [] }
      def result.part(name)
        hash = self[:parts].detect { |h| h[:part].name == name }
        [hash[:part], hash[:body].join]
      end
      reader.on_part do |part|
        result[:parts] << thispart = {
          part: part,
          body: []
        }
        part.on_data do |chunk|
          thispart[:body] << chunk
        end
      end
      reader.on_error do |msg|
        result[:errors] << msg
      end
      reader.write(body)
      result
    end
def parse_multipart ( boundary , body ) reader = MultipartParser :: Reader . new ( boundary ) result = { errors : [ ] , parts : [ ] } def result . part ( name ) hash = self [ :parts ] . detect { | h | h [ :part ] . name == name } [ hash [ :part ] , hash [ :body ] . join ] end reader . on_part do | part | result [ :parts ] << thispart = { part : part , body : [ ] } part . on_data do | chunk | thispart [ :body ] << chunk end end reader . on_error do | msg | result [ :errors ] << msg end reader . write ( body ) result end
parse a multipart MIME message, returning a hash of any multipart errors
parse a multipart MIME message returning a hash of any multipart errors
boundary
<not_specific>
body
<not_specific>