Class: DevSystem::DirShell

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

Class Method Summary collapse

Methods inherited from FileShell

_raise_if_blank, _raise_if_not_exists, directory?, file?, gitkeep, 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

.create(path, log_level: self.log_level) ⇒ Object

CUSTOM



20
21
22
23
24
25
# File 'lib/dev_system/sub/shell/shells/dir_shell.rb', line 20

def self.create path, log_level: self.log_level
  log log_level, "Creating directory at '#{path}'"
  _raise_if_blank path

  Pathname.new(path).mkpath
end

.exist?(path, log_level: self.log_level) ⇒ Boolean

OVERRIDES

Returns:

  • (Boolean)


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

def self.exist? path, log_level: self.log_level
  log log_level, "Checking if directory exists at '#{path}'"

  directory? path
end

.size(path, log_level: self.log_level) ⇒ Object



11
12
13
14
15
16
# File 'lib/dev_system/sub/shell/shells/dir_shell.rb', line 11

def self.size path, log_level: self.log_level
  log log_level, "Getting size of directory at '#{path}'"
  _raise_if_not_exists path

  Pathname.new(path).children.inject(0) { |sum, f| sum + f.size }
end