Module: Nomansland
- Defined in:
- lib/nomansland.rb,
lib/nomansland/init.rb,
lib/nomansland/distro.rb,
lib/nomansland/installer.rb
Class Method Summary collapse
Class Method Details
.distro? ⇒ Boolean
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/nomansland/distro.rb', line 3 def self.distro? return :fedora if File.exist? '/etc/fedora-release' return :redhat if File.exist? '/etc/redhat-release' return :suse if File.exist? '/etc/SUSE-release' return :mandrake if File.exist? '/etc/mandrake-release' return :ubuntu if File.exist? '/etc/ubuntu-release' return :debian if File.exist? '/etc/debian_version' return :gentoo if File.exist? '/etc/gentoo-release' return :archlinux if File.exist? '/etc/arch-release' return :void if self.grep?('/etc/os-release', /void/) end |
.grep?(file, regex) ⇒ Boolean
15 16 17 18 19 20 21 22 |
# File 'lib/nomansland/distro.rb', line 15 def self.grep?(file, regex) is_found = false return is_found unless File.exist? file File.open(file) do |f| f.each { |l| is_found = true if l.match(regex) } end is_found end |
.init? ⇒ Boolean
2 3 4 5 6 7 8 |
# File 'lib/nomansland/init.rb', line 2 def self.init? return :systemd if Dir.exist? '/etc/systemd' # https://github.com/void-linux/void-runit return :runit if Dir.exist? '/etc/runit' return :openrc if Dir.exist? '/etc/init.d' end |
.installer? ⇒ Boolean
2 3 4 5 6 7 8 |
# File 'lib/nomansland/installer.rb', line 2 def self.installer? return :yum if File.exist? '/usr/bin/yum' return :apt_get if File.exist? '/usr/bin/apt-get' return :pacman if File.exist? '/usr/bin/pacman' return :emerge if File.exist? '/usr/bin/emerge' return :void if File.exist? '/usr/bin/xbps-install' end |