Sha256: c77ed266e88f6b96ee3b28268f3afef56edade9dd83479de0093cc362a8af85d

Contents?: true

Size: 789 Bytes

Versions: 9

Compression:

Stored size: 789 Bytes

Contents

# typed: true
# frozen_string_literal: true

module Tapioca
  module GemHelper
    extend T::Sig

    sig { params(gemfile_dir: String, full_gem_path: String).returns(T::Boolean) }
    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

    sig { params(full_gem_path: String).returns(T::Boolean) }
    def gem_in_bundle_path?(full_gem_path)
      full_gem_path.start_with?(Bundler.bundle_path.to_s, Bundler.app_cache.to_s)
    end

    sig { params(path: T.any(String, Pathname)).returns(String) }
    def to_realpath(path)
      path_string = path.to_s
      path_string = File.realpath(path_string) if File.exist?(path_string)
      path_string
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
tapioca-0.10.1 lib/tapioca/helpers/gem_helper.rb
tapioca-0.10.0 lib/tapioca/helpers/gem_helper.rb
tapioca-0.9.4 lib/tapioca/helpers/gem_helper.rb
tapioca-0.9.3 lib/tapioca/helpers/gem_helper.rb
tapioca-0.9.2 lib/tapioca/helpers/gem_helper.rb
tapioca-0.9.1 lib/tapioca/helpers/gem_helper.rb
tapioca-0.9.0 lib/tapioca/helpers/gem_helper.rb
tapioca-0.8.3 lib/tapioca/helpers/gem_helper.rb
tapioca-0.8.2 lib/tapioca/helpers/gem_helper.rb