From a3d5c6a38d8a468898a755b2616fd8b8f741c828 Mon Sep 17 00:00:00 2001 From: Tristan Morgan Date: Mon, 7 Sep 2020 09:21:38 +1000 Subject: [PATCH] Updates for added RuboCop checks. --- .rubocop.yml | 3 +++ .travis.yml | 2 +- lib/awskeyring/input.rb | 11 ++++++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 1ebabf1..f282079 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,6 +12,9 @@ Metrics/AbcSize: RSpec/MultipleExpectations: Enabled: false +RSpec/MultipleMemoizedHelpers: + Max: 8 + RSpec/ExampleLength: Enabled: false diff --git a/.travis.yml b/.travis.yml index 264a435..1d9b384 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ --- language: ruby os: osx -osx_image: xcode11 +osx_image: xcode12 rvm: - 2.6.3 - ruby-head diff --git a/lib/awskeyring/input.rb b/lib/awskeyring/input.rb index bfcb48b..28dda3f 100644 --- a/lib/awskeyring/input.rb +++ b/lib/awskeyring/input.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require 'io/console' - # Awskeyring Module, module Awskeyring # Input methods for Awskeyring @@ -15,18 +13,21 @@ def self.read_secret(prompt) end private_class_method def self.hide_input # rubocop:disable Metrics/MethodLength + # Lazy-load io/console since it is gem-ified as of 2.3 + require 'io/console' password = +'' loop do character = $stdin.getch break unless character - if ["\n", "\r"].include? character + case character + when "\n", "\r" puts '' break - elsif ["\b", "\u007f"].include? character + when "\b", "\u007f" password.chop! print "\b\e[P" - elsif character == "\u0003" + when "\u0003" exit 1 else print '*'