module SeedHelper::OutputFormatter
Public Instance Methods
error(message, options = {})
click to toggle source
# File lib/seed_helper/output_formatter.rb, line 31 def error(message, options = {}) options[:prefix] ||= " - " options[:color] ||= :red output message, options end
message(message, options = {})
click to toggle source
# File lib/seed_helper/output_formatter.rb, line 19 def message(message, options = {}) options[:prefix] ||= "*** " options[:color] ||= :white output message, options end
output(message, options = {})
click to toggle source
Outputs a message with a set of given options
@param [String] message: The message to format @param [Hash] options: A hash of options to apply to the string @option options [String] prefix: A prefix for the message. EG: “–> message” @option options [String] color: A Symbol representing the color from the Colored gem. See: Colored.colors @option options [String] suffix: A String suffix for the message. EG: “message !!!”
@example Print out an error message
SeedHelper.output "Some error", {:prefix => "!!! ", :color => :red} # outputs "!!! Some error" in red text
# File lib/seed_helper/output_formatter.rb, line 14 def output(message, options = {}) options[:color] ||= :white $stdout.puts "#{options[:prefix]}#{message}#{options[:suffix]}".send(options[:color]) end
resource_already_exists(resource)
click to toggle source
# File lib/seed_helper/output_formatter.rb, line 37 def resource_already_exists(resource) message = "#{resource} already exists" options = {} options[:prefix] ||= " > " options[:color] ||= :cyan output(message, options) end
special_message(*lines)
click to toggle source
# File lib/seed_helper/output_formatter.rb, line 46 def special_message(*lines) $stdout.puts "" $stdout.puts lines.join("\n ").magenta end
success(message, options = {})
click to toggle source
# File lib/seed_helper/output_formatter.rb, line 25 def success(message, options = {}) options[:prefix] ||= " + " options[:color] ||= :green output message, options end