Class: Tapioca::Gemfile::Gem
- Inherits:
-
Object
- Object
- Tapioca::Gemfile::Gem
- Extended by:
- T::Sig
- Defined in:
- lib/tapioca/gemfile.rb
Constant Summary collapse
- IGNORED_GEMS =
T.let(%w{ sorbet sorbet-static sorbet-runtime }.freeze, T::Array[String])
Instance Attribute Summary collapse
-
#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
- #files ⇒ Object
- #ignore?(gemfile_dir) ⇒ Boolean
-
#initialize(spec) ⇒ Gem
constructor
A new instance of Gem.
- #name ⇒ Object
- #rbi_file_name ⇒ Object
Constructor Details
#initialize(spec) ⇒ Gem
Returns a new instance of Gem.
97 98 99 100 101 102 |
# File 'lib/tapioca/gemfile.rb', line 97 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 |
Instance Attribute Details
#full_gem_path ⇒ Object (readonly)
Returns the value of attribute full_gem_path.
94 95 96 |
# File 'lib/tapioca/gemfile.rb', line 94 def full_gem_path @full_gem_path end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
94 95 96 |
# File 'lib/tapioca/gemfile.rb', line 94 def version @version end |
Instance Method Details
#contains_path?(path) ⇒ Boolean
127 128 129 |
# File 'lib/tapioca/gemfile.rb', line 127 def contains_path?(path) to_realpath(path).start_with?(full_gem_path) || has_parent_gemspec?(path) end |
#files ⇒ Object
110 111 112 113 114 |
# File 'lib/tapioca/gemfile.rb', line 110 def files @spec.full_require_paths.flat_map do |path| Pathname.glob((Pathname.new(path) / "**/*.rb").to_s) end end |
#ignore?(gemfile_dir) ⇒ Boolean
105 106 107 |
# File 'lib/tapioca/gemfile.rb', line 105 def ignore?(gemfile_dir) gem_ignored? || gem_in_app_dir?(gemfile_dir) end |
#name ⇒ Object
117 118 119 |
# File 'lib/tapioca/gemfile.rb', line 117 def name @spec.name end |
#rbi_file_name ⇒ Object
122 123 124 |
# File 'lib/tapioca/gemfile.rb', line 122 def rbi_file_name "#{name}@#{version}.rbi" end |