ruby - send multiple params to hash -


hy parse file find params uid,dbname , url. try value in hash sending in csv file

when parse hash (res_licence) have 3 params

uid, uid'] = 'adfs'; url, url'] = 'https://mydom.sandboxbk.net'; dbname,

i cant find why override :(

res_licence = hash.new  array = dir.glob('configuration_*') array.each |f|        file = file.open(f ,"r")       lines = file.readlines    lines.each |line|    if line.include? 'uid'      uid = line.match(/(?=uid)(.*)/)      puts ""      puts "==>#{uid} "      #res_licence = { uid: uid}   end     if line.include? 'url'      url = line.match(/(?=url)(.*)/)      puts "==>#{url} "        #res_licence = {  url: url}   end     if line.include? 'dbname'      dbname = line.match(/(?=dbname)(.*)/)      puts "=>#{dbname} "    end      res_licence = {uid: uid, url: url, dbname: dbname}    end   end 

i found solution problem, , times dont have uid => "xxx", url=> "xxx"

configs = {} dir.glob('configuration_*').each |filename|  configs[filename]= hash.new   file.foreach(filename) |line|            if line.include? 'uid'               next unless line.match(/(?=uid).*?[\'\"].*?[\'\"](.*?)[\'\"](.*?)[\;\"]/)                 field, value = line.split("=",2);              ( configs[filename] = []  <<  value.strip.gsub("';", "").gsub("'",""))                #( configs[filename][:uid] ||= [] ) <<  value.strip.gsub("';", "").gsub("'","")           end    csv.open("/tmp/data.csv", "wb", options = {quote_char: "\0" }) {|csv| configs.each {|input| csv << input }} 

now have last problem when execute script in output

configuration_groupe-poult.mydomain.net.php,["group", "https://groupe-poult.mydomain.net", "group"] configuration_kb-in.mydomain.net.php,["kbin", "https://kb-in.mydomain.net", "kauf"] 

how can remove hook'[ ] , quote " ?


Comments

Popular posts from this blog

Why can rails not find a route created by a helper? -

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -