Module: SeedHelper::OutputFormatter
- Included in:
- SeedHelper
- Defined in:
- lib/seed_helper/output_formatter.rb
Instance Method Summary collapse
- #error(message, options = {}) ⇒ Object
- #message(message, options = {}) ⇒ Object
-
#output(message, options = {}) ⇒ Object
Outputs a message with a set of given options.
- #resource_already_exists(resource) ⇒ Object
- #special_message(*lines) ⇒ Object
- #success(message, options = {}) ⇒ Object
Instance Method Details
#error(message, options = {}) ⇒ Object
31 32 33 34 35 |
# File 'lib/seed_helper/output_formatter.rb', line 31 def error(, = {}) [:prefix] ||= " - " [:color] ||= :red output , end |
#message(message, options = {}) ⇒ Object
19 20 21 22 23 |
# File 'lib/seed_helper/output_formatter.rb', line 19 def (, = {}) [:prefix] ||= "*** " [:color] ||= :white output , end |
#output(message, options = {}) ⇒ Object
Outputs a message with a set of given options
14 15 16 17 |
# File 'lib/seed_helper/output_formatter.rb', line 14 def output(, = {}) [:color] ||= :white $stdout.puts "#{options[:prefix]}#{message}#{options[:suffix]}".send([:color]) end |
#resource_already_exists(resource) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/seed_helper/output_formatter.rb', line 37 def resource_already_exists(resource) = "#{resource} already exists" = {} [:prefix] ||= " > " [:color] ||= :cyan output(, ) end |
#special_message(*lines) ⇒ Object
46 47 48 49 |
# File 'lib/seed_helper/output_formatter.rb', line 46 def (*lines) $stdout.puts "" $stdout.puts lines.join("\n ").magenta end |
#success(message, options = {}) ⇒ Object
25 26 27 28 29 |
# File 'lib/seed_helper/output_formatter.rb', line 25 def success(, = {}) [:prefix] ||= " + " [:color] ||= :green output , end |