Module: Getch::Guard
- Defined in:
- lib/getch/guard.rb
Overview
various guard
Class Method Summary collapse
Class Method Details
.disk(name) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/getch/guard.rb', line 29 def self.disk(name) raise InvalidDisk, 'No disk.' unless name raise InvalidDisk, "Bad device name #{name}." unless valid_disk(name) raise InvalidDisk, "Disk /dev/#{name} no found." unless File.exist? "/dev/#{name}" name rescue InvalidDisk => e puts "#{e.class} => #{e}" exit 1 end |
.format(name) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/getch/guard.rb', line 40 def self.format(name) raise InvalidFormat, 'No format specified.' unless name raise InvalidFormat, "Format #{name} not yet available." if name.match(/btrfs|xfs/) raise InvalidFormat, "Format #{name} not supported." unless name.match(/zfs|ext4/) name rescue InvalidFormat => e puts "#{e.class} => #{e}" exit 1 end |
.keymap(name) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/getch/guard.rb', line 62 def self.keymap(name) raise InvalidKeymap, 'No keymap specified.' unless name key = [] if Dir.exist? '/usr/share/keymaps' key = Dir.glob("/usr/share/keymaps/**/#{name}.map.gz") elsif Dir.exist? '/usr/share/kbd/keymaps' key = Dir.glob("/usr/share/kbd/keymaps/**/#{name}.map.gz") else raise InvalidKeymap, 'No directory found for keymap.' end raise InvalidKeymap, "Keymap #{name} no found." if key == [] name rescue InvalidKeymap => e puts "#{e.class} => #{e}" exit 1 end |
.zone(name) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/getch/guard.rb', line 51 def self.zone(name) raise InvalidZone, 'No zoneinfo specified.' unless name raise InvalidZone, 'Directory /usr/share/zoneinfo/ no found on this system...' unless Dir.exist? '/usr/share/zoneinfo/' raise InvalidZone, "Zoneinfo #{name} is no found in /usr/share/zoneinfo/." unless File.exist? "/usr/share/zoneinfo/#{name}" name rescue InvalidZone => e puts "#{e.class} => #{e}" exit 1 end |