You can also try creating erb templates of the files you want to change. Then bind the values and generate the files dinamically. It's really simple.
http://www.ensta.fr/~diam/ruby/online/ruby-doc-stdlib/libdoc/erb/rdoc/classes/ERB.html And very rubyish :P On 15 September 2010 23:35, Antoine Toulme <[email protected]> wrote: > Hi Travis, you can reuse some buildrdeb code that does that: > > > http://github.com/intalio/package_as_deb/blob/master/lib/buildrdeb/package.rb#L33 > > < > http://github.com/intalio/package_as_deb/blob/master/lib/buildrdeb/package.rb#L33 > >You > read the file, eval(its contents), then write it in the target folder in > place. > > The code is not really good looking there but it's really simple. I > recommend you try in irb first. > > On Wed, Sep 15, 2010 at 14:28, Travis Jensen <[email protected] > >wrote: > > > I have a client/server system where both the client and the server need > to > > know the server's hostname (think of this requirement like Apache's > virtual > > hosts where one process is able to serve as multiple hosts), but that can > > change depending on whether it is a dev, QA, or production build. I need > > to > > replace a variable for the hostname in a couple of XML files, a > properties > > file, and a JSON/JavaScript file. The number is small enough that I > would > > want to specify the files to modify rather than do a global > search/replace > > (keeps the variables from proliferating, too :) > > > > One solution I thought of is to have a configuration file that specifies > > the > > hostname the system is being built for (the confi file would exist > outside > > our repository). When a build is performed, the files would have the > > variable substitution performed to give *this* build a particular > hostname. > > > > > > The problem with this is that it doesn't work well in IDE projects that > > don't know about the substitution. > > > > I'm open to other ideas and, more importantly, any points for > accomplishing > > this that a new user of buildr might not know about (I can always write > the > > ruby code to do it if it comes to that). > > > > Thanks. > > > > tj > > > > *Travis Jensen* > > *** > > *Read the Software Maven @ http://softwaremaven.innerbrane.com/ > > Read my LinkedIn profile @ http://www.linkedin.com/in/travisjensen > > Read my Twitter mumblings @ http://twitter.com/SoftwareMaven > > Send me email @ [email protected] > > > > **What kind of guy calls himself the Software Maven???** > > > -- Rafa de Castro [email protected]
