Class: DevSystem::BinShell

Inherits:
FileShell show all
Defined in:
lib/dev_system/sub/shell/shells/bin_shell.rb

Class Method Summary collapse

Methods inherited from FileShell

_raise_if_blank, _raise_if_not_exists, directory?, exist?, file?, gitkeep, size, touch

Methods inherited from Shell

cruby?, engine, jruby?, linux?, mac?, os, ruby_version, unix?, windows?

Methods inherited from Liza::Controller

color, inherited, on_connected

Methods inherited from Liza::Unit

const_missing, division, part, system, #system, test_class

Class Method Details

.read(path) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/dev_system/sub/shell/shells/bin_shell.rb', line 5

def self.read path
  log "Reading #{path}"
  _raise_if_blank path
  _raise_if_not_exists path

  File.binread path
end

.write(path, content, create_dir: nil) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/dev_system/sub/shell/shells/bin_shell.rb', line 13

def self.write path, content, create_dir: nil
  log "Writing #{content&.size.to_i} bytes (#{content.encoding}) to #{path}"
  _raise_if_blank path

  create_dir = get :create_dir if create_dir.nil?
  DevSystem::DirShell.create File.dirname path if create_dir
  
  File.binwrite path, content
end