Export gem in single file

R

Roman Kononov

I have following task - create single file from gem for executing it on
dedicated server. I have implemented recursive walk of files tree. Main
problem that order of file list i extracted from gem is wrong, i.e

require "/simple_record/attributes"
require "/simple_record/active_sdb"
require "/simple_record/callbacks"

but when i'm trying to merge these files into one in this precedence on
file load i'm receiving NameError due to wrong files order.Any ideas how
i could get proper list of gem files or make dependency graph, or export
gem in single huge file?
 
J

Josh Cheek

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

I have following task - create single file from gem for executing it on
dedicated server. I have implemented recursive walk of files tree. Main
problem that order of file list i extracted from gem is wrong, i.e

require "/simple_record/attributes"
require "/simple_record/active_sdb"
require "/simple_record/callbacks"

but when i'm trying to merge these files into one in this precedence on
file load i'm receiving NameError due to wrong files order.Any ideas how
i could get proper list of gem files or make dependency graph, or export
gem in single huge file?
Did you mean to have a leading slash on your require statement? That implies
you installed it in your root dir (which is probably not a good place for
it), I'd personally let Rubygems handle installation and location of gems,
in fact I did, and when I ran your code (on 1.9.1) I didn't get any errors.

But, to answer your question, looking at the gem, you can just require the
lib and it will require all those files for you:
https://github.com/appoxy/simple_record/blob/master/lib/simple_record.rb#L37-48

So you could just replace your three lines with: require("simple_record")
which also worked for me.

This is a fairly common convention, you can check out the gem's source code
with `$ gem open simple_record` (you'll first need to `$ gem install
gem-open`)
 

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

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top