Is there a simple way to load and use a small subset of fog?

26 views
Skip to first unread message

Myron Marston

unread,
May 29, 2012, 12:38:12 PM5/29/12
to ruby-fog
I'm working on a project that uses S3 in one place. Fog seems to be
the standard way to interface with AWS from ruby these days, so I gave
it whirl. It works great, but I noticed that the tests that load fog
seem sluggish getting started compared to those tests that don't load
fog. (Note that I keep my tests quite isolated; my spec_helper.rb
doesn't load the entire environment, and each test file loads just the
dependencies it needs).

Knowing of the relative slowness of `require` on 1.9, I threw together
a little test script [1] to see how many files are being loaded when I
`require 'fog'`...and it's over 400 files. It makes sense it could
take a half second or so to load fog.

Looking at the source, I can see why...fog interfaces with tons of
cloud providers. Fog is starting to feel like a very heavy dependency
to pull in for just interfacing with S3. Is there a way to load and
use just a small subset of fog? Can I load just the S3 bits of fog
and use those without incurring the cost of loading the rest of fog?

Thanks,
Myron

[1] https://gist.github.com/2829415

geemus (Wesley Beary)

unread,
May 29, 2012, 4:03:51 PM5/29/12
to ruby...@googlegroups.com
Yes. I believe `require 'fog/aws/storage'` should just load the
required files. I think in general that sort of pattern should work
within fog (I did some work to ensure as much a while ago but haven't
recently revisited it). I'd like to break apart and make more
granular various parts, but I think for the time being this should
satisfy your use case.
wes

Myron Marston

unread,
May 29, 2012, 4:22:03 PM5/29/12
to ruby-fog
Thanks, that worked great!

geemus (Wesley Beary)

unread,
May 29, 2012, 4:23:30 PM5/29/12
to ruby...@googlegroups.com
Cool, if there are places that should be better documented (and I'm
fairly sure there are), doc patches would be awesome if you get a
chance.
Thanks!
wes
Reply all
Reply to author
Forward
0 new messages