Skip to content

Commit

Permalink
(PDK-871) Relax dependencies on tty-* gems
Browse files Browse the repository at this point in the history
  • Loading branch information
rodjek committed Aug 14, 2019
1 parent ab5e290 commit 14fde38
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/pdk/cli/exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
require 'childprocess'
require 'English'
require 'tempfile'
require 'tty-spinner'
require 'tty-which'

require 'pdk/util'
require 'pdk/util/git'
require 'pdk/util/ruby_version'
require 'pdk/cli/util/spinner'

module PDK
module CLI
Expand Down
3 changes: 2 additions & 1 deletion lib/pdk/cli/exec/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
require 'childprocess'
require 'English'
require 'tempfile'
require 'tty-spinner'
require 'tty-which'

require 'pdk/util'
require 'pdk/util/git'
require 'pdk/util/ruby_version'
require 'pdk/cli/util/spinner'


module PDK
module CLI
Expand Down
2 changes: 1 addition & 1 deletion lib/pdk/cli/exec_group.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'tty-spinner'
require 'tty-which'

require 'pdk/util'
require 'pdk/cli/util/spinner'

module PDK
module CLI
Expand Down
4 changes: 3 additions & 1 deletion lib/pdk/cli/util/interview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module PDK
module CLI
module Util
class Interview < TTY::Prompt::AnswersCollector
READER = defined?(TTY::Reader) ? TTY::Reader : TTY::Prompt::Reader

def pastel
@pastel ||= Pastel.new
end
Expand Down Expand Up @@ -60,7 +62,7 @@ def run
@prompt.puts ''
end
@answers
rescue TTY::Prompt::Reader::InputInterrupt
rescue READER::InputInterrupt
nil
end
end
Expand Down
13 changes: 13 additions & 0 deletions lib/pdk/cli/util/spinner.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'tty-spinner'

require 'pdk/cli/util'

# Replace the built-in tty check in tty-spinner with our own implementation
# that allows us to mock the behaviour during acceptance tests.
module TTY
class Spinner
def tty?
PDK::CLI::Util.interactive?
end
end
end
6 changes: 3 additions & 3 deletions pdk.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency 'minitar', '~> 0.6.1'
spec.add_runtime_dependency 'net-ssh', '~> 4.2.0'
spec.add_runtime_dependency 'pathspec', '~> 0.2.1'
spec.add_runtime_dependency 'tty-prompt', '0.13.1'
spec.add_runtime_dependency 'tty-spinner', '0.5.0'
spec.add_runtime_dependency 'tty-which', '0.3.0'
spec.add_runtime_dependency 'tty-prompt', '~> 0.13'
spec.add_runtime_dependency 'tty-spinner', '~> 0.5'
spec.add_runtime_dependency 'tty-which', '~> 0.3'

# Analytics dependencies
spec.add_runtime_dependency 'concurrent-ruby', '~> 1.1.5'
Expand Down
8 changes: 8 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,11 @@
]
end
end

# Add method to StringIO needed for TTY::TestPrompt to work on tty-prompt >=
# 0.19 (see https://github.com/piotrmurach/tty-prompt/issues/104)
class StringIO
def wait_readable(*)
true
end
end

0 comments on commit 14fde38

Please sign in to comment.