Module: Bundler::CLI::Common
- Defined in:
- lib/bundler/cli/common.rb
Class Method Summary collapse
- .ask_for_spec_from(specs) ⇒ Object
- .gem_not_found_message(missing_gem_name, alternatives) ⇒ Object
- .select_spec(name, regex_match = nil) ⇒ Object
- .without_groups_message ⇒ Object
Class Method Details
.ask_for_spec_from(specs) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/bundler/cli/common.rb', line 32 def self.ask_for_spec_from(specs) if !$stdout.tty? && ENV['BUNDLE_SPEC_RUN'].nil? raise GemNotFound, (name, Bundler.definition.dependencies) end specs.each_with_index do |spec, index| Bundler.ui.info "#{index.succ} : #{spec.name}", true end Bundler.ui.info '0 : - exit -', true num = Bundler.ui.ask('> ').to_i num > 0 ? specs[num - 1] : nil end |
.gem_not_found_message(missing_gem_name, alternatives) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/bundler/cli/common.rb', line 46 def self.(missing_gem_name, alternatives) require 'bundler/similarity_detector' = "Could not find gem '#{missing_gem_name}'." alternate_names = alternatives.map { |a| a.respond_to?(:name) ? a.name : a } suggestions = SimilarityDetector.new(alternate_names).similar_word_list(missing_gem_name) += "\nDid you mean #{suggestions}?" if suggestions end |
.select_spec(name, regex_match = nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/bundler/cli/common.rb', line 11 def self.select_spec(name, regex_match = nil) specs = [] regexp = Regexp.new(name) if regex_match Bundler.definition.specs.each do |spec| return spec if spec.name == name specs << spec if regexp && spec.name =~ regexp end case specs.count when 0 raise GemNotFound, (name, Bundler.definition.dependencies) when 1 specs.first else ask_for_spec_from(specs) end rescue RegexpError raise GemNotFound, (name, Bundler.definition.dependencies) end |
.without_groups_message ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/bundler/cli/common.rb', line 3 def self. groups = Bundler.settings.without group_list = [groups[0...-1].join(", "), groups[-1..-1]]. reject{|s| s.to_s.empty? }.join(" and ") group_str = (groups.size == 1) ? "group" : "groups" "Gems in the #{group_str} #{group_list} were not installed." end |