summaryrefslogtreecommitdiff
path: root/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-22 23:08:05 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-22 23:08:05 +0000
commit7825e8363d4b2ccad8e2d3f5eeba9e26f6656911 (patch)
tree83cbcf419e0feeb2ab0fd063ed85e0776eb0081b /lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb
parent73bed0312895322e0fd18310e840356c8e6af812 (diff)
Postponing the Bundler merge.
I faced a big issue about Bundler with ruby core. I have no time to resolve it issue before 2.5 final release. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb')
-rw-r--r--lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb88
1 files changed, 0 insertions, 88 deletions
diff --git a/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb b/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb
deleted file mode 100644
index dd39cff35d..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb
+++ /dev/null
@@ -1,88 +0,0 @@
-begin
- require "readline"
-rescue LoadError
-end
-
-class Bundler::Thor
- module LineEditor
- class Readline < Basic
- def self.available?
- Object.const_defined?(:Readline)
- end
-
- def readline
- if echo?
- ::Readline.completion_append_character = nil
- # Ruby 1.8.7 does not allow Readline.completion_proc= to receive nil.
- if complete = completion_proc
- ::Readline.completion_proc = complete
- end
- ::Readline.readline(prompt, add_to_history?)
- else
- super
- end
- end
-
- private
-
- def add_to_history?
- options.fetch(:add_to_history, true)
- end
-
- def completion_proc
- if use_path_completion?
- proc { |text| PathCompletion.new(text).matches }
- elsif completion_options.any?
- proc do |text|
- completion_options.select { |option| option.start_with?(text) }
- end
- end
- end
-
- def completion_options
- options.fetch(:limited_to, [])
- end
-
- def use_path_completion?
- options.fetch(:path, false)
- end
-
- class PathCompletion
- attr_reader :text
- private :text
-
- def initialize(text)
- @text = text
- end
-
- def matches
- relative_matches
- end
-
- private
-
- def relative_matches
- absolute_matches.map { |path| path.sub(base_path, "") }
- end
-
- def absolute_matches
- Dir[glob_pattern].map do |path|
- if File.directory?(path)
- "#{path}/"
- else
- path
- end
- end
- end
-
- def glob_pattern
- "#{base_path}#{text}*"
- end
-
- def base_path
- "#{Dir.pwd}/"
- end
- end
- end
- end
-end