module Fog::Formatador

Fog::Formatador

Constants

INDENT_REGEX
PARSE_REGEX
STYLES

Public Class Methods

display_compact_table(hashes, keys = nil, &block) click to toggle source
# File lib/fog/formatador.rb, line 26
def self.display_compact_table(hashes, keys = nil, &block)
  ::Formatador.display_compact_table(hashes, keys, &block)
end
display_line(data) click to toggle source
# File lib/fog/formatador.rb, line 18
def self.display_line(data)
  ::Formatador.display_line(data)
end
display_lines(data) click to toggle source
# File lib/fog/formatador.rb, line 22
def self.display_lines(data)
  ::Formatador.display_lines(data)
end
display_table(hashes, keys = nil, &block) click to toggle source
# File lib/fog/formatador.rb, line 30
def self.display_table(hashes, keys = nil, &block)
  ::Formatador.display_table(hashes, keys, &block)
end
format(object, opts = { :include_nested => true }) click to toggle source
# File lib/fog/formatador.rb, line 12
def self.format(object, opts = { :include_nested => true })
  string = init_string(object)
  indent { string << object_string(object, opts) }
  string << "#{indentation}>"
end
formatador() click to toggle source
# File lib/fog/formatador.rb, line 8
def self.formatador
  Thread.current[:formatador] ||= ::Formatador.new
end
redisplay_progressbar(current, total, options = {}) click to toggle source
# File lib/fog/formatador.rb, line 34
def self.redisplay_progressbar(current, total, options = {})
  ::Formatador.redisplay_progressbar(current, total, options = {})
end

Private Class Methods

attribute_string(object) click to toggle source
# File lib/fog/formatador.rb, line 58
def self.attribute_string(object)
  return "" unless object.class.respond_to?(:attributes)
  if object.class.attributes.empty?
    ""
  else
    "#{indentation}#{object_attributes(object)}\n"
  end
end
indent(&block) click to toggle source
# File lib/fog/formatador.rb, line 40
def self.indent(&block)
  formatador.indent(&block)
end
indentation() click to toggle source
# File lib/fog/formatador.rb, line 44
def self.indentation
  formatador.indentation
end
init_string(object) click to toggle source
# File lib/fog/formatador.rb, line 48
def self.init_string(object)
  "#{indentation}<#{object.class.name}\n"
end
inspect_object(object) click to toggle source
# File lib/fog/formatador.rb, line 83
def self.inspect_object(object)
  return "" unless object.is_a?(Enumerable)
  object.map { |o| indentation + o.inspect }.join(", \n#{indentation}")
end
nested_objects_string(object) click to toggle source
# File lib/fog/formatador.rb, line 67
def self.nested_objects_string(object)
  nested = ""
  return nested if object.respond_to?(:empty) and object.empty?
  return nested unless object.is_a?(Enumerable)
  nested = "#{indentation}[\n"
  indent { nested << indentation + inspect_object(object) }
  nested << "#{indentation}\n#{indentation}]\n"
end
object_attributes(object) click to toggle source
# File lib/fog/formatador.rb, line 76
def self.object_attributes(object)
  attrs = object.class.attributes.map do |attr|
    "#{attr}=#{object.send(attr).inspect}"
  end
  attrs.join(",\n#{indentation}")
end
object_string(object, opts) click to toggle source
# File lib/fog/formatador.rb, line 52
def self.object_string(object, opts)
  string = "#{attribute_string(object)}"
  string << "#{nested_objects_string(object)}" if opts[:include_nested]
  string
end