Sha256: 88c08cd7c01d4e829063e7f668e0350c46c6558c85c8f2b926153fe43929a80c
Contents?: true
Size: 1.23 KB
Versions: 6
Compression:
Stored size: 1.23 KB
Contents
require 'specinfra/helper/detect_os' module Specinfra::Helper::Os def commands Specinfra::Command::Base.new end 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) 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
6 entries across 6 versions & 1 rubygems