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
- .capture ⇒ Object
- .ci_provider ⇒ Object
- .encoding_state ⇒ Object
- .executable?(name) ⇒ Boolean
- .header_state ⇒ Object
- .key ⇒ Object
- .locale_state ⇒ Object
- .timezone_state ⇒ Object
Class Method Details
.capture ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# 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, "timezone" => timezone_state, "encoding" => encoding_state, "locale" => locale_state } end |
.ci_provider ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/bootprint/collectors/operating_system.rb', line 43 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 |
.encoding_state ⇒ Object
61 62 63 64 65 66 |
# File 'lib/bootprint/collectors/operating_system.rb', line 61 def encoding_state { "external" => Encoding.default_external.name, "internal" => Encoding.default_internal&.name } end |
.executable?(name) ⇒ Boolean
29 30 31 32 33 34 35 36 |
# File 'lib/bootprint/collectors/operating_system.rb', line 29 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_state ⇒ Object
38 39 40 41 |
# File 'lib/bootprint/collectors/operating_system.rb', line 38 def header_state path = RbConfig::CONFIG["rubyhdrdir"] { "present" => path && File.directory?(path), "path" => path && Sanitizer.path(path) } end |
.key ⇒ Object
13 |
# File 'lib/bootprint/collectors/operating_system.rb', line 13 def key = "operating_system" |
.locale_state ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/bootprint/collectors/operating_system.rb', line 68 def locale_state { "lang" => ENV.fetch("LANG", nil), "lc_all" => ENV.fetch("LC_ALL", nil), "charmap" => Encoding.locale_charmap } end |
.timezone_state ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/bootprint/collectors/operating_system.rb', line 52 def timezone_state now = Time.now { "name" => now.zone, "utc_offset" => now.utc_offset, "tz" => ENV.fetch("TZ", nil) } end |