编辑代码

text1 = "PrecursorEnterpriseApplicationTypeEnum"
text2 = 'NETWORK_APPLICATION(1, "入网申请"),
    CHANGE_APPLICATION(2, "变更申请")'
data_arr = []
text2.split("\n").map{|line| line.strip}.each do |line|
    arr = line.split("(").last.split(")").first.split(",")
    data_arr << "\"#{arr[0].to_s.strip}\":#{arr[1, arr.length-1].join("").to_s.strip}"
end
puts text1.gsub(/::/, '/').
    gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
    gsub(/([a-z\d])([A-Z])/,'\1_\2').
    tr("-", "_").
    downcase.
    gsub("_enum","")
puts "{" + data_arr.join(",") + "}"