Class: Serialbench::Models::Platform

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/serialbench/models/platform.rb

Overview

platform:

platform_string: docker-ruby-3.0
kind: docker
os: linux
arch: arm64
ruby_build_tag: 3.0.7

Class Method Summary collapse

Class Method Details

.current_local(ruby_version: nil) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/serialbench/models/platform.rb', line 34

def self.current_local(ruby_version: nil)
  version = ruby_version || RUBY_VERSION

  # Check for GitHub Actions runner platform
  github_platform = ENV['GITHUB_RUNNER_PLATFORM']
  if github_platform
    os, arch = parse_github_platform(github_platform)
    platform_string = "#{github_platform}-ruby-#{version}"
  else
    os = detect_os
    arch = detect_arch
    platform_string = "local-#{version}"
  end

  new(
    platform_string: platform_string,
    kind: 'local',
    os: os,
    arch: arch,
    ruby_version: version,
    ruby_build_tag: version
  )
end

.detect_archObject



71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/serialbench/models/platform.rb', line 71

def self.detect_arch
  case RbConfig::CONFIG['host_cpu']
  when /x86_64|amd64/i
    'x86_64'
  when /aarch64|arm64/i
    'arm64'
  when /arm/i
    'arm'
  else
    'unknown'
  end
end

.detect_osObject



58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/serialbench/models/platform.rb', line 58

def self.detect_os
  case RbConfig::CONFIG['host_os']
  when /darwin/i
    'macos'
  when /linux/i
    'linux'
  when /mswin|mingw|cygwin/i
    'windows'
  else
    'unknown'
  end
end

.parse_github_platform(platform_name) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/serialbench/models/platform.rb', line 84

def self.parse_github_platform(platform_name)
  # Parse GitHub Actions runner platform names
  # Examples: ubuntu-24.04, ubuntu-24.04-arm, macos-13, macos-15-intel,
  #           macos-14, macos-15, macos-26, windows-2022, windows-2025, windows-11-arm

  case platform_name
  when /^ubuntu.*-arm$/
    ['linux', 'arm64']
  when /^ubuntu/
    ['linux', 'x86_64']
  when /^macos-.*-intel$/
    ['macos', 'x86_64']
  when /^macos-(13)$/
    ['macos', 'x86_64']
  when /^macos-(14|15|26)$/
    ['macos', 'arm64']
  when /^windows.*-arm$/
    ['windows', 'arm64']
  when /^windows/
    ['windows', 'x86_64']
  else
    # Fallback to automatic detection
    [detect_os, detect_arch]
  end
end