lib/tapioca/gemfile.rb in tapioca-0.5.2 vs lib/tapioca/gemfile.rb in tapioca-0.5.3
- old
+ new
@@ -1,20 +1,19 @@
# typed: strict
# frozen_string_literal: true
require "bundler"
+require "logger"
+require "yard-sorbet"
module Tapioca
class Gemfile
extend(T::Sig)
Spec = T.type_alias do
T.any(
- T.all(
- ::Bundler::StubSpecification,
- ::Bundler::RemoteSpecification
- ),
+ ::Bundler::StubSpecification,
::Gem::Specification
)
end
sig { returns(Bundler::Definition) }
@@ -113,16 +112,17 @@
gem_ignored? || gem_in_app_dir?(gemfile_dir)
end
sig { returns(T::Array[Pathname]) }
def files
- if default_gem?
- @spec.files.map do |file|
+ spec = @spec
+ if default_gem? && spec.is_a?(::Gem::Specification)
+ spec.files.map do |file|
ruby_lib_dir.join(file)
end
else
- @spec.full_require_paths.flat_map do |path|
+ spec.full_require_paths.flat_map do |path|
Pathname.glob((Pathname.new(path) / "**/*.rb").to_s)
end
end
end
@@ -141,9 +141,14 @@
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
+
+ sig { void }
+ def parse_yard_docs
+ files.each { |path| YARD.parse(path.to_s, [], Logger::Severity::FATAL) }
end
private
sig { returns(T::Boolean) }