1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

removed HighLine in favor of ruby's noecho

This commit is contained in:
Kai Kuchenbecker 2014-08-05 16:01:21 +02:00
parent 3e664b01f2
commit 5333e507ad
5 changed files with 17 additions and 43 deletions

View file

@ -14,8 +14,7 @@ https://github.com/capistrano/capistrano/compare/v3.2.1...HEAD
* Added tests for after/before hooks features (@juanibiapina, @miry)
* Improved the output of `cap --help`. (@mbrictson)
* Cucumber suite now runs on the latest version of Vagrant (@tpett)
* The `ask` method now supports the `echo: false` option. (@mbrictson)
* Capistrano now depends on the `highline` gem.
* The `ask` method now supports the `echo: false` option. (@mbrictson, @kaikuchn)
## `3.2.1`

View file

@ -28,7 +28,6 @@ eos
gem.add_dependency 'sshkit', '~> 1.3'
gem.add_dependency 'rake', '>= 10.0.0'
gem.add_dependency 'i18n'
gem.add_dependency 'highline'
gem.add_development_dependency 'rspec'
gem.add_development_dependency 'mocha'

View file

@ -1,7 +1,7 @@
require 'rake'
require 'sshkit'
require 'sshkit/dsl'
require 'highline'
require 'io/console'
Rake.application.options.trace = true

View file

@ -7,18 +7,22 @@ module Capistrano
end
def call
response = highline_ask(question) { |q| q.echo = echo? }
save_response(value_or_default(response))
ask_question
save_response
end
private
attr_reader :env, :key, :default, :options
def save_response(value)
env.set(key, value)
def ask_question
$stdout.print question
end
def value_or_default(response)
def save_response
env.set(key, value_or_default)
end
def value_or_default
if response.empty?
default
else
@ -26,6 +30,12 @@ module Capistrano
end
end
def response
return @response if defined? @response
return @response = $stdin.gets.chomp if echo?
@response = $stdin.noecho(&:gets).chomp
end
def question
I18n.t(:question, key: key, default_value: default, scope: :capistrano)
end
@ -33,12 +43,6 @@ module Capistrano
def echo?
(options || {}).fetch(:echo, true)
end
def highline_ask(question, &block)
# For compatibility, we call #to_s to unwrap HighLine::String and
# return a regular String.
HighLine.new.ask(question, &block).to_s
end
end
end
end

View file

@ -46,34 +46,6 @@ module Capistrano
env.expects(:set).with(key, branch)
question.call
end
end
describe 'highline behavior' do
let(:highline) { stub }
before do
question.expects(:highline_ask).yields(highline).returns("answer")
env.expects(:set).with(key, "answer")
end
context 'with no options' do
let(:options) { nil }
it 'passes echo: true to HighLine' do
highline.expects(:"echo=").with(true)
question.call
end
end
context 'with echo: false' do
let(:options) { { echo: false } }
it 'passes echo: false to HighLine' do
highline.expects(:"echo=").with(false)
question.call
end
end
end
end
end