Export gem in single file

Discussion in 'Ruby' started by Roman Kononov, Mar 9, 2011.

  1. 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?

    --
    Posted via http://www.ruby-forum.com/.
     
    Roman Kononov, Mar 9, 2011
    #1
    1. Advertising

  2. Roman Kononov

    Josh Cheek Guest

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

    On Wed, Mar 9, 2011 at 6:30 AM, Roman Kononov <> wrote:

    > 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?
    >
    > --
    > Posted via http://www.ruby-forum.com/.
    >
    >

    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`)
     
    Josh Cheek, Mar 9, 2011
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGF2aWQgVmFsbGU=?=

    Invalid export DLL or export format

    =?Utf-8?B?RGF2aWQgVmFsbGU=?=, Oct 29, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    3,624
    =?Utf-8?B?RGF2aWQgVmFsbGU=?=
    Oct 29, 2003
  2. Austin 7873
    Replies:
    5
    Views:
    190
    Eric Hodel
    Jan 27, 2007
  3. Maarten Porters
    Replies:
    1
    Views:
    432
    Florian Gilcher
    Jul 28, 2008
  4. Nasir Khan
    Replies:
    0
    Views:
    105
    Nasir Khan
    Jun 8, 2009
  5. Brandon Simmons
    Replies:
    0
    Views:
    350
    Brandon Simmons
    Dec 22, 2010
Loading...

Share This Page