Module: Bootprint::Collectors::OperatingSystem

Defined in:
lib/bootprint/collectors/operating_system.rb

Constant Summary collapse

TOOLS =
%w[git make gcc clang cmake pkg-config docker podman].freeze

Class Method Summary collapse

Class Method Details

.captureObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/bootprint/collectors/operating_system.rb', line 15

def capture
  {
    "name" => RbConfig::CONFIG["host_os"],
    "cpu" => RbConfig::CONFIG["host_cpu"],
    "processors" => Etc.nprocessors,
    "capabilities" => TOOLS.to_h { |tool| [tool, executable?(tool)] },
    "ruby_headers" => header_state,
    "ci" => ci_provider
  }
end

.ci_providerObject



40
41
42
43
44
45
46
47
# File 'lib/bootprint/collectors/operating_system.rb', line 40

def ci_provider
  return "github" if ENV["GITHUB_ACTIONS"] == "true"
  return "gitlab" if ENV["GITLAB_CI"] == "true"
  return "circleci" if ENV["CIRCLECI"] == "true"
  return "generic" if ENV.key?("CI")

  nil
end

.executable?(name) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
32
33
# File 'lib/bootprint/collectors/operating_system.rb', line 26

def executable?(name)
  extensions = Gem.win_platform? ? ENV.fetch("PATHEXT", ".EXE;.BAT;.CMD").split(";") : [""]
  ENV.fetch("PATH", "").split(File::PATH_SEPARATOR).any? do |directory|
    extensions.any? do |extension|
      File.executable?(File.join(directory, "#{name}#{extension}"))
    end
  end
end

.header_stateObject



35
36
37
38
# File 'lib/bootprint/collectors/operating_system.rb', line 35

def header_state
  path = RbConfig::CONFIG["rubyhdrdir"]
  { "present" => path && File.directory?(path), "path" => path && Sanitizer.path(path) }
end

.keyObject



13
# File 'lib/bootprint/collectors/operating_system.rb', line 13

def key = "operating_system"