SciRuby / daru-io

daru-io is a plugin gem to the existing daru gem, which aims to add support to Importing DataFrames from / Exporting DataFrames to multiple formats.
http://www.rubydoc.info/github/athityakumar/daru-io/master/
MIT License
25 stars 9 forks source link

Optional dependencies workflow #25

Closed athityakumar closed 7 years ago

athityakumar commented 7 years ago

Daru-io has lots of format-specific dependencies that are used in just one importer / exporter. Having them all as optional dependencies is one way to go about it.

#! lib/daru/io/importers/html.rb
begin
    gem gem_name, gem_version
    require gem_name
rescue LoadError
    raise "Please install #{gem_name} gem v#{gem_version} with `gem install #{gem_name}`."
end

Optional dependencies aren't supported by Rubygem's gemspec file - so they will NOT feature in the gemspec file. So, what if any user wants to install ALL of the optional gems of daru-io at one go? In bundler's Gemfile, can all optional gems be included them under a group (say, optional)? That way, the normal user installs with bundle install --without optional and someone who wants all optional gems runs just bundle install.

Please share your thoughts on whether there is a better way to go about optional dependencies. 😃

Ping @zverok @v0dro @lokeshh

zverok commented 7 years ago

From my perspective:

  1. All libraries that are required only at a moment of usage (not requiring corresponding file).
  2. Not included as a runtime deps of gem
  3. Described with a nice DSL, like this:
    
    module Daru
    module Importers
    class CSV < Base
       required_gem 'smartcsv', '~> 2.5'
       optional_gem 'fastcsv', '~> 3'
v0dro commented 7 years ago

I like the idea of being able to install dependencies in one go. You can have groups for individual wrappers and another one where all of them are installed together.

However, users will be using gem install to install the library so the options that a user passes must work with that.