Class: Tapioca::Gemfile::GemSpec
- Inherits:
-
Object
- Object
- Tapioca::Gemfile::GemSpec
- Extended by:
- T::Sig
- 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
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#full_gem_path ⇒ Object
readonly
Returns the value of attribute full_gem_path.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #contains_path?(path) ⇒ Boolean
- #export_rbi_files? ⇒ Boolean
- #exported_rbi_files ⇒ Object
- #exported_rbi_tree ⇒ Object
- #ignore?(gemfile_dir) ⇒ Boolean
-
#initialize(spec) ⇒ GemSpec
constructor
A new instance of GemSpec.
- #name ⇒ Object
- #parse_yard_docs ⇒ Object
- #rbi_file_name ⇒ Object
Constructor Details
#initialize(spec) ⇒ GemSpec
Returns a new instance of GemSpec.
152 153 154 155 156 157 158 159 |
# File 'lib/tapioca/gemfile.rb', line 152 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 (readonly)
Returns the value of attribute files.
149 150 151 |
# File 'lib/tapioca/gemfile.rb', line 149 def files @files end |
#full_gem_path ⇒ Object (readonly)
Returns the value of attribute full_gem_path.
146 147 148 |
# File 'lib/tapioca/gemfile.rb', line 146 def full_gem_path @full_gem_path end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
146 147 148 |
# File 'lib/tapioca/gemfile.rb', line 146 def version @version end |
Instance Method Details
#contains_path?(path) ⇒ Boolean
177 178 179 180 181 182 183 |
# File 'lib/tapioca/gemfile.rb', line 177 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
196 197 198 |
# File 'lib/tapioca/gemfile.rb', line 196 def export_rbi_files? exported_rbi_files.any? end |
#exported_rbi_files ⇒ Object
191 192 193 |
# File 'lib/tapioca/gemfile.rb', line 191 def exported_rbi_files @exported_rbi_files ||= Dir.glob("#{full_gem_path}/rbi/**/*.rbi").sort end |
#exported_rbi_tree ⇒ Object
201 202 203 204 205 206 207 208 209 210 |
# File 'lib/tapioca/gemfile.rb', line 201 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
162 163 164 |
# File 'lib/tapioca/gemfile.rb', line 162 def ignore?(gemfile_dir) gem_ignored? || gem_in_app_dir?(gemfile_dir) end |
#name ⇒ Object
167 168 169 |
# File 'lib/tapioca/gemfile.rb', line 167 def name @spec.name end |
#parse_yard_docs ⇒ Object
186 187 188 |
# File 'lib/tapioca/gemfile.rb', line 186 def parse_yard_docs files.each { |path| YARD.parse(path.to_s, [], Logger::Severity::FATAL) } end |
#rbi_file_name ⇒ Object
172 173 174 |
# File 'lib/tapioca/gemfile.rb', line 172 def rbi_file_name "#{name}@#{version}.rbi" end |