Class: Thug::PlatformDetector
- Inherits:
-
Object
- Object
- Thug::PlatformDetector
- Defined in:
- lib/thug/platform/platform_detector.rb
Instance Method Summary collapse
- #get_os ⇒ Object
-
#get_package_manager(platform) ⇒ Object
returns package manager of current platform.
-
#get_platform ⇒ Object
get platform: ubuntu, debian, centos.
Instance Method Details
#get_os ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/thug/platform/platform_detector.rb', line 25 def get_os os = `ohai os` if os =~ /linux/i os = "linux" end os end |
#get_package_manager(platform) ⇒ Object
returns package manager of current platform
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/thug/platform/platform_detector.rb', line 35 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 |
#get_platform ⇒ Object
get platform: ubuntu, debian, centos
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/thug/platform/platform_detector.rb', line 5 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 |