Sha256: e9b77a295272e395c90bff6859cdc18832d9aa47aed66e8ae48d1c2134e6a5b5

Contents?: true

Size: 746 Bytes

Versions: 2

Compression:

Stored size: 746 Bytes

Contents

module Thug
	class PlatformDetector
		
		# get platform: ubuntu, debian, centos
		def get_platform
			
			if(/darwin/i =~ RUBY_PLATFORM)
				return "mac"
			end

			platform = `ohai platform`


			if platform =~ /ubuntu/i
				platform = "ubuntu"
			elsif platform =~ /debian/i
				platform = "debian"
			elsif platform =~ /centos/i
				platform = "centos"
			end
				
			platform
		end

		def get_os
			os = `ohai os`
			if os =~ /linux/i
				os = "linux"
			end

			os
		end

		# returns package manager of current platform
		def get_package_manager platform
			case platform
			when "ubuntu"
				pkg = "apt-get"
			when "debian"
				pkg = "apt-get"
			when "centos"
				pkg = "yum"
			when "mac"
				pkg = "brew"
			end

			pkg
		end


	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thug-0.2.1 lib/thug/platform/platform_detector.rb
thug-0.2.0 lib/thug/platform/platform_detector.rb