module Tr3llo::Utils

Constants

COLOR
TRELLO_LABEL_COLOR

Public Instance Methods

assert_string!(data, message) click to toggle source
# File lib/3llo/utils.rb, line 29
def assert_string!(data, message)
  raise InvalidArgumentError.new(message) unless data.is_a?(String)
end
build_req_path(path, extra_params = {}) click to toggle source
# File lib/3llo/utils.rb, line 61
def build_req_path(path, extra_params = {})
  params =
    {
      "key" => Application.fetch_configuration!().api_key,
      "token" => Application.fetch_configuration!().api_token
    }.merge(extra_params)

  [path, URI.encode_www_form(params)].join("?")
end
deprecate!(message) click to toggle source
# File lib/3llo/utils.rb, line 37
def deprecate!(message)
  interface = Application.fetch_interface!()

  interface.puts(Utils.paint("DEPRECATED: #{message}", "yellow"))
end
format_bold(string) click to toggle source
# File lib/3llo/utils.rb, line 49
def format_bold(string)
  "\e[1m#{string}\e[0m"
end
format_dim(string) click to toggle source
# File lib/3llo/utils.rb, line 53
def format_dim(string)
  "\e[2m#{string}\e[0m"
end
format_highlight(string) click to toggle source
# File lib/3llo/utils.rb, line 57
def format_highlight(string)
  paint(string, "yellow")
end
format_key_tag(id, shortcut) click to toggle source
# File lib/3llo/utils.rb, line 22
def format_key_tag(id, shortcut)
  formatted_shortcut = Utils.format_highlight(Entities::SHORTCUT_PREFIX + shortcut)
  formatted_id = Utils.paint(id, "blue")

  "[#{formatted_id} #{formatted_shortcut}]"
end
format_user(user) click to toggle source
# File lib/3llo/utils.rb, line 33
def format_user(user)
  Utils.paint("@" + user.username, "blue")
end
paint(string, color) click to toggle source
# File lib/3llo/utils.rb, line 43
def paint(string, color)
  code = COLOR.fetch(color)

  "\e[#{code}m#{string}\e[0m"
end
require_directory(glob) click to toggle source
# File lib/3llo/utils.rb, line 71
def require_directory(glob)
  Dir.glob(glob).each do |file|
    require file
  end
end