Sha256: fc120e57254e8dc23c9b2e27b33489234f4c9dcd35c4f661ca31309c2b932048

Contents?: true

Size: 871 Bytes

Versions: 39

Compression:

Stored size: 871 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, default)
        end
      end

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

    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
hobo_support-2.2.6 lib/generators/hobo_support/thor_shell.rb
hobo_support-2.2.5 lib/generators/hobo_support/thor_shell.rb
hobo_support-2.2.4 lib/generators/hobo_support/thor_shell.rb
hobo_support-2.2.3 lib/generators/hobo_support/thor_shell.rb
hobo_support-2.2.2 lib/generators/hobo_support/thor_shell.rb
hobo_support-2.2.1 lib/generators/hobo_support/thor_shell.rb
hobo_support-2.2.0 lib/generators/hobo_support/thor_shell.rb
hobo_support-2.1.2 lib/generators/hobo_support/thor_shell.rb
hobo_support-2.1.1 lib/generators/hobo_support/thor_shell.rb
hobo_support-2.1.0 lib/generators/hobo_support/thor_shell.rb
hobo_support-2.1.0.pre4 lib/generators/hobo_support/thor_shell.rb
hobo_support-2.1.0.pre3 lib/generators/hobo_support/thor_shell.rb
hobo_support-2.1.0.pre2 lib/generators/hobo_support/thor_shell.rb
hobo_support-2.1.0.pre1 lib/generators/hobo_support/thor_shell.rb
hobo_support-2.0.1 lib/generators/hobo_support/thor_shell.rb
hobo_support-2.0.0 lib/generators/hobo_support/thor_shell.rb
hobo_support-2.0.0.pre10 lib/generators/hobo_support/thor_shell.rb
hobo_support-2.0.0.pre9 lib/generators/hobo_support/thor_shell.rb
hobo_support-2.0.0.pre8 lib/generators/hobo_support/thor_shell.rb
hobo_support-1.3.3 lib/generators/hobo_support/thor_shell.rb