Module: Tapioca::GemHelper

Extended by:
T::Sig
Included in:
Tapioca::Gemfile::GemSpec, Loaders::Loader
Defined in:
lib/tapioca/helpers/gem_helper.rb

Instance Method Summary collapse

Instance Method Details

#gem_in_app_dir?(app_dir, full_gem_path) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
# File 'lib/tapioca/helpers/gem_helper.rb', line 9

def gem_in_app_dir?(app_dir, full_gem_path)
  app_dir = to_realpath(app_dir)
  full_gem_path = to_realpath(full_gem_path)

  !gem_in_bundle_path?(full_gem_path) && !gem_in_ruby_path?(full_gem_path) && path_in_dir?(full_gem_path, app_dir)
end

#gem_in_bundle_path?(full_gem_path) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/tapioca/helpers/gem_helper.rb', line 17

def gem_in_bundle_path?(full_gem_path)
  path_in_dir?(full_gem_path, Bundler.bundle_path) || path_in_dir?(full_gem_path, Bundler.app_cache)
end

#gem_in_ruby_path?(full_gem_path) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/tapioca/helpers/gem_helper.rb', line 22

def gem_in_ruby_path?(full_gem_path)
  path_in_dir?(full_gem_path, RbConfig::CONFIG["rubylibprefix"])
end

#to_realpath(path) ⇒ Object



27
28
29
30
31
# File 'lib/tapioca/helpers/gem_helper.rb', line 27

def to_realpath(path)
  path_string = path.to_s
  path_string = File.realpath(path_string) if File.exist?(path_string)
  path_string
end