module.exports={postToRally:function(){console.log("I made it inside the reporter");var e=protractor.promise.defer();return protractor.promise.controlFlow().execute(function(){var t=require("fs"),s=require("xml2js").parseString;console.log("About to write jasmine file");var r=new Array;t.readFile(path.resolve(__dirname,"./../../../Reports/jasmine.xml"),"UTF-8",function(i,n){s(n,function(s,i){console.log(i.testsuites.testsuite.length),console.dir(JSON.stringify(i));var n=function(e,t){if(e<t){var s=i.testsuites.testsuite[e].$.name,o=s.replace(/ /g,"-"),a=new Array;console.log("Length of steps: "+i.testsuites.testsuite[e].testcase.length);var l=function(t,s){if(t<s){var r=i.testsuites.testsuite[e].testcase[t].$.name,n=r.replace(/ /g,"-"),c=i.testsuites.testsuite[e].testcase[t].$.time;if(null!=i.testsuites.testsuite[e].testcase[t].failure&&"unknown"!=typeof i.testsuites.testsuite[e].testcase[t].failure)u="failed";else var u="passed";var p="",m="",v="";void 0!=process.env.user_story&&""!=process.env.user_story&&(console.log("Assigned env user story"),p=(p=process.env.user_story).match(/US[0-9]+/g));var d=r.split(":");if("false"==process.env.overwrite_US||void 0==process.env.overwrite_US?2==d.length?(d[0].match(/US[0-9]+/g)?p=(p=d[0]).match(/US[0-9]+/g):m=d[0],v=d[1]):3==d.length?(d[0].match(/US[0-9]+/)?(p=d[0],m=d[1]):(m=d[0],p=d[1]),p=p.match(/US[0-9]+/g),v=d[2]):v=d[0]:2==d.length?(d[0].match(/US[0-9]+/g)||(m=d[0]),v=d[1]):3==d.length?(m=d[0].match(/US[0-9]+/)?d[1]:d[0],v=d[2]):v=d[0],""!=p)var g=p.join(",");""!=m&&(void 0==g&&void 0!=m?g=m:g+=":"+m);var h={name:r=d.length>1&&("false"==process.env.overwrite_US||void 0==process.env.overwrite_US)?g+":"+v:""!=g&&void 0!=g?g+":"+v:d[0],id:o+";"+n,line:"",keyword:"Scenario",description:"",type:"scenario",steps:[{name:r,line:"",keyword:"Given",result:{status:u,duration:c},match:{location:""}},{keyword:"After",hidden:!0,result:{status:"passed",duration:951364},match:{location:""}}]};if(null!=p&&p.length>1){console.log("Reached here"),h.name=d[0].replace(/(,(\s*)?US[0-9]+)+/g,"")+":"+d[1]+"_US_1";for(var f=1;f<p.length;f++){var S=JSON.parse(JSON.stringify(h)),y=S.name.split(":")[0].replace(/US[0-9]+/g,p[f]);S.name=y+":"+S.name.split(":")[1].substring(0,S.name.split(":")[1].length-2)+"_"+(f+1),a.push(S)}}a.push(h),l(t+1,s)}};l(0,i.testsuites.testsuite[e].testcase.length),describeStatementObject={id:o,name:s,description:"",line:"",keyword:"Feature",uri:"",elements:a},r.push(describeStatementObject),n(e+1,t)}};n(0,i.testsuites.testsuite.length),t.writeFile(path.resolve(__dirname,"./../../../Reports/json_report/jasmineRally.json"),JSON.stringify(r),function(t){if(t)throw t;require("./Rally.js").RallyWebAPI(path.resolve(__dirname,"./../../../Reports/json_report/jasmineRally.json"),function(){e.fulfill(),wroteFile=!0})})})})}),e}};