Sha256: dd67120bc323a2ce67f33e51f0f83e6f8b7491d1f4b6045bea320024aa67f760

Contents?: true

Size: 1.44 KB

Versions: 16

Compression:

Stored size: 1.44 KB

Contents

module Quorum
  module Helpers

    #
    # I18n flash helper. Set flash message based on key.
    #
    def set_flash_message(key, kind, options = {})
      options[:scope] = "quorum.#{controller_name}"
      options[:scope] << ".errors" if key.to_s == "error"
      options[:scope] << ".notices" if key.to_s == "notice"
      options[:scope] << ".alerts" if key.to_s == "alert"
      message = I18n.t("#{kind}", options)
      flash[key] = message if message.present?
    end

    #
    # Colorize console text.
    #
    module Colors
      ## Thanks to the Rspec team for this code! ##

      #
      # Main color method.
      #
      def color(text, color_code)
        "#{color_code}#{text}\e[0m"
      end

      #
      # Bold
      #
      def bold(text)
        color(text, "\e[1m")
      end

      #
      # White
      #
      def white(text)
        color(text, "\e[37m")
      end

      #
      # Green
      #
      def green(text)
        color(text, "\e[32m")
      end

      #
      # Red
      #
      def red(text)
        color(text, "\e[31m")
      end

      #
      # Magenta
      #
      def magenta(text)
        color(text, "\e[35m")
      end

      #
      # Yellow
      #
      def yellow(text)
        color(text, "\e[33m")
      end

      #
      # Blue
      #
      def blue(text)
        color(text, "\e[34m")
      end

      #
      # Grey
      #
      def grey(text)
        color(text, "\e[90m")
      end
    end

  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
quorum-0.8.2 lib/quorum/helpers.rb
quorum-0.8.1 lib/quorum/helpers.rb
quorum-0.8.0 lib/quorum/helpers.rb
quorum-0.7.1 lib/quorum/helpers.rb
quorum-0.7.0 lib/quorum/helpers.rb
quorum-0.6.0 lib/quorum/helpers.rb
quorum-0.5.2 lib/quorum/helpers.rb
quorum-0.5.1 lib/quorum/helpers.rb
quorum-0.5.0 lib/quorum/helpers.rb
quorum-0.4.0 lib/quorum/helpers.rb
quorum-0.3.3 lib/quorum/helpers.rb
quorum-0.3.2 lib/quorum/helpers.rb
quorum-0.3.1 lib/quorum/helpers.rb
quorum-0.3.0 lib/quorum/helpers.rb
quorum-0.2.1 lib/quorum/helpers.rb
quorum-0.2.0 lib/quorum/helpers.rb