Class: FunWith::Gems::RootSetter

Inherits:
Object
  • Object
show all
Defined in:
lib/fun_with/gems/root_setter.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.set_root(*args, &block) ⇒ Object



4
5
6
# File 'lib/fun_with/gems/root_setter.rb', line 4

def self.set_root( *args, &block )
  self.new.set_root( *args, &block )
end

Instance Method Details

#set_root(gem_const, caller_file, opts = {}) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/fun_with/gems/root_setter.rb', line 8

def set_root( gem_const, caller_file, opts = {} )
  # Hence, the "make_gem_fun()" directive should be called in the lib/gem_name.rb file.
  main_lib_file = opts[:main_lib_file] || caller_file
  root = opts.fetch(:root){ main_lib_file.fwf_filepath.expand.dirname.up }
  
  Files::RootPath.rootify( gem_const, root )
end