Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PDK-871) Relax dependencies on tty-* gems #730

Merged
merged 1 commit into from
Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion lib/pdk/cli/exec/command.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
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
1 change: 1 addition & 0 deletions lib/pdk/util/ruby_version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'pdk/util'
require 'forwardable'

module PDK
module Util
Expand Down
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