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