Module: OS
- Defined in:
- lib/fluent/plugin/os.rb
Overview
Utility class to determine the underlying operating system.
Class Method Summary collapse
- .debian? ⇒ Boolean
- .linux? ⇒ Boolean
- .mac? ⇒ Boolean
- .os_name_debian? ⇒ Boolean
- .os_name_ubuntu? ⇒ Boolean
- .ubuntu? ⇒ Boolean
- .unix? ⇒ Boolean
- .windows? ⇒ Boolean
Class Method Details
.debian? ⇒ Boolean
30 31 32 |
# File 'lib/fluent/plugin/os.rb', line 30 def self.debian? linux? and os_name_debian? end |
.linux? ⇒ Boolean
22 23 24 |
# File 'lib/fluent/plugin/os.rb', line 22 def self.linux? unix? and !mac? end |
.mac? ⇒ Boolean
14 15 16 |
# File 'lib/fluent/plugin/os.rb', line 14 def self.mac? (/darwin/ =~ RUBY_PLATFORM) != nil end |
.os_name_debian? ⇒ Boolean
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/fluent/plugin/os.rb', line 52 def self.os_name_debian? os_name = 'not_found' file_name = '/etc/os-release' if File.exists?(file_name) File.foreach(file_name).each do |line| if line.start_with?('ID=') os_name = line.split('=')[1].strip end end else logger.info('Unknown linux distribution detected') end os_name == 'debian' ? true : false rescue StandardError => e log.error "Unable to detect ubuntu platform due to: #{e.}" false end |
.os_name_ubuntu? ⇒ Boolean
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fluent/plugin/os.rb', line 34 def self.os_name_ubuntu? os_name = 'not_found' file_name = '/etc/os-release' if File.exists?(file_name) IO.foreach(file_name).each do |line| if line.start_with?('ID=') os_name = line.split('=')[1].strip end end else logger.info('Unknown linux distribution detected') end os_name == 'ubuntu' ? true : false rescue StandardError => e log.error "Unable to detect ubuntu platform due to: #{e.}" false end |
.ubuntu? ⇒ Boolean
26 27 28 |
# File 'lib/fluent/plugin/os.rb', line 26 def self.ubuntu? linux? and os_name_ubuntu? end |
.windows? ⇒ Boolean
10 11 12 |
# File 'lib/fluent/plugin/os.rb', line 10 def self.windows? (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil end |