RestoreBundledWith

Gem version Travis-CI Status yard docs

Restore BUNDLED WITH section in Gemfile.lock from git repository.

# Gemfile.lock
PATH
  remote: .
  specs:
(snip)

BUNDLED WITH
   1.10.4

Description

Bundler v1.10.0 or higher tracks Bundler version in lockfile. We should use latest Bundler, but sometimes we are afraid we have to use older Bundler. We use Different version of Bundler between a project and a local machine. In addition, Bundler v1.9.x removes BUNDLED WITH section. RestoreBundledWith solves these conflicts. RestoreBundledWith restores BUNDLED WITH section from git repository.

Example

Newer Bundler Case

$ cat Gemfile.lock
(snip)
  unicorn-worker-killer
  webmock

BUNDLED WITH
   1.10.2

Execute bundle update by Bundler v1.10.3.

$ bundle update
(update)

$ git diff
(snip)
@@ -291,4 +296,4 @@ DEPENDENCIES
   webmock

 BUNDLED WITH
-   1.10.2
+   1.10.3

Then, execute restore-bundled-with.

$ restore-bundled-with
(restore BUNDLED WITH section)

$ git diff
(no diff)

There is no diff, because this restores BUNDLED WITH from git repository.

Old Bundler (v1.9) Case

$ cat Gemfile.lock
(snip)
  unicorn-worker-killer
  webmock

BUNDLED WITH
   1.10.2

Execute bundle update by Bundler v1.9.9.

$ bundle update
(update)

$ git diff
(snip)
@@ -289,6 +299,3 @@ DEPENDENCIES
   unicorn
   unicorn-worker-killer
   webmock
-
-BUNDLED WITH
-   1.10.2

Then, execute restore-bundled-with.

$ restore-bundled-with
(restore BUNDLED WITH section)

$ git diff
(no diff)

There is no diff, because this restores BUNDLED WITH from git repository.

Call from Ruby script

system(*['bundle', 'update'])

# restore_bundled_with
lock_file_contents = File.read('Gemfile.lock')
lock = RestoreBundledWith::Lock.restore(lock_file_contents, 'Gemfile.lock')
File.write('Gemfile.lock', lock.body)

There is no diff, because this restores BUNDLED WITH from git repository.

Requirement

  • Git

Usage

Commands:
  restore-bundled-with delete          # Delete BUNDLED WITH section
  restore-bundled-with fetch           # Fetch BUNDLED WITH section
  restore-bundled-with help [COMMAND]  # Describe available commands or one specific command
  restore-bundled-with restore         # Restore BUNDLED WITH section in Gemfile.lock
  restore-bundled-with version         # Show the RestoreBundledWith version

Usage:
  restore-bundled-with restore

Options:
  [--data=DATA]
  [--file=FILE]
  [--lockfile=LOCKFILE]
                               # Default: Gemfile.lock
  [--ref=REF]
                               # Default: HEAD
  [--git-path=GIT_PATH]
                               # Default: .
  [--git-options=key:value]
  [--new-line=NEW_LINE]
                               # Default:
  [--debug], [--no-debug]
  [--verbose], [--no-verbose]

Restore BUNDLED WITH section in Gemfile.lock

Installation

Add this line to your application's Gemfile:

gem 'restore_bundled_with'

And then execute:

$ bundle

Or install it yourself as:

$ gem install restore_bundled_with

Changelog

CHANGELOG.md.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/packsaddle/ruby-restore_bundled_with. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.