Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Not imposing your dependencies in Ruby

Thread Tools

Not imposing your dependencies in Ruby

Posts: n/a

I was wondering about not imposing some dependencies when I release a
Ruby library. Say I have a class used to detect the (natural) language
of a text. To run, objects of this class need some data files, the
location of which must be known. It is fine to have this location as a
class-wide settings (all objects will use the same data files), so I
make the setting as a class instance variable :

class LanguageDetect
@path_to_ngrams = "data/ngrams"

attr_accessor ath_to_ngrams
# [......]

Now, I'd rather use my own Config library ; which allows me to set the
default value, the command line switch to look for, get the value
directly from config files, etc. I'd have something like this :

class LanguageDetect
extend Configurable
config_option ath_to_ngrams {
default "data/ngrams"
switch "--path-to-ngrams"

# [....]

This is much more practical for me to use in my own applications.
However, if I release the LanguageDetect class on it's own, I don't
want to impose the dependency on my Config library to everyone else (as
people might want to integrate it in their own application which works

What is the best way to achieve this ? I could think of several
solutions :

1. Just change the code when releasing the library on it's own
2. Keep the 'config_option' call in a separate file, that depends on
the application rather than the library
3. include some light version of the Config library with the
LanguageDetect library which would create the class instance variable
but not try to link to command line switch and config files.

But none of those are quite satisfying. Any ideas ? Or am I just
looking at this from the wrong angle ?


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Europe-Not Imposing Net Neutrality StevieO Computer Support 1 11-13-2010 03:20 PM
Time Warner Telecom Calls on FCC to Support Competitive Telecom Market by Imposing Conditions to AT&T-BellSouth Merger Knowing About VOIP 0 10-13-2006 07:44 AM
Time Date Imposing Software komobu Digital Photography 6 10-02-2006 12:18 AM
Imposing my style sheet on an IFRAME content. Mel HTML 1 11-30-2005 09:23 AM
Imposing a timeout on the <> operator - is this possible? Bob Dubery Perl 1 03-05-2004 08:03 PM