Library to find Ruby modules/packages/dependencies?

I’m looking for a Ruby library to recursively scan a Ruby project and
assemble an object graph/array/list of the imported modules. The library
should have functionality similar to these libraries in other languages:

https://docs.python.org/2/library/modulefinder.html

Bundler (http://bundler.io) doesn’t quite look like what I’m looking
for, as it seems to focus on binary gems and is more of a
versioning/build tool (to avoid DLL hell) than a deployment tool.

My objective here is to deploy a standalone Ruby-Tk app on the Mac
without having to roll up an entire Ruby installation: that can get
rather large. I’ve worked out the part of actually creating an app
package (building a stub launcher in C that runs Ruby as an embedded
interpreter), but stripping out unneeded bits is an important part that
I haven’t solved.

If I’m wrong about bunder, please correct me. And if anyone knows of a
library that can put together a complete list of Ruby modules/packages
for a project, please let me know.

Thanks,
Kevin

Hi Kevin,

I don’t think I’m understanding quite what you’re looking for, but using
Bundler with the “config.path” option set to a local (to your project)
path
will give you way to vendor all necessary dependencies.

http://bundler.io/v1.7/bundle_config.html

Is that helpful?

Thanks,

Ryan

If you just want to create a package containing all the dependencies you
can vendor your gems by running:

bundle install --path vendor/bundle

Docs: http://bundler.io/v1.1/bundle_install.html

You can also see a list of every single dependency by looking at your
projects Gemfile.lock

E.g: https://github.com/libgit2/rugged/blob/master/Gemfile.lock

On Thu, Nov 13, 2014 at 2:45 PM, Kevin W. [email protected]
wrote:

as it seems to focus on binary gems and is more of a versioning/build tool
a project, please let me know.

Thanks,
Kevin


Kevin W.
Code by Kevin/Mobile Code by Kevin
http://www.codebykevin.com
http://www.wtmobilesoftware.com


George D.
Software Engineer

+44 (0)333 240 2222

[image: Rentify]
6-8 Long Lane, London EC1A 9HF
www.rentify.com

Kevin W. wrote in post #1162362:

I’m looking for a Ruby library to recursively scan a Ruby project and
assemble an object graph/array/list of the imported modules.

I append in the start up of application this code :

Gem.loaded_specs.each {|name,gem| puts " #{gem.name}-#{gem.version}"}

this give me on stdout the list of gem that has been loaded by the
application. exemple after a simple 'require ‘gtk’ ;
glib2-2.2.0
gobject-introspection-2.2.0
gio2-2.2.0
atk-2.2.0
pango-2.2.0
gdk_pixbuf2-2.2.0
gdk3-2.2.0
gtk3-2.2.0
pkg-config-1.1.5
cairo-1.12.9

it must be executed when all ‘require’ are done.If you don’t know
when the requires are done, you can put this code on a at_exit bloc,
and execut a maximum of actions with your tk application.

On 11/13/14, 11:52 AM, Ryan Cook wrote:

don’t think I’m understanding quite what you’re looking for, but using
Bundler with the “config.path” option set to a local (to your project)
path will give you way to vendor all necessary dependencies.

http://bundler.io/v1.7/bundle_config.html

Is that helpful?

As I understand bundler, it allows you to create recipes to manage a
chain of dependencies in gems/libraries so that others building your
project can pull the right gems, from the right places, with the correct
versions, and their correct dependencies, and thus build your app or
project correctly. Very cool, but not quite what I’m looking for.

What I’m looking for is a module or library that will scan the code in
my project, assemble a list of libraries and dependencies, and then pass
those lists for another library to copy those libraries/packages/gems
into a standalone application for deployment on other systems.

This is what the Perl “scandeps” module and the Python “modulefinder”
that I referenced earlier do–these libraries and similar packages are
key components to standalone app builders like Perl’s Par::Packer module
or Python’s py2exe/py2app. These modules are part of the core libraries
of these languages. By contrast, it doesn’t seem that Ruby has such a
module in its core library.

Perhaps bundler can be massaged to provide something like the
functionality I seek.

–Kevin

Ah. So you want to remove all extraneous libraries, even if they are a
part
of the stdlib, in order to only ship the bare minimum with the packaged
app?

I don’t know of a standard library package in Ruby that does this. I
also
don’t know of way to remove packages from the stdlib that are unused,
but
have never tried to that before…

The entire standard library for Rubinius ships as gems. Maybe that’s
helpful? Also, what about using mruby?

Ryan

I’d like to ad to this that OS X comes with ruby std