Chapter 09/circuit-oneops-1-master/components/cookbooks/spark-v1/recipes/spark_helper.rb
# Corrects the Nexus URL by ensuring that it is in the proper format
#
# INPUT:
# orig_nexus_url: The original Nexus URL
#
# RETURNS:
# A string containing the corrected URL
#
Corrects the Nexus URL by ensuring that it is in the proper format
INPUT:
orig_nexus_url: The original Nexus URL

A string containing the corrected URL
Corrects the Nexus URL by ensuring that it is in the proper format INPUT : orig_nexus_url : The original Nexus URL A string containing the corrected URL
def fix_nexus_url(orig_nexus_url)
  new_nexus_url = orig_nexus_url
  Chef::Log.info("fix_nexus_url: in: {orig_nexus_url}")
  urlArray = orig_nexus_url.split("/")
   [http:|https:]//[server]
   or
   [http:|https:]//[server]/nexus
  if (urlArray[0] == 'http:' || urlArray[0] == 'https:') && (urlArray[1] == '') && (urlArray.length == 3 || ((urlArray.length == 4) && (urlArray[3] == 'nexus')))
     Make sure the URL ends with "nexus"
    new_nexus_url = urlArray[0] + "//" + urlArray[2] + "/nexus"
  end
  Chef::Log.info("fix_nexus_url: out: {new_nexus_url}")
  return new_nexus_url
end
def fix_nexus_url ( orig_nexus_url ) new_nexus_url = orig_nexus_url Chef :: Log . info ( "fix_nexus_url: in: #{orig_nexus_url}" ) urlArray = orig_nexus_url . split ( "/" ) if ( urlArray [ 0 ] == 'http:' || urlArray [ 0 ] == 'https:' ) && ( urlArray [ 1 ] == '' ) && ( urlArray . length == 3 || ( ( urlArray . length == 4 ) && ( urlArray [ 3 ] == 'nexus' ) ) ) new_nexus_url = urlArray [ 0 ] + "//" + urlArray [ 2 ] + "/nexus" end Chef :: Log . info ( "fix_nexus_url: out: #{new_nexus_url}" ) return new_nexus_url end
Corrects the Nexus URL by ensuring that it is in the proper format
INPUT:
orig_nexus_url: The original Nexus URL
Corrects the Nexus URL by ensuring that it is in the proper format INPUT : orig_nexus_url : The original Nexus URL
# Expect the string to be: # # [http:|https:]//[server] # # or # # [http:|https:]//[server]/nexus # # Make sure the URL ends with "nexus"
orig_nexus_url
<not_specific>