Class: Niman::Shell
- Inherits:
-
Object
- Object
- Niman::Shell
- Defined in:
- lib/niman/shell.rb
Instance Method Summary collapse
- #create_file(path, content) ⇒ Object
- #exec(command, use_sudo = false) ⇒ Object
-
#initialize ⇒ Shell
constructor
A new instance of Shell.
- #os ⇒ Object
- #print(message, type) ⇒ Object
Constructor Details
Instance Method Details
#create_file(path, content) ⇒ Object
36 37 38 39 40 |
# File 'lib/niman/shell.rb', line 36 def create_file(path, content) File.open(File.(path), 'w') do |handle| handle.write(content) end end |
#exec(command, use_sudo = false) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/niman/shell.rb', line 19 def exec(command, use_sudo=false) if use_sudo `sudo #{command}` else `#{command}` end end |
#os ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/niman/shell.rb', line 9 def os if @platform.linux? variant = @platform.linux_variant(-> (fn){ File.exists?(fn)}, -> (fn){ File.read(fn)}) variant[:family] else raise Niman::UnsupportedOSError end end |
#print(message, type) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/niman/shell.rb', line 27 def print(, type) case type when :error STDERR.puts else STDOUT.puts end end |