Module: Storazzo::Common

Includes:
Colors
Included in:
GCS::Client, Media::AbstractRicDisk, Media::GcsBucket, Media::LocalFolder, RicDisk, RicDisk, RicDiskConfig, SearchEngine
Defined in:
lib/storazzo/common.rb

Constant Summary

Constants included from Colors

Storazzo::Colors::PREPEND_ME

Instance Method Summary collapse

Methods included from Colors

#azure, #blue, #deb2, #gray, #green, #orange, #pgreen, #pred, #purple, #pwhite, #pyellow, #red, #white, #yellow

Instance Method Details

#bug(s) ⇒ Object



64
65
66
# File 'lib/storazzo/common.rb', line 64

def bug(s)
  puts "[πŸ›] #{gray s}"
end

#deb(s) ⇒ Object



42
43
44
45
# File 'lib/storazzo/common.rb', line 42

def deb(s)
  # useless: put logic in _debug_true() # return if ENV['RUBYOPT'] == "-W0"
  puts "[DEBπŸ‘€] #{yellow(s)}" if _debug_true # $DEBUG
end

#err(str) ⇒ Object



60
61
62
# File 'lib/storazzo/common.rb', line 60

def err(str)
  puts "[ERRπŸ‘Ž] #{red(str)}" # β›”
end

#fatal(s) ⇒ Object



84
85
86
# File 'lib/storazzo/common.rb', line 84

def fatal(s)
  raise "[FπŸ’€TAL] #{red s}"
end

#if_deb?Boolean

this has a yield

Returns:

  • (Boolean)


48
49
50
51
52
53
54
# File 'lib/storazzo/common.rb', line 48

def if_deb?
  if _debug_true # $DEBUG
    deb '== yield START =='
    yield
    deb '== yield END =='
  end
end

#linux?Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/storazzo/common.rb', line 92

def linux?
  `uname`.chomp == 'Linux'
end

#mac?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/storazzo/common.rb', line 88

def mac?
  `uname`.chomp == 'Darwin'
end

#ppp(complex_object_to_colorize) ⇒ Object



75
76
77
78
79
80
81
82
# File 'lib/storazzo/common.rb', line 75

def ppp(complex_object_to_colorize)
  if defined?(Pry::ColorPrinter)
    Pry::ColorPrinter.pp(complex_object_to_colorize)
  else
    require 'pp'
    pp complex_object_to_colorize
  end
end

#pverbose(_is_verbose, str) ⇒ Object



68
69
70
71
72
73
# File 'lib/storazzo/common.rb', line 68

def pverbose(_is_verbose, str)
  # puts "[VπŸ“šRBπŸ’€SπŸ“š] #{gray str}"
  return if ENV['RUBYOPT'] == '-W0'

  puts "[πŸ¦‹πŸ›πŸπŸžπŸœπŸ•·πŸ•ΈπŸ¦‚πŸ¦—πŸ¦Ÿ] #{gray str}" # insects: http://xahlee.info/comp/unicode_insects.html
end

#slugify(string) ⇒ Object



96
97
98
# File 'lib/storazzo/common.rb', line 96

def slugify(string)
  string.to_s.downcase.strip.gsub(/\s+/, '_').gsub(/[^\w-]/, '')
end

#warn(s) ⇒ Object



56
57
58
# File 'lib/storazzo/common.rb', line 56

def warn(s)
  puts "[W⚠️RN] #{azure(s)}"
end