Module: Meroku::Extensions

Defined in:
lib/meroku/extensions.rb

Overview

Has methods that are similar to but extended versions of core ruby methods

Class Method Summary collapse

Class Method Details

.env_sgets(name) ⇒ Object

get from env variable



23
24
25
# File 'lib/meroku/extensions.rb', line 23

def self.env_sgets(name)
  ENV['MEROKU_' + name.to_s.upcase]
end

.mgets(names) ⇒ Object

Get multipe inputs from user Masks passwords if detected Bypasses prompt when ENV variables present



8
9
10
11
12
# File 'lib/meroku/extensions.rb', line 8

def self.mgets(names)
  names.map do |name|
    sgets(name)
  end
end

.secure_sgetsObject

secure gets from stdin



28
29
30
# File 'lib/meroku/extensions.rb', line 28

def self.secure_sgets
  STDIN.noecho(&:gets).chomp
end

.sgets(name) ⇒ Object

single gets



15
16
17
18
19
20
# File 'lib/meroku/extensions.rb', line 15

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