ruby compactor/consolidator?

K

Kyle Schmitt

Is there a built-in or common way to consolidate a ruby project into one file?

I've got a project of 8-10 files (one class per file & a script that
use the classes). For ease of distributing it to my servers, I've got
a secondary script that consolidates all of them to one big ugly
script.

While the script to consolidate the project does does work well enough
for now, I can easily see it may not in the future.

Thanks
--Kyle
 
J

James Coglan

[Note: parts of this message were removed to make it a legal post.]

2009/4/8 Kyle Schmitt said:
Is there a built-in or common way to consolidate a ruby project into one
file?


cat `find . -name '*.rb'` > all.rb
 
J

James Coglan

[Note: parts of this message were removed to make it a legal post.]

2009/4/8 Kyle Schmitt said:
Did you get that from the new O'Reilly book, "Mastering cat"? ;)
http://www.shlomifish.org/humour/bits/Mastering-Cat/


Hey, it's worth knowing your cat... although I really wish someone actually
would publish that book, I'd love to see how much mileage they could eke out
of it.

I slightly more robust thing to do would be to list all the files in a
config file e.g. Manifest.txt, since order can be important, then write a
build take in your Rakefile:

task :build do
files = File.read('Manifest.txt').strip.split(/\s+/)
code = files.map(&File.method:)read)) * "\n\n"
File.open('build.rb', 'wb') { |f| f.write(code) }
end
 

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

Forum statistics

Threads
473,744
Messages
2,569,481
Members
44,900
Latest member
Nell636132

Latest Threads

Top