Sha256: e7d8d4de5d5ea16f38f5d9f2ac6509e0e5de8c19b13bd60c4de242762f37becd

Contents?: true

Size: 820 Bytes

Versions: 9

Compression:

Stored size: 820 Bytes

Contents

module Shelly
  module Helpers
    def echo_disabled
      system "stty -echo"
      value = yield
      system "stty echo"
      value
    end

    def say_new_line
      say "\n"
    end

    # FIXME: errors should be printed on STDERR
    def say_error(message, options = {})
      options = {:with_exit => true}.merge(options)
      say  message, :red
      exit 1 if options[:with_exit]
    end

    def ask_for_email(options = {})
      options = {:guess_email => true}.merge(options)
      email_question = options[:guess_email] && !User.guess_email.blank? ? "Email (#{User.guess_email} - default):" : "Email:"
      email = ask(email_question)
      email = email.blank? ? User.guess_email : email
      return email if email.present?
      say_error "Email can't be blank, please try again"
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
shelly-0.0.26 lib/shelly/helpers.rb
shelly-0.0.21.pre5 lib/shelly/helpers.rb
shelly-0.0.25 lib/shelly/helpers.rb
shelly-0.0.24 lib/shelly/helpers.rb
shelly-0.0.23 lib/shelly/helpers.rb
shelly-0.0.22 lib/shelly/helpers.rb
shelly-0.0.21.pre3 lib/shelly/helpers.rb
shelly-0.0.21.pre2 lib/shelly/helpers.rb
shelly-0.0.21 lib/shelly/helpers.rb