Class: Tapioca::Gemfile::Gem

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/tapioca/gemfile.rb

Constant Summary collapse

IGNORED_GEMS =
T.let(%w{
  sorbet sorbet-static sorbet-runtime tapioca
}.freeze, T::Array[String])

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spec) ⇒ Gem

Returns a new instance of Gem.



89
90
91
92
# File 'lib/tapioca/gemfile.rb', line 89

def initialize(spec)
  @spec = T.let(spec, Tapioca::Gemfile::Spec)
  @full_gem_path = T.let(@spec.full_gem_path.to_s, String)
end

Instance Attribute Details

#full_gem_path ⇒ Object (readonly)

Returns the value of attribute full_gem_path.



86
87
88
# File 'lib/tapioca/gemfile.rb', line 86

def full_gem_path
  @full_gem_path
end

Instance Method Details

#files ⇒ Object



100
101
102
103
104
# File 'lib/tapioca/gemfile.rb', line 100

def files
  @spec.full_require_paths.flat_map do |path|
    Pathname.glob((Pathname.new(path) / "**/*.rb").to_s)
  end
end

#ignore?(gemfile_dir) ⇒ Boolean

Returns:

  • (Boolean)


95
96
97
# File 'lib/tapioca/gemfile.rb', line 95

def ignore?(gemfile_dir)
  gem_ignored? || gem_in_app_dir?(gemfile_dir)
end

#name ⇒ Object



107
108
109
# File 'lib/tapioca/gemfile.rb', line 107

def name
  @spec.name
end

#rbi_file_name ⇒ Object



117
118
119
# File 'lib/tapioca/gemfile.rb', line 117

def rbi_file_name
  "#{name}@#{version}.rbi"
end

#version ⇒ Object



112
113
114
# File 'lib/tapioca/gemfile.rb', line 112

def version
  @spec.version
end