# Token replacement & rake

**URL:** <https://www.ruby-forum.com/t/token-replacement-rake/118197>\
**Category:** Ruby\
**Created:** [October 24, 2007, 6:34pm UTC](https://www.ruby-forum.com/t/token-replacement-rake/118197 "2007-10-24T18:34:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/838e76/32.png) [@rob](https://www.ruby-forum.com/u/rob)\
**Post date:** [October 24, 2007, 6:34pm UTC](https://www.ruby-forum.com/t/token-replacement-rake/118197/1 "2007-10-24T18:34:01Z")

</div>

Hi,

I need to create some method of automating builds of my rails web app.  
It needs to be built repetitively with minor differences specified in a  
config file. I was planning to use rake for this, but I guess it will  
need some kind of token replacement.

Does anyone know of any way of doing this kind of thing with rake?

Thanks,

Rob.

---

<div class="post-metadata">

**Author:** ![rob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/838e76/32.png) [@rob](https://www.ruby-forum.com/u/rob)\
**Post date:** [October 24, 2007, 8:57pm UTC](https://www.ruby-forum.com/t/token-replacement-rake/118197/2 "2007-10-24T20:57:09Z")

</div>

On Oct 24, 2007, at 10:34 AM, Rob L. wrote:

> Hi,
> 
> I need to create some method of automating builds of my rails web app.  
> It needs to be built repetitively with minor differences specified  
> in a  
> config file. I was planning to use rake for this, but I guess it will  
> need some kind of token replacement.
> 
> Does anyone know of any way of doing this kind of thing with rake?

Use a combination of rake and ERB. Write a rake task that uses ERB  
to modify your config files as needed.

Blessings,  
TwP

---

<div class="post-metadata">

**Author:** ![rob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/838e76/32.png) [@rob](https://www.ruby-forum.com/u/rob)\
**Post date:** [October 25, 2007, 2:35pm UTC](https://www.ruby-forum.com/t/token-replacement-rake/118197/3 "2007-10-25T14:35:02Z")

</div>

On Oct 24, 2007, at 12:34 , Rob L. wrote:

> I need to create some method of automating builds of my rails web app.  
> It needs to be built repetitively with minor differences specified  
> in a  
> config file. I was planning to use rake for this, but I guess it will  
> need some kind of token replacement.

I’m assuming you mean that your rake rules should change based on the  
config file? Is it the dependencies or rule names or rule actions  
that should change? Either way, it should be easy:

config = eval File.read(“config/build.conf.rb”)

task “compile-#{config[“stage”]}” =\> “do-#{config[“stage”]}” do  
case config[“flag”]  
when # …  
# …  
end  
end
