Skip to content

Instantly share code, notes, and snippets.

@frank-west-iii
Last active October 6, 2016 04:17
Show Gist options
  • Save frank-west-iii/14cd3ea59ab97001be7350e207500fd6 to your computer and use it in GitHub Desktop.
Save frank-west-iii/14cd3ea59ab97001be7350e207500fd6 to your computer and use it in GitHub Desktop.
Bundle Commands

bundle console

Allows you to run an irb console with the current bundle environment loaded

$ irb
irb > unit = Unit.new("1 mm")
NameError: uninitialized constant Unit
        from (irb):1
        from /Users/frank/.rubies/ruby-2.3.1/bin/irb:11:in `<main>'
        
$ bundle console
irb > unit = Unit.new("1 mm")
1 mm

bundle inject [GEM] [VERSION]

Adds the gem to the Gemfile and bundle installs in one command

$ > bundle inject 'money' '> 0'

Fetching gem metadata from https://rubygems.org/.............
Fetching version metadata from https://rubygems.org/.
Resolving dependencies...
Added to Gemfile:
  money (> 0)

bundle outdated

Lists outdated gems from your Gemfile.lock

$ bundle outdated

Outdated gems included in the bundle:
  * ruby-units (newest 2.0.1, installed 2.0.0) in group "default"

bundle viz

Generates a visual dependency graph

$ bundle viz

/Users/frank/code/bundler/gem_graph.png

$ open gem_graph.png

bundle show

Lists all gems in your current bundle environment

$ bundle show

Gems included by the bundle:
  * bundler (1.13.1)
  * i18n (0.7.0)
  * money (6.7.1)
  * ruby-units (2.0.0)
  * sixarm_ruby_unaccent (1.1.1)

bundle show --paths

Lists out the gems with the paths

$ bundle show --paths

/Users/frank/.gem/ruby/2.3.1/gems/bundler-1.13.1
/Users/frank/.gem/ruby/2.3.1/gems/i18n-0.7.0
/Users/frank/.gem/ruby/2.3.1/gems/money-6.7.1
/Users/frank/.gem/ruby/2.3.1/gems/ruby-units-2.0.0
/Users/frank/.gem/ruby/2.3.1/gems/sixarm_ruby_unaccent-1.1.1

bundle open

Opens the gem in your set editor

$ export EDITOR=vim
$ bundle open money

# Do some work in the gem like puts statements

Now clean up after yourself

$ gem pristine money

Restoring gems to pristine condition...
Please note the following API changes in Money version 6

 - Money#amount, Money#dollars methods now return instances of BigDecimal (rather than Float).

Please read the migration notes at https://github.com/RubyMoney/money#migration-notes
and choose the migration that best suits your application.

Test responsibly :-)
Restored money-6.7.1

bundle gem [GEMNAME]

Creates a new gem project

$ bundle gem joe-sucks

bundle gem my-awesome-gem
Creating gem 'my-awesome-gem'...
Do you want to generate tests with your gem?
Type 'rspec' or 'minitest' to generate those test files now and in the future. rspec/minitest/(none): rspec
Do you want to license your code permissively under the MIT license?
This means that any other developer or company will be legally allowed to use your code for free as long as they admit you created it. You can read more about the MIT license at http://choosealicense.com/licenses/mit. y/(n): y
MIT License enabled in config
Do you want to include a code of conduct in gems you generate?
Codes of conduct can increase contributions to your project by contributors who prefer collaborative, safe spaces. You can read more about the code of conduct at contributor-covenant.org. Having a code of conduct means agreeing to the responsibility of enforcing it, so be sure that you are prepared to do that. Be sure that your email address is specified as a contact in the generated code of conduct so that people know who to contact in case of a violation. For suggestions about how to enforce codes of conduct, see http://bit.ly/coc-enforcement. y/(n): y
Code of conduct enabled in config
Creating gem 'joe-sucks'...
MIT License enabled in config
Code of conduct enabled in config
      create  joe-sucks/Gemfile
      create  joe-sucks/.gitignore
      create  joe-sucks/lib/joe/sucks.rb
      create  joe-sucks/lib/joe/sucks/version.rb
      create  joe-sucks/joe-sucks.gemspec
      create  joe-sucks/Rakefile
      create  joe-sucks/README.md
      create  joe-sucks/bin/console
      create  joe-sucks/bin/setup
      create  joe-sucks/.travis.yml
      create  joe-sucks/.rspec
      create  joe-sucks/spec/spec_helper.rb
      create  joe-sucks/spec/joe/sucks_spec.rb
      create  joe-sucks/LICENSE.txt
      create  joe-sucks/CODE_OF_CONDUCT.md
Initializing git repo in /Users/frank/code/bundler/joe-sucks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment