1

What object/process picks up a newly created Specification object when running gem build against a typical gemspec file?

For instance, suppose we have mynewgem.gemspec with contents as follows:

Gem::Specification.new do |s|
  s.name = "mynewgem"
  s.version = "0.0.1"
  s.summary = "here is a summary"
  s.description = "here is a desc"
  s.authors = ["Full Name"]
  s.email = "myname@mydomain.net"
  s.files = Dir.glob("lib/**/*", File::FNM_DOTMATCH)
  s.homepage = "https://rubygems.org/gems/mynewgem"
  s.license = "My License"

  s.add_dependency "this-dependency", "~> 1.2.3"
  s.add_dependency "that-dependency", "~> 4.5.6"
end

What class/method is referencing the newly created Gem::Specification object here? It's obviously not directly assigned to a variable in mynewgem.gemspec. How does whatever sees this new object actually see/reference it?

Jared Beck
  • 16,796
  • 9
  • 72
  • 97
Jacob M. Barnard
  • 1,347
  • 1
  • 10
  • 24

1 Answers1

1

What object/process picks up [the] newly created Specification object when running gem build against a typical gemspec file?

Please see Gem::Commands::BuildCommand#build_package

# rubygems/commands/build_command.rb
def build_package(gemspec)
  spec = Gem::Specification.load(gemspec)
  if spec
    Gem::Package.build(
      # etc ...
Jared Beck
  • 16,796
  • 9
  • 72
  • 97
  • Ahhh. Looks like eventually an `eval` is called against the contents of the `.gemspec` file, then the result is assigned to the `_spec` variable. Of course, some pre-processing in there and I/O with `File` class, but that's the gist of it. That's what I needed. Thanks! – Jacob M. Barnard Jul 26 '21 at 19:38