Sha256: 7eaadf3af5e96739f7a626cba330628efbf4ae551d458a39be8b7f1ebd5d0d06

Contents?: true

Size: 862 Bytes

Versions: 10

Compression:

Stored size: 862 Bytes

Contents

module Generators
  module HoboSupport
    module ThorShell

      PREFIX = '  => '

      private

      def ask(statement, default='', color=:magenta)
        result = super(statement, color)
        result = default if result.blank?
        say PREFIX + result.inspect
        result
      end

      def yes_no?(statement, color=:magenta)
        result = choose(statement + ' [y|n]', /^(y|n)$/i)
        result == 'y' ? true : false
      end

      def choose(prompt, format, default=nil)
        choice = ask prompt, default
        case
        when choice =~ format
          choice
        when choice.blank? && !default.blank?
          default
        else
          say 'Unknown choice! ', :red
          choose(prompt, format)
        end
      end

      def say_title(title)
        say "\n #{title} \n", "\e[37;44m"
      end

    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
hobo_support-1.3.0.RC2 lib/generators/hobo_support/thor_shell.rb
hobo_support-1.3.0.RC1 lib/generators/hobo_support/thor_shell.rb
hobo_support-1.3.0.RC lib/generators/hobo_support/thor_shell.rb
hobo_support-1.3.0.pre31 lib/generators/hobo_support/thor_shell.rb
hobo_support-1.3.0.pre29 lib/generators/hobo_support/thor_shell.rb
hobo_support-1.3.0.pre28 lib/generators/hobo_support/thor_shell.rb
hobo_support-1.3.0.pre27 lib/generators/hobo_support/thor_shell.rb
hobo_support-1.3.0.pre26 lib/generators/hobo_support/thor_shell.rb
hobo_support-1.3.0.pre25 lib/generators/hobo_support/thor_shell.rb
hobo_support-1.3.0.pre24 lib/generators/hobo_support/thor_shell.rb