Module: Bundler::CLI::Common
Relationships & Source Files | |
Defined in: | lib/bundler/cli/common.rb |
Class Attribute Summary
- .clean_after_install? ⇒ Boolean readonly
Class Method Summary
- .ask_for_spec_from(specs)
- .configure_gem_version_promoter(definition, options)
- .ensure_all_gems_in_lockfile!(names, locked_gems = Bundler.locked_gems)
- .gem_not_found_message(missing_gem_name, alternatives)
- .output_post_install_messages(messages)
- .output_without_groups_message
- .patch_level_options(options)
- .print_post_install_message(name, msg)
- .select_spec(name, regex_match = nil)
- .without_groups_message
Class Attribute Details
.clean_after_install? ⇒ Boolean
(readonly)
[ GitHub ]
Class Method Details
.ask_for_spec_from(specs)
[ GitHub ]# File 'lib/bundler/cli/common.rb', line 51
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
.configure_gem_version_promoter(definition, options)
# File 'lib/bundler/cli/common.rb', line 81
def self.configure_gem_version_promoter(definition, ) patch_level = ( ) raise InvalidOption, "Provide only one of the following options: #{patch_level.join(", ")}" unless patch_level.length <= 1 definition.gem_version_promoter.tap do |gvp| gvp.level = patch_level.first || :major gvp.strict = [:strict] || ["update-strict"] end end
.ensure_all_gems_in_lockfile!(names, locked_gems = Bundler.locked_gems)
[ GitHub ]# File 'lib/bundler/cli/common.rb', line 74
def self.ensure_all_gems_in_lockfile!(names, locked_gems = Bundler.locked_gems) locked_names = locked_gems.specs.map(&:name) names.-(locked_names).each do |g| raise GemNotFound, (g, locked_names) end end
.gem_not_found_message(missing_gem_name, alternatives)
[ GitHub ]# File 'lib/bundler/cli/common.rb', line 65
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
.output_post_install_messages(messages)
[ GitHub ].output_without_groups_message
[ GitHub ].patch_level_options(options)
[ GitHub ]# File 'lib/bundler/cli/common.rb', line 90
def self. ( ) [:major, :minor, :patch].select {|v| .keys.include?(v.to_s) } end
.print_post_install_message(name, msg)
[ GitHub ].select_spec(name, regex_match = nil)
[ GitHub ]# File 'lib/bundler/cli/common.rb', line 30
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
[ GitHub ]# File 'lib/bundler/cli/common.rb', line 22
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