module Opal::UseGem

def require_paths_for_gem(gem_name, include_dependencies)

def require_paths_for_gem(gem_name, include_dependencies)
  paths = []
  spec = Gem::Specification.find_by_name(gem_name)
  raise GemNotFound, gem_name unless spec
  if include_dependencies
    spec.runtime_dependencies.each do |dependency|
      paths += require_paths_for_gem(dependency.name, include_dependencies)
    end
  end
  gem_dir = spec.gem_dir
  spec.require_paths.map do |path|
    paths << File.join(gem_dir, path)
  end
  paths
end