gitlab-org--gitlab-foss/lib/gitlab/utils.rb
2017-05-25 19:31:21 +08:00

33 lines
632 B
Ruby

module Gitlab
module Utils
extend self
# Run system command without outputting to stdout.
#
# @param cmd [Array<String>]
# @return [Boolean]
def system_silent(cmd)
Popen.popen(cmd).last.zero?
end
def force_utf8(str)
str.force_encoding(Encoding::UTF_8)
end
def to_boolean(value)
return value if [true, false].include?(value)
return true if value =~ /^(true|t|yes|y|1|on)$/i
return false if value =~ /^(false|f|no|n|0|off)$/i
nil
end
def boolean_to_yes_no(bool)
if bool
'Yes'
else
'No'
end
end
end
end