Class: Tapioca::Gemfile
- Inherits:
-
Object
- Object
- Tapioca::Gemfile
- Extended by:
- T::Sig
- Defined in:
- lib/tapioca/gemfile.rb
Defined Under Namespace
Classes: Gem
Constant Summary collapse
- Spec =
T.type_alias( T.any( T.all( ::Bundler::StubSpecification, ::Bundler::RemoteSpecification ), ::Gem::Specification ) )
Instance Method Summary collapse
- #dependencies ⇒ Object
- #gem(gem_name) ⇒ Object
-
#initialize ⇒ Gemfile
constructor
A new instance of Gemfile.
- #require ⇒ Object
Constructor Details
#initialize ⇒ Gemfile
Returns a new instance of Gemfile.
21 22 23 24 25 26 |
# File 'lib/tapioca/gemfile.rb', line 21 def initialize @gemfile = T.let(File.new(Bundler.default_gemfile), File) @lockfile = T.let(File.new(Bundler.default_lockfile), File) @dependencies = T.let(nil, T.nilable(T::Array[Gem])) @definition = T.let(nil, T.nilable(Bundler::Definition)) end |
Instance Method Details
#dependencies ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/tapioca/gemfile.rb', line 29 def dependencies @dependencies ||= begin specs = definition.specs.to_a definition .resolve .materialize(specs) .reject { |spec| ignore_gem_spec?(spec) } .map { |spec| Gem.new(spec) } .uniq(&:rbi_file_name) .sort_by(&:rbi_file_name) end end |
#gem(gem_name) ⇒ Object
44 45 46 |
# File 'lib/tapioca/gemfile.rb', line 44 def gem(gem_name) dependencies.detect { |dep| dep.name == gem_name } end |
#require ⇒ Object
49 50 51 |
# File 'lib/tapioca/gemfile.rb', line 49 def require T.unsafe(runtime).setup(*groups).require(*groups) end |