Module: ReverseRequire

Defined in:
lib/reverse_require/gems.rb,
lib/reverse_require/version.rb,
lib/reverse_require/reverse_require.rb

Defined Under Namespace

Classes: Gems

Constant Summary collapse

VERSION =
'0.1.0'

Class Method Summary collapse

Class Method Details

.gems_of(name) ⇒ Object

Returns a new Gems object containing the gems which depend upon the RubyGem of the specified name.



8
9
10
# File 'lib/reverse_require/reverse_require.rb', line 8

def ReverseRequire.gems_of(name)
  Gems.depending_on(name)
end

.require_for(gems, sub_path) ⇒ Object

Requires certain files from the gems that contain the specified sub_path. If no gems contain the specified sub_path, false will be returned.



17
18
19
20
21
22
23
24
25
26
# File 'lib/reverse_require/reverse_require.rb', line 17

def ReverseRequire.require_for(gems,sub_path)
  lib_path = File.join('lib',sub_path)

  was_loaded = gems.with_path(lib_path).map do |path,gem_spec|
    gem(gem_spec.name,gem_spec.version)
    require File.expand_path(File.join(path,lib_path))
  end

  return was_loaded.include?(true)
end