Convert shell script to ruby

can someone please help me convert this shell script to ruby?

#########################################################################

shell script:

#########################################################################

#!/bin/sh

awk ‘/{/,/}/’ ~/newservices.txt | while read line
do
BEGIN=$(echo “${line}” | egrep “:” | egrep “{”)
if [ ! -z “${BEGIN}” ] ; then
checkname=$(echo $line | awk -F":" ‘{print $1}’ | sed
's_"_g’)
echo “{” >
/tmp/services/monitoring
${checkname}vip.json
echo ’ “id”: "’"monitoring
${checkname}vip"’",’ >>
/tmp/services/monitoring
${checkname}vip.json
continue
fi
USENRPE=$(echo “${line}” | egrep “nrpe_args”)
if [ ! -z “${USENRPE}” ] ; then
echo " ${line}" >>
/tmp/services/monitoring
${checkname}vip.json
echo ’ “use_existing_command”: “nrpe_args”,’ >>
/tmp/services/monitoring
${checkname}vip.json
continue
fi
END=$(echo “${line}” | egrep “}”)
if [ ! -z “${END}” ] && [ -z “${USENRPE}” ] ; then
echo “${line}” | sed 's
,_g’ >>
/tmp/services/monitoring
${checkname}vip.json
continue
else
echo " ${line}" | sed
‘s~service_description~description~g’ >>
/tmp/services/monitoring
${checkname}_vip.json
fi
done

#########################################################################

The contents of ~/newservices.txt looks similar to:

#########################################################################

       "check_bpe_cpu_core": {
                "service_description": "CPU Core Utilization - BPE",
                "contact_groups":["app-team"],
                "command": "nrpe_args",
                "notifications_enabled": 0,
                "max_check_attempts": "5",
                "check_interval": "900",
                "retry_interval": "120",
                "command_options": [ "check_cpu_core_usage",

“‘24,25,26,27,28,29,30,31,32 10 3 90% 95%’” ]
},
“check_mrch_cpu_core”: {
“service_description”: “CPU Core Utilization -
MRCH”,
“contact_groups”:[“app-team”],
“command”: “nrpe_args”,
“notifications_enabled”: 0,
“max_check_attempts”: “5”,
“check_interval”: “900”,
“retry_interval”: “120”,
“command_options”: [ “check_cpu_core_usage”,
“‘24,25,26,27,28,29,30,31,32,34 10 3 90% 95%’”]
},

newservices.txt looks like JSON. What have you tried so far?