class Niman::Shell
Public Class Methods
new()
click to toggle source
# File lib/niman/shell.rb, line 5 def initialize @platform = Niman::Platform.new(RUBY_PLATFORM) end
Public Instance Methods
create_file(path, content)
click to toggle source
# File lib/niman/shell.rb, line 36 def create_file(path, content) File.open(File.expand_path(path), 'w') do |handle| handle.write(content) end end
exec(command, use_sudo=false)
click to toggle source
# File lib/niman/shell.rb, line 19 def exec(command, use_sudo=false) if use_sudo `sudo #{command}` else `#{command}` end end
os()
click to toggle source
# 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)
click to toggle source
# File lib/niman/shell.rb, line 27 def print(message, type) case type when :error STDERR.puts message else STDOUT.puts message end end