Module: FunWith::Gems::GemAPI

Included in:
FunWith::Gems
Defined in:
lib/fun_with/gems/gem_api.rb

Instance Method Summary collapse

Instance Method Details

#make_gem_fun(gem_const, opts = {}) ⇒ Object

Very opinionated. Expects the function to be called in the gem’s lib/gem_name.rb file. Also expects a VERSION file at the root of the gem, which has “0.0.3” (or whatever), and nothing else. Finally, it expects that ‘requiring’ the classes the gem needs is a simple matter of requiring every item in the lib/fun_with directory, so keep those classes clean. The string given should represent the module that refers to the gem as a whole.

Configurable options: While all these things are handled by default, some things can be overridden :main_lib_file => use a different filepath to calculate the root

:root => or render :main_lib_file moot by declaring a different root.

:version => Declare a different version string for the gem.

:require => false (avoids requiring the default lib/fun_with dir.) :require => filepath or array of filepaths (require these things instead (note: not in addition to))



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fun_with/gems/gem_api.rb', line 20

def make_gem_fun( gem_const, opts = {} )
  @caller_file = caller.first.gsub(/:\d+:.*/,'').fwf_filepath
  @opts = opts
  set_gem_const( gem_const )
  @gem_const.extend( FunGemAPI )
  set_gem_root
  set_gem_version
  require_libs
  extend_constant_with_gem_api
  @gem_const.gem_verbose = opts[:verbose]
  @gem_const.load_external_tasks  # Nothing happens unless 'rake' gem is active
end