lib/packaging/util/net.rb
# This is fairly absurd. We're implementing curl by shelling out. What do I
# wish we were doing? Using a sweet ruby wrapper around curl, such as Curb or
# Curb-fu. However, because we're using clean build systems and trying to
# make this portable with minimal system requirements, we can't very well
# depend on libraries that aren't in the ruby standard libaries. We could
# also do this using Net::HTTP but that set of libraries is a rabbit hole to
# go down when what we're trying to accomplish is posting multi-part form
# data that includes file uploads to jenkins. It gets hairy fairly quickly,
# but, as they say, pull requests accepted.
#
# This method takes three arguments
# 1) String - the URL to post to
# 2) Array  - Ordered array of name=VALUE curl form parameters
# 3) Hash - Options to be set
This is fairly absurd. We're implementing curl by shelling out. What do I
wish we were doing. Using a sweet ruby wrapper around curl, such as Curb or
Curb-fu. However, because we're using clean build systems and trying to
make this portable with minimal system requirements, we can't very well
depend on libraries that aren't in the ruby standard libaries. We could
also do this using Net::HTTP but that set of libraries is a rabbit hole to
go down when what we're trying to accomplish is posting multi-part form
data that includes file uploads to jenkins. It gets hairy fairly quickly,
but, as they say, pull requests accepted.

This method takes three arguments
1) String - the URL to post to
2) Array  - Ordered array of name=VALUE curl form parameters
3) Hash - Options to be set
This is fairly absurd . We ' re implementing curl by shelling out . What do I wish we were doing . Using a sweet ruby wrapper around curl such as Curb or Curb - fu . However because we ' re using clean build systems and trying to make this portable with minimal system requirements we can ' t very well depend on libraries that aren ' t in the ruby standard libaries . We could also do this using Net :: HTTP but that set of libraries is a rabbit hole to go down when what we ' re trying to accomplish is posting multi - part form data that includes file uploads to jenkins . It gets hairy fairly quickly but as they say pull requests accepted . This method takes three arguments 1 ) String - the URL to post to 2 ) Array - Ordered array of name = VALUE curl form parameters 3 ) Hash - Options to be set
def curl_form_data(uri, form_data = [], options = {})
      curl = Pkg::Util::Tool.check_tool("curl")
       Begin constructing the post string.
       First, assemble the form_data arguments
      post_string = "-i "
      form_data.each do |param|
        post_string << "{param} "
      end
       Add the uri
      post_string << "{uri}"
       If this is quiet, we're going to silence all output
      if options[:quiet]
        post_string << " >{Pkg::Util::OS::DEVNULL} 2>&1"
      end
      begin
        Pkg::Util::Execution.ex("{curl} {post_string}")
      rescue RuntimeError
        return false
      end
    end
def curl_form_data ( uri , form_data = [ ] , options = { } ) curl = Pkg :: Util :: Tool . check_tool ( "curl" ) post_string = "-i " form_data . each do | param | post_string << "#{param} " end post_string << "#{uri}" if options [ :quiet ] post_string << " >#{Pkg::Util::OS::DEVNULL} 2>&1" end begin Pkg :: Util :: Execution . ex ( "#{curl} #{post_string}" ) rescue RuntimeError return false end end
This is fairly absurd.
This is fairly absurd .
# # Begin constructing the post string. # First, assemble the form_data arguments # # Add the uri # If this is quiet, we're going to silence all output
uri
<not_specific>
form_data
<not_specific>
options
<not_specific>