Shoes/lib/shoes/cobbler.rb
def rewrite_with_env before, after, reg = /\#\{(\w+)\}/, reg2 = '\1'
     File.open(after, 'w') do |a|
       File.open(before) do |b|
         b.each do |line|
           a << line.gsub(reg) do
             if reg2.include? '\1'
               reg2.gsub(%r!\\1!, ENV[$1])
             else
               reg2
             end
           end
         end
       end
     end
   end
# not that pretty at all.
not that pretty at all.
not that pretty at all .
def rewrite_with_env before, after, reg = /\#\{(\w+)\}/, reg2 = '\1'
     File.open(after, 'w') do |a|
       File.open(before) do |b|
         b.each do |line|
           a << line.gsub(reg) do
             if reg2.include? '\1'
               reg2.gsub(%r!\\1!, ENV[$1])
             else
               reg2
             end
           end
         end
       end
     end
   end
def rewrite_with_env before , after , reg = / \# \{ ( \w +) \} / , reg2 = '\1' File . open ( after , 'w' ) do | a | File . open ( before ) do | b | b . each do | line | a << line . gsub ( reg ) do if reg2 . include? '\1' reg2 . gsub ( %r! \\ 1 ! , ENV [ $1 ] ) else reg2 end end end end end end
not that pretty at all.
not that pretty at all .
before
after
reg
reg2