The Ruby/ERB way to do this?

P

Peter Booth

Hello, I was wondering if someone could point me to a smarter way of doing
the following? It's probably a Ruby basics question.

I am using ERB to generate sets of configuration files for different
environments. I imagined that I would use a different config file per
environment, that sets variables, and apply this against a list of
configuration file templates.

Currently each environment file defines a module "X" that has constants for
each variable:
module X
MgrPort = '3000'
MsgPort2s = '4000'

The template files reference the variables like so
domain = <%= X::Domain %>

The script that calls erb.result() uses require/include to reference the
config file

require "Configs/stagingProperties"
include X


There must be a better way to do this. Is there a "Right Way" here? I've
perused the erb docs and the Pickaxe book but neither explicitly join the
dots.
----------------------------------------------------------------------------
----------------------------------------

The information contained in and accompanying this communication is strictly
confidential and intended solely for the use of the intended recipient(s).
If you have received it by mistake please let us know by reply and then
delete it from your system; you should not copy the message or disclose its
content to anyone.
MarketAxess reserves the right to monitor the content of emails sent to or
from its systems.
Any comments or statements made are not necessarily those of MarketAxess.
For more information, please visit www.marketaxess.com. MarketAxess Europe
Limited is regulated in the UK by the FSA, registered in England no.
4017610, registered office at 71 Fenchurch Street, London, EC3M 4BS.
Telephone (020) 7709 3100.
MarketAxess Corporation is regulated in the USA by the SEC and the NASD,
incorporated in Delaware, executive offices at 140 Broadway, New York, NY
10005. Telephone (1) 212 813 6000.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top