rubyocra

Compile ruby script with dependencies on other classes


have a problem with compressing my script.

I have a main.rb and some classes in subfolders like Subfolder/Class.rb In my main.rb, I have the Classes declared like that:

require './Subfolder/Class.rb'

When I just run my main script, it works. Also my exe works, when it is in the same place as the main.rb.
But when I put the exe somewhere else I get this error:

C:/Users/MLEING~1/AppData/Local/Temp/ocr53C2.tmp/lib/ruby/site_ruby/1.9.1/rubyge
ms/custom_require.rb:36:in `require': cannot load such file -- ./Parsing/Calibra
tionState (LoadError) from C:/Users/MLEING~1/AppData/Local/Temp/ocr53C2.tmp/lib/ruby/site_ruby
/1.9.1/rubygems/custom_require.rb:36:in `require'
    from C:/Users/MLEING~1/AppData/Local/Temp/ocr53C2.tmp/src/main.rb:9:in `
<main>'

Can I somehow put the dependencies into my exe?
I also tried to include them like that:

ocra main.rb Subfolder/*.rb

But it doesn't help.


Solution

  • Have you tried making a ruby gem out of your project? http://guides.rubygems.org/make-your-own-gem/

    Gems define their own dependencies.