argent-codegen - a Ruby Code Generation Tool argent is basically a copy of cog.py, go see the cog page: http://www.nedbatchelder.com/code/cog/ Much thanks to Ned Batchelder for the idea! Thanks to whoever made rake for their install.rb file! ;-> ======================================================================== INSTALLATION: The automatic install is just (from a root prompt): # ruby install.rb If that doesn't work, you can still do it by hand: 1) move bin/argent into some directory in your $PATH 2) move the directory ./lib/argent/ intosome directory in your $RUBYLIB I use vim, and thus I put the below in my $HOME/.vimrc (under Linux): nmap :%!argent -t:/\$\]\] Something similar is possible for Emacs and under Win32, I'm sure. argent is known to run on my computers (Debian Linux and Cygwin/XP) It may run on yours too... or may not. If it doesn't and you can figure out why, drop me a line. ======================================================================== USAGE NOTES: Very much functions like Cog, go read the cog page. ok, you're back? for help: $ ./argent -h DIFFERENCES FROM COG: The first example from that page for argent would be: ------------------------------------------------------------ // This is my C++ file. ... /*[[$argent fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing'] fnames.each do |fn| $argent.outl("void #{fn}();") end $]]*/ //[[$end$]] ... ------------------------------------------------------------ the -s and -t options are new: Functions available: $argent.out() - prints out $argent.outl() - as above, but appends newline Variables available: $out - where the output goes, may be a StringBuffer (see Common.rb) $err - " error " $filename - current filename Also, the below are used by argent for debugging: $debug - not really useful $lineNo - current line number (inaccurate, and thus not very useful) ======================================================================== TESTING After you've installed argent, you can run: $ make to run some tests... if they fail in interesting ways, let me know. NOTE: if you don't have rubygems installed to the same directory as me, then test11-s.out will certainly fail! Mine's in: /usr/local/lib/site_ruby/1.8/rubygems/ tests/commands.rb together with do-tests.rb and the Makefile are (slightly contrived) examples of using argent to generate some repetitive code. If you need an example, you could do worse than looking at them (start with running the targets tidy: and ready: in the makefile if you have argent working) ======================================================================== See LICENCE file for Terms I consider this a fun toy, not a heavy-duty tool. Do NOT use this for anything without backups! I doubt it will, but if it causes you to lose all your data, you have my sympathy, but as the LICENCE says: "THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND" That said, it is somewhat useful and fairly reliable... enjoy! Cullen J. O'Neill -- cjon256@gmail.com