Module: Spawngebob::Utils
- Includes:
- Constants
- Defined in:
- lib/spawngebob/utils.rb
Constant Summary
Constants included
from Constants
Constants::BASE_CONFIG_PATH, Constants::CONFIG_FILE, Constants::NGINX_CONF, Constants::NGINX_CONFD_PATH, Constants::NGINX_CONF_PATH, Constants::NGINX_DEFAULTS, Constants::NGINX_DIRS, Constants::NGINX_HTTP_LOCATION_TEMPLATE, Constants::NGINX_PATH, Constants::NGINX_PID, Constants::NGINX_SERVER_TEMPLATE, Constants::NGINX_SSL_LOCATION_TEMPLATE, Constants::NGINX_SSL_SERVER_TEMPLATE, Constants::NGINX_UPSTREAM_TEMPLATE, Constants::SCRIPT_DIR
Class Method Summary
collapse
Class Method Details
.error(message, code = -1)) ⇒ Object
20
21
22
23
|
# File 'lib/spawngebob/utils.rb', line 20
def self.error(message, code=-1)
say("\033[31merror: #{message}")
exit(code)
end
|
.say(message, subitem = false) ⇒ Object
7
8
9
|
# File 'lib/spawngebob/utils.rb', line 7
def self.say(message, subitem = false)
puts "#{subitem ? " ->" : "--"} #{message}"
end
|
.say_with_time(message) ⇒ Object
11
12
13
14
15
16
17
18
|
# File 'lib/spawngebob/utils.rb', line 11
def self.say_with_time(message)
say(message)
result = nil
time = Benchmark.measure { result = yield }
say "%.4fs" % time.real, :subitem
say("#{result} rows", :subitem) if result.is_a?(Integer)
result
end
|