Sha256: 034b44b3c1c1375df60add01d537d9b10c2f920eb80f46ce088c287e8607a79b

Contents?: true

Size: 1.98 KB

Versions: 7

Compression:

Stored size: 1.98 KB

Contents

require 'term/ansicolor'

namespace :bake do
  C = Term::ANSIColor

  desc 'Print the "ALL TESTS PASSED" message'
  task :ok do
    puts
    print [
      C.bold,
      C.red,     "*",
      C.yellow,  "*",
      C.green,   "*",
      C.blue,    "*",
      C.magenta, "*",
      C.green,   " ALL TESTS PASSED ",
      C.magenta, "*",
      C.blue,    "*",
      C.green,   "*",
      C.yellow,  "*",
      C.red,     "*",
      C.clear
    ].join
    puts
  end

  desc 'Print the "ALL TESTS PASSED" message WITH A SWEET RAINBOW!!!'
  task :ok_rainbow do
    title = "ALL TESTS PASSED"
    sement_size = %w[ - -- --- ----- ----------- ----- --- -- - ]
    rows = [
      [ :clear,  :clear,   :clear,   :clear,   :red,     :clear,   :clear,   :clear,   :clear  ],
      [ :clear,  :clear,   :clear,   :red,     :yellow,  :red,     :clear,   :clear,   :clear  ],
      [ :clear,  :clear,   :red,     :yellow,  :green,   :yellow,  :red,     :clear,   :clear  ],
      [ :clear,  :red,     :yellow,  :green,   :blue,    :green,   :yellow,  :red,     :clear  ],
      [ :red,    :yellow,  :green,   :blue,    :magenta, :blue,    :green,   :yellow,  :red    ],
      [ :yellow, :green,   :blue,    :magenta, :clear,   :magenta, :blue,    :green,   :yellow ],
      [ :green,  :blue,    :magenta, :clear,   :clear,   :clear,   :magenta, :blue,    :green  ],
      [ :blue,   :magenta, :text,    :text,    :text,    :text,    title,    :magenta, :blue   ],
    ]

    puts
    rows.each do |row|
      text_block_length = 0
      sement_size.zip(row).each do |size, colour|
        string = size.gsub('-',' ')
        case colour
        when :clear
          print C.clear(string)
        when :text
          text_block_length += size.length
        when String
          text_block_length += size.length
          print C.bold, C.green(colour.center(text_block_length)), C.clear
        else
          cmd = "on_#{colour}".to_sym
          print C.send(cmd, string)
        end
      end
      puts
    end
    puts C.reset
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rake-n-bake-2.0.1 tasks/ok.rake
rake-n-bake-2.0.0 tasks/ok.rake
rake-n-bake-1.4.3 tasks/ok.rake
rake-n-bake-1.4.2 tasks/ok.rake
rake-n-bake-1.4.1 tasks/ok.rake
rake-n-bake-1.4.0 tasks/ok.rake
rake-n-bake-1.3.3 tasks/ok.rake