class WB::Shell

Public Class Methods

append(path) { |file| ... } click to toggle source
# File lib/wb/shell.rb, line 35
def self.append(path)
  file = File.open(path, "a")
  yield file
ensure
  $stdout.puts "Wrote to #{file.path}"
  file.close
end
create_file(path) click to toggle source
# File lib/wb/shell.rb, line 22
def self.create_file(path)
  mkdir_p_touch(path)
  path
end
getc() click to toggle source
# File lib/wb/shell.rb, line 31
def self.getc
  $stdin.getc
end
mkdir_p_touch(path) click to toggle source
# File lib/wb/shell.rb, line 12
def self.mkdir_p_touch(path)
  directories = File.dirname(path)
  filename = File.basename(path)
  unless File.exist?(directories)
    FileUtils.mkdir_p(directories)
  end
  FileUtils.touch(path)
  $stdout.puts "#{path} created"
end
open_file(path, editor: ENV["EDITOR"]) click to toggle source
# File lib/wb/shell.rb, line 27
def self.open_file(path, editor: ENV["EDITOR"])
  run(editor, path)
end
run(*commands) click to toggle source
# File lib/wb/shell.rb, line 7
def self.run(*commands)
  $stdout.puts commands.join(" ")
  system *commands
end