Module: Tapioca::GemHelper

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

Instance Method Summary collapse

Instance Method Details

#gem_in_app_dir?(gemfile_dir, full_gem_path) ⇒ Boolean

Returns:

  • (Boolean)


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

def gem_in_app_dir?(gemfile_dir, full_gem_path)
  !gem_in_bundle_path?(to_realpath(full_gem_path)) &&
    full_gem_path.start_with?(to_realpath(gemfile_dir))
end

#gem_in_bundle_path?(full_gem_path) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/tapioca/helpers/gem_helper.rb', line 15

def gem_in_bundle_path?(full_gem_path)
  full_gem_path.start_with?(Bundler.bundle_path.to_s, Bundler.app_cache.to_s)
end

#to_realpath(path) ⇒ Object



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

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