Module: PumaPlus::Core

Defined in:
lib/puma_plus/core.rb,
lib/puma_plus/core/version.rb

Overview

Locates the compiled puma-plus server binary.

This gem exists so that the Go server can be installed by RubyGems like anything else. It ships two ways:

puma-plus-core-X.Y.Z.gem                  source; builds Go at install time
puma-plus-core-X.Y.Z-x86_64-linux.gem     the binary, already built

A platform gem is preferred by RubyGems automatically when one matches, so the common case installs a binary and never needs a Go toolchain. The source gem is the fallback for platforms nobody has published, and it is the reason this is a separate gem from puma-plus at all: a native-platform gem can carry a precompiled Go binary only if it carries nothing that also needs compiling for the local Ruby, and puma-plus has a C extension that does.

Constant Summary collapse

GO_MINIMUM =
"1.24"
VERSION =

Released in lockstep with puma-plus, which depends on this exact version.

The Go server and the Ruby gem speak a private binary protocol with no version negotiation in the data path, so a mismatched pair is not a degraded install -- it is a broken one. Pinning exactly is cheaper than building negotiation for a pair that is always released together.

"0.1.0"

Class Method Summary collapse

Class Method Details

.binary_pathObject

Where the binary lives once installed, either way it got there.



22
23
24
# File 'lib/puma_plus/core.rb', line 22

def self.binary_path
  candidates.find { |p| File.executable?(p) && !File.directory?(p) }
end

.binary_path!Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/puma_plus/core.rb', line 26

def self.binary_path!
  binary_path || raise(<<~MSG)
    puma-plus-core is installed but has no server binary for this platform.

    Looked in:
    #{candidates.map { |c| "  #{c}" }.join("\n")}

    If this is a source install, the Go build did not produce a binary --
    check the output of `gem install puma-plus-core`. A Go toolchain
    (#{GO_MINIMUM}+) is required to build from source.
  MSG
end

.candidatesObject

exe/ is where both paths converge: the source build writes its output there so that a source install and a platform install are indistinguishable to everything downstream.



44
45
46
47
48
49
50
# File 'lib/puma_plus/core.rb', line 44

def self.candidates
  root = File.expand_path("../..", __dir__)
  [
    File.join(root, "exe", exe_name),
    File.join(root, "bin", exe_name)
  ]
end

.exe_nameObject



52
53
54
# File 'lib/puma_plus/core.rb', line 52

def self.exe_name
  windows? ? "puma-plus-server.exe" : "puma-plus-server"
end

.windows?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/puma_plus/core.rb', line 56

def self.windows?
  RbConfig::CONFIG["host_os"] =~ /mswin|mingw|cygwin/
end