Class: PlatformGem
- Inherits:
-
Object
- Object
- PlatformGem
- Defined in:
- lib/ratatui_ruby/devtools/tasks/release/platform_gem.rb
Overview
A platform-specific gem assembled from pre-compiled versioned binaries.
CI builds produce one compiled binary per Ruby version per OS. A PlatformGem collects those binaries and packages them into a single installable gem that serves all supported Ruby versions.
Instance Method Summary collapse
-
#build ⇒ Object
Packages the platform gem into
pkg/. -
#initialize(spec = Gem::Specification.load(RatatuiRuby::Devtools.gemspec_file), lib_dir = "lib/#{RatatuiRuby::Devtools.gem_name.tr('-', '_')}") ⇒ PlatformGem
constructor
Loads the gemspec and scans for compiled binaries.
Constructor Details
#initialize(spec = Gem::Specification.load(RatatuiRuby::Devtools.gemspec_file), lib_dir = "lib/#{RatatuiRuby::Devtools.gem_name.tr('-', '_')}") ⇒ PlatformGem
Loads the gemspec and scans for compiled binaries.
21 22 23 24 25 26 27 28 |
# File 'lib/ratatui_ruby/devtools/tasks/release/platform_gem.rb', line 21 def initialize( spec = Gem::Specification.load(RatatuiRuby::Devtools.gemspec_file), lib_dir = "lib/#{RatatuiRuby::Devtools.gem_name.tr('-', '_')}" ) @spec = spec @lib_dir = lib_dir @binaries = VersionedBinary.scan(lib_dir, RatatuiRuby::Devtools.gem_name) end |
Instance Method Details
#build ⇒ Object
Packages the platform gem into pkg/.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/ratatui_ruby/devtools/tasks/release/platform_gem.rb', line 31 def build abort "No versioned binaries found in #{@lib_dir}/*/" if @binaries.empty? @spec.platform = Gem::Platform.local @spec.extensions.clear @spec.files += @binaries.map(&:path) #-- # SPDX-SnippetBegin # SPDX-SnippetCopyrightText: rake-compiler contributors # SPDX-License-Identifier: MIT # # Version constraint pattern derived from rake-compiler's # ExtensionTask#define_native_tasks (lib/rake/extensiontask.rb). #++ @spec.required_ruby_version = [ ">= #{@binaries.first.api_version}", "< #{@binaries.last.api_version.succ}.dev", ] #-- # SPDX-SnippetEnd #++ FileUtils.mkdir_p("pkg") gem_file = Gem::Package.build(@spec) FileUtils.mv(gem_file, "pkg") puts "Built pkg/#{File.basename(gem_file)}" end |