Class: Tapioca::Gemfile::GemSpec
- Inherits:
-
Object
- Object
- Tapioca::Gemfile::GemSpec
show all
- Extended by:
- T::Sig
- Includes:
- Tapioca::GemHelper
- Defined in:
- lib/tapioca/gemfile.rb
Constant Summary
collapse
- IGNORED_GEMS =
T.let(["sorbet", "sorbet-static", "sorbet-runtime", "sorbet-static-and-runtime"].freeze,
T::Array[String])
Instance Attribute Summary collapse
Instance Method Summary
collapse
#gem_in_app_dir?, #gem_in_bundle_path?, #to_realpath
Constructor Details
#initialize(spec) ⇒ GemSpec
153
154
155
156
157
158
159
160
|
# File 'lib/tapioca/gemfile.rb', line 153
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)
@exported_rbi_files = T.let(nil, T.nilable(T::Array[String]))
@files = T.let(collect_files, T::Array[Pathname])
end
|
Instance Attribute Details
#files ⇒ Object
Returns the value of attribute files.
150
151
152
|
# File 'lib/tapioca/gemfile.rb', line 150
def files
@files
end
|
#full_gem_path ⇒ Object
Returns the value of attribute full_gem_path.
147
148
149
|
# File 'lib/tapioca/gemfile.rb', line 147
def full_gem_path
@full_gem_path
end
|
#version ⇒ Object
Returns the value of attribute version.
147
148
149
|
# File 'lib/tapioca/gemfile.rb', line 147
def version
@version
end
|
Instance Method Details
#contains_path?(path) ⇒ Boolean
178
179
180
181
182
183
184
|
# File 'lib/tapioca/gemfile.rb', line 178
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
|
#export_rbi_files? ⇒ Boolean
197
198
199
|
# File 'lib/tapioca/gemfile.rb', line 197
def export_rbi_files?
exported_rbi_files.any?
end
|
#exported_rbi_files ⇒ Object
192
193
194
|
# File 'lib/tapioca/gemfile.rb', line 192
def exported_rbi_files
@exported_rbi_files ||= Dir.glob("#{full_gem_path}/rbi/**/*.rbi").sort
end
|
#exported_rbi_tree ⇒ Object
202
203
204
205
206
207
208
209
210
211
|
# File 'lib/tapioca/gemfile.rb', line 202
def exported_rbi_tree
rewriter = RBI::Rewriters::Merge.new(keep: RBI::Rewriters::Merge::Keep::NONE)
exported_rbi_files.each do |file|
rbi = RBI::Parser.parse_file(file)
rewriter.merge(rbi)
end
rewriter.tree
end
|
#ignore?(gemfile_dir) ⇒ Boolean
163
164
165
|
# File 'lib/tapioca/gemfile.rb', line 163
def ignore?(gemfile_dir)
gem_ignored? || gem_in_app_dir?(gemfile_dir, full_gem_path)
end
|
#name ⇒ Object
168
169
170
|
# File 'lib/tapioca/gemfile.rb', line 168
def name
@spec.name
end
|
#parse_yard_docs ⇒ Object
187
188
189
|
# File 'lib/tapioca/gemfile.rb', line 187
def parse_yard_docs
files.each { |path| YARD.parse(path.to_s, [], Logger::Severity::FATAL) }
end
|
#rbi_file_name ⇒ Object
173
174
175
|
# File 'lib/tapioca/gemfile.rb', line 173
def rbi_file_name
"#{name}@#{version}.rbi"
end
|