Class: Tapioca::Gemfile

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/tapioca/gemfile.rb

Defined Under Namespace

Classes: Gem

Constant Summary collapse

Spec =
T.type_alias do
  T.any(
    T.all(
      ::Bundler::StubSpecification,
      ::Bundler::RemoteSpecification
    ),
    ::Gem::Specification
  )
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGemfile

Returns a new instance of Gemfile.



30
31
32
33
34
35
36
37
# File 'lib/tapioca/gemfile.rb', line 30

def initialize
  @gemfile = T.let(File.new(Bundler.default_gemfile), File)
  @lockfile = T.let(File.new(Bundler.default_lockfile), File)
  @definition = T.let(Bundler::Dsl.evaluate(gemfile, lockfile, {}), Bundler::Definition)
  dependencies, missing_specs = load_dependencies
  @dependencies = T.let(dependencies, T::Array[Gem])
  @missing_specs = T.let(missing_specs, T::Array[String])
end

Instance Attribute Details

#definitionObject (readonly)

Returns the value of attribute definition.



21
22
23
# File 'lib/tapioca/gemfile.rb', line 21

def definition
  @definition
end

#dependenciesObject (readonly)

Returns the value of attribute dependencies.



24
25
26
# File 'lib/tapioca/gemfile.rb', line 24

def dependencies
  @dependencies
end

#missing_specsObject (readonly)

Returns the value of attribute missing_specs.



27
28
29
# File 'lib/tapioca/gemfile.rb', line 27

def missing_specs
  @missing_specs
end

Instance Method Details

#gem(gem_name) ⇒ Object



40
41
42
# File 'lib/tapioca/gemfile.rb', line 40

def gem(gem_name)
  dependencies.detect { |dep| dep.name == gem_name }
end

#requireObject



45
46
47
# File 'lib/tapioca/gemfile.rb', line 45

def require
  T.unsafe(runtime).setup(*groups).require(*groups)
end