Sha256: 8b659474c7dd5123ffc86fd4c516cb7399dec16f618b3aa4caa92948d6b001d9
Contents?: true
Size: 1.18 KB
Versions: 17
Compression:
Stored size: 1.18 KB
Contents
require 'specinfra/helper/detect_os' module Specinfra::Helper::Os def os property[:os_by_host] = {} if ! property[:os_by_host] host_port = current_host_and_port if property[:os_by_host][host_port] os_by_host = property[:os_by_host][host_port] else # Set command object explicitly to avoid `stack too deep` os_by_host = detect_os property[:os_by_host][host_port] = os_by_host end os_by_host end private # put this in a module for better reuse def current_host_and_port if Specinfra.configuration.ssh "#{Specinfra.configuration.ssh.host}:#{Specinfra.configuration.ssh.options[:port]}" elsif Specinfra.configuration.ssh_options "#{Specinfra.configuration.host}:#{Specinfra.configuration.ssh_options[:port]}" else "#{Specinfra.configuration.host}:0" end end def run_command(cmd) Specinfra.backend.run_command(cmd) end def detect_os return Specinfra.configuration.os if Specinfra.configuration.os Specinfra::Helper::DetectOs.subclasses.each do |c| res = c.detect if res res[:arch] ||= run_command('uname -m').stdout.strip return res end end end end
Version data entries
17 entries across 17 versions & 1 rubygems