class Tapioca::Gemfile::GemSpec
Constants
- IGNORED_GEMS
Attributes
full_gem_path[R]
version[R]
Public Class Methods
new(spec)
click to toggle source
# File lib/tapioca/gemfile.rb, line 104 def initialize(spec) @spec = T.let(spec, Tapioca::Gemfile::Spec) real_gem_path = to_realpath(@spec.full_gem_path) @full_gem_path = T.let(real_gem_path, String) @version = T.let(version_string, String) end
Public Instance Methods
contains_path?(path)
click to toggle source
# File lib/tapioca/gemfile.rb, line 140 def contains_path?(path) if default_gem? files.any? { |file| file.to_s == to_realpath(path) } else to_realpath(path).start_with?(full_gem_path) || has_parent_gemspec?(path) end end
files()
click to toggle source
# File lib/tapioca/gemfile.rb, line 117 def files if default_gem? @spec.files.map do |file| ruby_lib_dir.join(file) end else @spec.full_require_paths.flat_map do |path| Pathname.glob((Pathname.new(path) / "**/*.rb").to_s) end end end
ignore?(gemfile_dir)
click to toggle source
# File lib/tapioca/gemfile.rb, line 112 def ignore?(gemfile_dir) gem_ignored? || gem_in_app_dir?(gemfile_dir) end
name()
click to toggle source
# File lib/tapioca/gemfile.rb, line 130 def name @spec.name end
rbi_file_name()
click to toggle source
# File lib/tapioca/gemfile.rb, line 135 def rbi_file_name "#{name}@#{version}.rbi" end
Private Instance Methods
default_gem?()
click to toggle source
# File lib/tapioca/gemfile.rb, line 151 def default_gem? @spec.respond_to?(:default_gem?) && @spec.default_gem? end
gem_ignored?()
click to toggle source
# File lib/tapioca/gemfile.rb, line 195 def gem_ignored? IGNORED_GEMS.include?(name) end
gem_in_app_dir?(gemfile_dir)
click to toggle source
# File lib/tapioca/gemfile.rb, line 200 def gem_in_app_dir?(gemfile_dir) !gem_in_bundle_path? && full_gem_path.start_with?(gemfile_dir) end
gem_in_bundle_path?()
click to toggle source
# File lib/tapioca/gemfile.rb, line 205 def gem_in_bundle_path? full_gem_path.start_with?(Bundler.bundle_path.to_s, Bundler.app_cache.to_s) end
has_parent_gemspec?(path)
click to toggle source
# File lib/tapioca/gemfile.rb, line 168 def has_parent_gemspec?(path) # For some Git installed gems the location of the loaded file can # be different from the gem path as indicated by the spec file # # To compensate for these cases, we walk up the directory hierarchy # from the given file and try to match a <gem-name.gemspec> file in # one of those folders to see if the path really belongs in the given gem # or not. return false unless Bundler::Source::Git === @spec.source parent = Pathname.new(path) until parent.root? parent = parent.parent.expand_path return true if parent.join("#{name}.gemspec").file? end false end
ruby_lib_dir()
click to toggle source
# File lib/tapioca/gemfile.rb, line 156 def ruby_lib_dir Pathname.new(RbConfig::CONFIG["rubylibdir"]) end
to_realpath(path)
click to toggle source
# File lib/tapioca/gemfile.rb, line 188 def to_realpath(path) path_string = path.to_s path_string = File.realpath(path_string) if File.exist?(path_string) path_string end
version_string()
click to toggle source
# File lib/tapioca/gemfile.rb, line 161 def version_string version = @spec.version.to_s version += "-#{@spec.source.revision}" if Bundler::Source::Git === @spec.source version end