title: Getting strings for Ruby templates?
body: <p>In the below script the <code>puts</code> outputs</p>
  
  <pre><code>admin1:secretpw@example.com
  </code></pre>
  
  <p>where I need to have it split in a username and a password, so I can use it for a template</p>
  
  <pre><code>[admins]
  &lt;%= couchdbAdminUri.user %&gt; = &lt;%= couchdbAdminUri.password %&gt;
  </code></pre>
  
  <p><strong>Question</strong></p>
  
  <p>How can I turn <code>couchdbAdminUri</code> into an object so I can use the template above?</p>
  
  <pre><code>#!/usr/bin/ruby
  
  require 'erb'
  require 'yaml'
  require 'uri'
  require 'awesome_print'
  
  data_root = '/vol'
  config_root = File.join(data_root, 'config')
  
  couchdb = YAML::load_file(File.join(config_root, 'couchdb.yaml'))
  couchdbAdminUri = URI(couchdb['_admin']['db'])
  
  puts couchdbAdminUri
  
  b = binding
  tmp = ERB.new File.read("local.ini.erb"), nil, "%"
  File.open("local.ini", "w") do |f|
    f.write(tmp.result(b))
  end
  </code></pre>