Sha256: 5dac9dd80d1c788502788887eaf11b4b61da1bfa0aa4d8fd0a6b0135e352b177

Contents?: true

Size: 772 Bytes

Versions: 12

Compression:

Stored size: 772 Bytes

Contents

module Meroku
  # Has methods that are similar to but extended versions
  # of core ruby methods
  module Extensions
    # Get multipe inputs from user
    # Masks passwords if detected
    # Bypasses prompt when ENV variables present
    def self.mgets(names)
      names.map do |name|
        sgets(name)
      end
    end

    # single gets
    def self.sgets(name)
      print "#{name.to_s.capitalize}: "
      return env_sgets(name) if ENV['MEROKU_' + name.to_s.upcase]
      return secure_sgets if name.match?(/password/)
      STDIN.gets.chomp
    end

    # get from env variable
    def self.env_sgets(name)
      ENV['MEROKU_' + name.to_s.upcase]
    end

    # secure gets from stdin
    def self.secure_sgets
      STDIN.noecho(&:gets).chomp
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
meroku-2.0.22 lib/meroku/extensions.rb
meroku-2.0.21 lib/meroku/extensions.rb
meroku-2.0.20 lib/meroku/extensions.rb
meroku-2.0.19 lib/meroku/extensions.rb
meroku-2.0.18 lib/meroku/extensions.rb
meroku-2.0.17 lib/meroku/extensions.rb
meroku-2.0.16 lib/meroku/extensions.rb
meroku-2.0.14 lib/meroku/extensions.rb
meroku-2.0.13 lib/meroku/extensions.rb
meroku-2.0.11 lib/meroku/extensions.rb
meroku-2.0.10 lib/meroku/extensions.rb
meroku-2.0.9 lib/meroku/extensions.rb