Forum: Ruby ruby compactor/consolidator?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
9dec3df8319c613f6f4f14a27da0fdb4?d=identicon&s=25 Kyle Schmitt (Guest)
on 2009-04-08 17:26
(Received via mailing list)
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
53581739a445ad78250a676dabddf55f?d=identicon&s=25 James Coglan (Guest)
on 2009-04-08 17:29
(Received via mailing list)
2009/4/8 Kyle Schmitt <kyleaschmitt@gmail.com>

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


cat `find . -name '*.rb'` > all.rb
53581739a445ad78250a676dabddf55f?d=identicon&s=25 James Coglan (Guest)
on 2009-04-08 17:31
(Received via mailing list)
2009/4/8 James Coglan <jcoglan@googlemail.com>

> 2009/4/8 Kyle Schmitt <kyleaschmitt@gmail.com>
>
> > Is there a built-in or common way to consolidate a ruby project into one
> > file?
>
>
> cat `find . -name '*.rb'` > all.rb
>

My apologies, that was kind of a silly answer. Best idea is to package
it as
a gem. I use hoe for this, for which there is an excellent tutorial:

http://nubyonrails.com/articles/tutorial-publishin...
9dec3df8319c613f6f4f14a27da0fdb4?d=identicon&s=25 Kyle Schmitt (Guest)
on 2009-04-08 17:39
(Received via mailing list)
On Wed, Apr 8, 2009 at 10:28 AM, James Coglan <jcoglan@googlemail.com>
wrote:
>
>
> cat `find . -name '*.rb'` > all.rb
>

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

For some reason I never even _thought_ of doing it as a gem.  Although
I'm not sure gem works by default on CentOS... I'll have to see.

Thanks
--Kyle
53581739a445ad78250a676dabddf55f?d=identicon&s=25 James Coglan (Guest)
on 2009-04-08 17:54
(Received via mailing list)
2009/4/8 Kyle Schmitt <kyleaschmitt@gmail.com>

> On Wed, Apr 8, 2009 at 10:28 AM, James Coglan <jcoglan@googlemail.com>
> wrote:
> >
> >
> > cat `find . -name '*.rb'` > all.rb
> >
>
> 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
47b1910084592eb77a032bc7d8d1a84e?d=identicon&s=25 Joel VanderWerf (Guest)
on 2009-04-08 19:21
(Received via mailing list)
Kyle Schmitt wrote:
> Is there a built-in or common way to consolidate a ruby project into one file?

Might be helpful:

http://raa.ruby-lang.org/project/darb

(Doesn't package binary extensions, though, only ruby source.)
This topic is locked and can not be replied to.