Sha256: 9bf9f4df7db8ab0797f28319500f2d3edd791b3ef9552960a36aa53d5e2608e2
Contents?: true
Size: 670 Bytes
Versions: 11
Compression:
Stored size: 670 Bytes
Contents
module Overcommit # Encapsulates prompting for and fetching input from a user. class UserInput # @param io [IO] device to fetch input from def initialize(io) @io = io reopen_tty end # Get a string of input from the user (up to the next newline character). def get @io.gets end private # Git hooks are not interactive and will close STDIN by default. def reopen_tty # If the hook isn't interactive, we need to map STDIN to keyboard manually STDIN.reopen('/dev/tty') if STDIN.eof? rescue # rubocop:disable HandleExceptions # Happens in tests run with no console available end end end
Version data entries
11 entries across 11 versions & 1 rubygems