diff options
author | Agrim Mittal <agrimmittal97@gmail.com> | 2018-06-17 15:17:21 +0530 |
---|---|---|
committer | Agrim Mittal <agrimmittal97@gmail.com> | 2018-06-28 15:35:17 +0530 |
commit | e0c0c4b696c64b42729173922703ab7e75163a8a (patch) | |
tree | 37ea5248aec2f7d028f7a43e968492442c490379 | |
parent | b8d0e5c1b0b55cf7cb34095fbc7ec0cd81d30126 (diff) | |
download | bundler-e0c0c4b696c64b42729173922703ab7e75163a8a.tar.gz |
Remove necessary comments and update documentation
-rw-r--r-- | lib/bundler/cli.rb | 4 | ||||
-rw-r--r-- | lib/bundler/cli/remove.rb | 1 | ||||
-rw-r--r-- | lib/bundler/injector.rb | 9 | ||||
-rw-r--r-- | man/bundle-remove.ronn | 6 |
4 files changed, 5 insertions, 15 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index ef07889c50..0f19638e45 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -168,10 +168,10 @@ module Bundler desc "remove [GEMS] [OPTIONS]", "Removes the gem from the Gemfile" long_desc <<-D - Removes the specified gems from the Gemfile in the current directory. If a gem is not found, Bundler prints a error message and if gem could not be removed due to any reason Bundler displays warning. + Removes the specified gems from the Gemfile. If the gem is not found, Bundler prints a error message and if gem could not be removed due to any reason Bundler will display a warning. D method_option "install", :type => :boolean, :banner => - "Runs 'bundle install' after removing the gems from the gemfile" + "Runs 'bundle install' after removing the gems from the Gemfile" def remove(*gems) require "bundler/cli/remove" Remove.new(gems, options).run diff --git a/lib/bundler/cli/remove.rb b/lib/bundler/cli/remove.rb index eb164a030b..cd6a2cec28 100644 --- a/lib/bundler/cli/remove.rb +++ b/lib/bundler/cli/remove.rb @@ -10,7 +10,6 @@ module Bundler def run raise InvalidOption, "Please specify gems to remove." if @gems.empty? - # remove requested gems Injector.remove(@gems, {}) Installer.install(Bundler.root, Bundler.definition) if @options["install"] diff --git a/lib/bundler/injector.rb b/lib/bundler/injector.rb index 7ce06c2873..d8f283aa68 100644 --- a/lib/bundler/injector.rb +++ b/lib/bundler/injector.rb @@ -123,28 +123,22 @@ module Bundler # evalutes a gemfile to remove the specified gem # from it. def remove_deps(gemfile_path) - # get initial snap shot of the gemfile initial_gemfile = IO.readlines(gemfile_path) - # inform user of the the gemfile currently - # being evaluated Bundler.ui.info "Removing gems from #{gemfile_path}" # evaluate the Gemfile we have builder = Dsl.new builder.eval_gemfile(gemfile_path) - # remove gems from dependencies removed_deps = remove_gems_from_dependencies(builder, @deps, gemfile_path) # abort the opertion if no gems were removed # no need to operate on gemfile furthur return [] if removed_deps.empty? - # gemfile after removing requested gems cleaned_gemfile = remove_gems_from_gemfile(@deps, gemfile_path) - # write the new gemfile write_to_gemfile(gemfile_path, cleaned_gemfile) # check for errors @@ -179,7 +173,6 @@ module Bundler # @param [Array] gems Array of names of gems to be removed. # @param [Pathname] gemfile_path The Gemfile from which to remove dependencies. def remove_gems_from_gemfile(gems, gemfile_path) - # store patterns of all gems to be removed patterns = /gem\s+(['"])#{Regexp.union(gems)}\1|gem\s*\((['"])#{Regexp.union(gems)}\2\)/ # remove lines which match the regex @@ -193,7 +186,6 @@ module Bundler end end - # remove any empty (and nested) blocks %w[group source env install_if].each {|block| remove_nested_blocks(new_gemfile, block) } new_gemfile.join.chomp @@ -251,7 +243,6 @@ module Bundler # record gems which could not be removed due to some reasons errored_deps = builder.dependencies.select {|d| d.gemfile == gemfile_path } & removed_deps.select {|d| d.gemfile == gemfile_path } - # warn user regarding those gems show_warning "#{errored_deps.map(&:name).join(", ")} could not be removed." unless errored_deps.empty? # return actual removed dependencies diff --git a/man/bundle-remove.ronn b/man/bundle-remove.ronn index da86316f22..f1ad41938e 100644 --- a/man/bundle-remove.ronn +++ b/man/bundle-remove.ronn @@ -7,14 +7,14 @@ bundle-remove(1) -- Removes gem specified in Gemfile ## DESCRIPTION -Removes a set of specified gems from the Gemfile or if needed from the bundle itself. +Removes a set of specified gems from the Gemfile or if needed runs `bundle install` and removes them from bundle as well. If any gem specified to be removed does not exist the in Gemfile, Bundler prints error message. -If gem could not be removed due to any reason Bundler warns the user. +If the gem could not be removed due to any reason, Bundler warns the user. ## OPTIONS * `--install`: - Runs 'bundle install' after removing the gems from the gemfile. + Runs 'bundle install' after removing the gems from the gemfile. This option sync the lockfile. Example: |