Sha256: 9418d5c0093718a136ae001eef3492837129313f9e2b66b4f137729684b097df

Contents?: true

Size: 772 Bytes

Versions: 6

Compression:

Stored size: 772 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

    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

6 entries across 6 versions & 1 rubygems

Version Path
shelly-0.0.20 lib/shelly/helpers.rb
shelly-0.0.21.pre lib/shelly/helpers.rb
shelly-0.0.20.pre lib/shelly/helpers.rb
shelly-0.0.19 lib/shelly/helpers.rb
shelly-0.0.18 lib/shelly/helpers.rb
shelly-0.0.17 lib/shelly/helpers.rb