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(::Bundler::StubSpecification, ::Gem::Specification))
Instance Method Summary collapse
- #dependencies ⇒ Object
- #gem(gem_name) ⇒ Object
-
#initialize ⇒ Gemfile
constructor
A new instance of Gemfile.
- #require_bundle(initialize_file, require_file) ⇒ Object
Methods included from T::Sig
Constructor Details
#initialize ⇒ Gemfile
Returns a new instance of Gemfile.
13 14 15 16 17 18 |
# File 'lib/tapioca/gemfile.rb', line 13 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
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/tapioca/gemfile.rb', line 21 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
36 37 38 |
# File 'lib/tapioca/gemfile.rb', line 36 def gem(gem_name) dependencies.detect { |dep| dep.name == gem_name } end |
#require_bundle(initialize_file, require_file) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/tapioca/gemfile.rb', line 41 def require_bundle(initialize_file, require_file) require(initialize_file) if initialize_file && File.exist?(initialize_file) runtime = Bundler::Runtime.new(File.dirname(gemfile.path), definition) groups = Bundler.definition.groups runtime.setup(*groups).require(*groups) require(require_file) if require_file && File.exist?(require_file) load_rails_engines end |