Sha256: 6d38a70dd758bfa76da8d50d051f87e6e1f4208f154ea7daa128a691fad32a10

Contents?: true

Size: 723 Bytes

Versions: 16

Compression:

Stored size: 723 Bytes

Contents

module Capistrano
  class Configuration
    class Question

      def initialize(env, key, default)
        @env, @key, @default = env, key, default
      end

      def call
        ask_question
        save_response
      end

      private
      attr_reader :env, :key, :default

      def ask_question
        $stdout.puts question
      end

      def save_response
        env.set(key, value)
      end

      def value
        if response.empty?
          default
        else
          response
        end
      end

      def response
        @response ||= $stdin.gets.chomp
      end

      def question
        I18n.t(:question, key: key, default_value: default, scope: :capistrano)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
capistrano-3.2.0 lib/capistrano/configuration/question.rb
capistrano-3.1.0 lib/capistrano/configuration/question.rb
capistrano-3.0.1 lib/capistrano/configuration/question.rb
capistrano-3.0.0 lib/capistrano/configuration/question.rb
capistrano-3.0.0.pre14 lib/capistrano/configuration/question.rb
capistrano-3.0.0.pre13 lib/capistrano/configuration/question.rb
capistrano-3.0.0.pre12 lib/capistrano/configuration/question.rb
capistrano-3.0.0.pre11 lib/capistrano/configuration/question.rb
capistrano-3.0.0.pre10 lib/capistrano/configuration/question.rb
capistrano-3.0.0.pre7 lib/capistrano/configuration/question.rb
capistrano-3.0.0.pre6 lib/capistrano/configuration/question.rb
capistrano-3.0.0.pre5 lib/capistrano/configuration/question.rb
capistrano-3.0.0.pre4 lib/capistrano/configuration/question.rb
capistrano-3.0.0.pre3 lib/capistrano/configuration/question.rb
capistrano-3.0.0.pre2 lib/capistrano/configuration/question.rb
capistrano-3.0.0.pre lib/capistrano/configuration/question.rb