Project

tweezer

0.0
No commit activity in last 3 years
No release in over 3 years
Tweezer is a CLI to add, remove, and edit Gemfile dependencies in an automated way
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.10
~> 10.0
~> 3.3
~> 1.2
~> 0.34

Runtime

~> 1.10
~> 2.2
~> 0.19
~> 0.2
 Project Readme

Tweezer Build Status Test Coverage

Tweezer is a CLI tool for editing your Gemfile that goes to great extents to ensure the Gemfile remains both valid and idiomatic

Tweezer is currently usable, but should be considered a WIP in that it's reasonably untested and might muck up your Gemfile in any number of nasty ways (which is irrelevant if your Gemfile is in source control (and if it's not what're you doing with your life)), and that it doesn't actually provide for the use-case that I started writing it for yet.

Installation

gem install tweezer

Usage

For full documentation, run tweezer help and tweezer help COMMAND.

Adding new gems - tweezer add

tweezer add rake # Adds rake to the end of the default group in your Gemfile

tweezer add rake '~> 0.9.6' # Adds rake ~> 0.9.6 to the end of the default group
                            # in your Gemfile

tweezer add rspec --group test # Adds rspec to the 'test' group in your gemfile.
                               # Tweezer will do this in a way that results in
                               # the most idiomatic possible Gemfile

Changing attributes of existing gems - tweezer alter

tweezer alter rake -v '~> 10.4.2' # Changes rake in the gemfile to be pinned to
                                  # 10.4.2

tweezer alter rake -p '~/code/rake' # Changes rake in the gemfile to be
                                    # installed from `~/code/rake`

Why?

Gemrat exists and is pretty cool, but has two problems with it that prevent it from serving my use-case:

  1. It uses naïve string-manipulation to edit the Gemfile. Tweezer, by comparison, uses the parser and unparser gems to do an actual modification of the AST of your gemfile.

  2. Gemrat only really satisfies the use-case of "install and save to Gemfile", covered by tools like npm install --save for other languages. Tweezer, by comparison, either allows or will allow much more advanced modifications of the gemfile, including adding gems to groups, deleting groups, modifying versions, sources, etc. of gems, and more.

My original use-case was for local-development of a gem that was used by one of my apps, which required rather frequently switching my gemfile between gem 'mygem', '~> 1.0.0' and gem 'mygem', path: '/path/to/local/gem'. I wanted to automate that using a mapping in my editor, and here we are.