Last active
July 25, 2017 23:08
-
-
Save elcontrastador/f0fb129de07477d80c3d618abc29404b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rows = CSV.read(CCM_DUMP) | |
rows.each do |row| | |
next unless row[0] =~ /^SEP/ | |
@p = Cisco::CCM::DB::ParseRow.new(row).get_phone | |
@p.lines.each do |l| | |
next unless @l = l | |
line_erb = File.read(ERB_LINE) | |
eruby = Erubis::Eruby.new | |
erb = eruby.convert(line_erb) | |
puts eval erb | |
end | |
end | |
### ORIG ERB ### | |
[<%= @l.dn %>](<%= @p.line_templ %>) | |
type = line | |
label = <%= @l.label %> | |
description = <%= @l.descr or @l.dn %> | |
mailbox = <%= @l.dn %> | |
cid_name = <%= @l.descr or @l.dn %> | |
cid_num = <%= @l.dn %> | |
incominglimit = <%= @p.incoming_limit %> | |
<%= "callgroup = #{@l.call_group}" if @l.call_group %> | |
<%= "pickupgroup = #{@l.pickup_group}" if @l.pickup_group %> | |
<%= "setvar = extphonemask=#{@l.external_num}" if @l.external_num %> | |
### WORKING ERB ### (added newlines to last 3 items, the closed with strip -%> | |
[<%= @l.dn %>](<%= @p.line_templ %>) | |
type = line | |
label = <%= @l.label %> | |
description = <%= @l.descr or @l.dn %> | |
mailbox = <%= @l.dn %> | |
cid_name = <%= @l.descr or @l.dn %> | |
cid_num = <%= @l.dn %> | |
incominglimit = <%= @p.incoming_limit %> | |
<%= "callgroup = #{@l.call_group}\n" if @l.call_group -%> | |
<%= "pickupgroup = #{@l.pickup_group}\n" if @l.pickup_group -%> | |
<%= "setvar = extphonemask=#{@l.external_num}\n" if @l.external_num -%> | |
### OUTPUT ### | |
# output with maddening blank lines for nil values. Want nil lines to be ignored, so no newlines. | |
# I have tried to suppress with both ERB and Erubis. I read Erubis is supposed to support my desired | |
# behavior by default. Not working. I've tried using ERB instantiating with ERB.new(var, nil, '-') and | |
# using <%- ruby_stuff -%> and it's not working as expected either. | |
[2004](sphs_admin_line) | |
type = line | |
label = Nurse (2004) | |
description = 2004 | |
mailbox = 2004 | |
cid_name = 2004 | |
cid_num = 2004 | |
incominglimit = 4 | |
callgroup = 1 | |
pickupgroup = 1 | |
[#11](sphs_admin_line) | |
type = line | |
label = #11 | |
description = #11 | |
mailbox = #11 | |
cid_name = #11 | |
cid_num = #11 | |
incominglimit = 4 | |
callgroup = 1 | |
pickupgroup = 1 | |
[2005](sphs_admin_line) | |
type = line | |
label = Mechanical Room (2005) | |
description = SP Mechanical Room | |
mailbox = 2005 | |
cid_name = SP Mechanical Room | |
cid_num = 2005 | |
incominglimit = 2 | |
setvar = extphonemask=5835912 | |
[2006](sphs_admin_line) | |
.... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment