Module: System
- Defined in:
- lib/vex/base/system.rb
Defined Under Namespace
Classes: ProcessFailed
Class Method Summary collapse
- .linux? ⇒ Boolean
- .name ⇒ Object
- .sys(*args) ⇒ Object
- .sys!(*args) ⇒ Object
- .uname ⇒ Object
- .which(binary) ⇒ Object
- .which!(binary) ⇒ Object
Class Method Details
.linux? ⇒ Boolean
43 44 45 |
# File 'lib/vex/base/system.rb', line 43 def self.linux? uname == "Linux" end |
.name ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/vex/base/system.rb', line 35 def self.name case uname when "Darwin" then :osx when "Linux" then :linux else raise "Unsupported OS uname #{uname}" end end |
.sys(*args) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/vex/base/system.rb', line 24 def self.sys(*args) sys!(*args) rescue ProcessFailed App.logger.warn "#{args.join(" ")}: #{$!}" false end |
.sys!(*args) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/vex/base/system.rb', line 15 def self.sys!(*args) cmd = args.join(" ") benchmark "**** Running #{cmd}" do next true if system(cmd) raise ProcessFailed, cmd end end |
.uname ⇒ Object
31 32 33 |
# File 'lib/vex/base/system.rb', line 31 def self.uname @uname ||= `uname`.chomp end |
.which(binary) ⇒ Object
47 48 49 50 |
# File 'lib/vex/base/system.rb', line 47 def self.which(binary) r = `which #{binary}`.chomp r.blank? ? nil : r end |
.which!(binary) ⇒ Object
52 53 54 |
# File 'lib/vex/base/system.rb', line 52 def self.which!(binary) which(binary) || abort("Missing binary #{binary}") end |