lib/bundler/patch/cli.rb in bundler-patch-1.1.0.pre2 vs lib/bundler/patch/cli.rb in bundler-patch-1.1.0.pre3
- old
+ new
@@ -61,14 +61,12 @@
end
def patch(options={})
Bundler.ui = Bundler::UI::Shell.new
- normalize_options(options)
+ options = Bundler::Patch::CLI::Options.new.normalize_options(options)
- process_gemfile_option(options)
-
if options[:use_target_ruby] # TODO: && different_ruby_found
tb = options[:target]
ruby = tb.ruby_bin_exe
tb.install_bundler_patch_in_target
bundler_patch = File.join(tb.ruby_bin, 'bundler-patch') # uses 'latest' bundler-patch, which can work after we've installed ours.
@@ -82,34 +80,10 @@
patch_gems(options)
end
end
- def normalize_options(options)
- map = {:prefer_minimal => :minimal, :strict_updates => :strict, :minor_preferred => :minor}
- {}.tap do |target|
- options.each_pair do |k, v|
- new_key = k.to_s.gsub('-', '_').to_sym
- new_key = map[new_key] || new_key
- target[new_key] = v
- end
- end
- end
-
private
-
- def process_gemfile_option(options)
- # copy/pasta from Bundler
- custom_gemfile = options[:gemfile] || Bundler.settings[:gemfile]
- if custom_gemfile && !custom_gemfile.empty?
- ENV['BUNDLE_GEMFILE'] = File.expand_path(custom_gemfile)
- dir, gemfile = [File.dirname(custom_gemfile), File.basename(custom_gemfile)]
- target_bundle = TargetBundle.new(dir: dir, gemfile: gemfile)
- options[:target] = target_bundle
- else
- options[:target] = TargetBundle.new
- end
- end
def list(options)
gem_patches = AdvisoryConsolidator.new(options).vulnerable_gems
if gem_patches.empty?