tweezer 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/README.md +52 -0
- data/lib/tweezer/gemfile.rb +10 -2
- data/lib/tweezer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OTgwOTUyZTM1ZmY3M2Y5MTdiZjU1NTgwOTA5MjYxZmY1NzQwNWFmOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NWIzZjczZGZjNzUyNmVmY2E0NmMyNTcxNzQ1YzU4YTM1Y2U5NGRjZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTUwNzFhZWQxZjQ3MGMxN2IzY2NlODAxYzAxZGIzZWI2MDUyM2E4YzNjNzhj
|
10
|
+
NDg2MWI0NGUwYmRkNjg1NjhmNTdjYWY2OGVlMjIxNWUyZTIwYTQ0YWFhNGJk
|
11
|
+
M2MwODY5ODg0NzY3MWVmOTVlNmJjMzc4ODE5ZTQ0MDQ1OTM0MzI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjMyZDVjYTJlYWRmODRiNzhmY2Q3YzZlNTRlZjlmZDkwNTFjYzBmOWZhYTRl
|
14
|
+
MTY4YTA1YzVjMTU0NmViODRlODhkZmNkMDZlMjQwNDY2MDM5OTFmZmRjNWE0
|
15
|
+
NGJkNDhjZjM2MzM5NmEzNmUwN2IwNmY0OGMzZjhjNWExNDA0ZDM=
|
data/README.md
CHANGED
@@ -1 +1,53 @@
|
|
1
1
|
# Tweezer [](https://travis-ci.org/glittershark/tweezer)
|
2
|
+
|
3
|
+
**Tweezer** is a CLI tool for editing your Gemfile.
|
4
|
+
|
5
|
+
Tweezer is currently usable, but should be considered a WIP in that it's
|
6
|
+
reasonably untested and might muck up your Gemfile in any number of nasty ways
|
7
|
+
(which is irrelevant if your Gemfile is in source control (and if it's not
|
8
|
+
what're you doing with your life)), and that it doesn't actually provide for the
|
9
|
+
use-case that I started writing it for yet.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
```sh
|
14
|
+
gem install tweezer
|
15
|
+
```
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
```sh
|
20
|
+
tweezer add rake # Adds rake to the end of the default group in your Gemfile
|
21
|
+
|
22
|
+
tweezer add rake '~> 0.9.6' # Adds rake ~> 0.9.6 to the end of the default group
|
23
|
+
# in your Gemfile
|
24
|
+
|
25
|
+
tweezer add rspec --group test # Adds rspec to the 'test' group in your gemfile.
|
26
|
+
# Tweezer will do this in a way that results in
|
27
|
+
# the most idiomatic possible Gemfile
|
28
|
+
```
|
29
|
+
|
30
|
+
For further documentation, run `tweezer help` and `tweezer help COMMAND`.
|
31
|
+
|
32
|
+
## Why?
|
33
|
+
|
34
|
+
[Gemrat][] exists and is pretty cool, but has two problems with it that prevent
|
35
|
+
it from serving my use-case:
|
36
|
+
|
37
|
+
1. It uses naïve string-manipulation to edit the Gemfile. **Tweezer**, by
|
38
|
+
comparison, uses the [parser][] and [unparser][] gems to do an actual
|
39
|
+
modification of the AST of your gemfile.
|
40
|
+
|
41
|
+
2. Gemrat only really satisfies the use-case of "install and save to Gemfile",
|
42
|
+
covered by tools like `npm install --save` for other languages. **Tweezer**,
|
43
|
+
by comparison, either allows or will allow much more advanced modifications
|
44
|
+
of the gemfile, including adding gems to groups, deleting groups, modifying
|
45
|
+
versions, sources, etc. of gems, and more.
|
46
|
+
|
47
|
+
My original use-case was for local-development of a gem that was used by one of
|
48
|
+
my apps, which required rather frequently switching my gemfile between `gem
|
49
|
+
'mygem', '~> 1.0.0'` and `gem 'mygem', path: '/path/to/local/gem'`.
|
50
|
+
|
51
|
+
[Gemrat]: https://github.com/DruRly/gemrat
|
52
|
+
[parser]: https://github.com/whitequark/parser
|
53
|
+
[unparser]: https://github.com/mbj/unparser
|
data/lib/tweezer/gemfile.rb
CHANGED
@@ -56,7 +56,9 @@ module Tweezer
|
|
56
56
|
# rubocop:enable Metrics/AbcSize
|
57
57
|
|
58
58
|
def dump
|
59
|
-
Unparser.unparse(ast, comments)
|
59
|
+
dumped = Unparser.unparse(ast, comments).dup
|
60
|
+
dumped << "\n" unless dumped.last == "\n"
|
61
|
+
dumped
|
60
62
|
end
|
61
63
|
|
62
64
|
private
|
@@ -85,8 +87,14 @@ module Tweezer
|
|
85
87
|
end
|
86
88
|
|
87
89
|
def append_before_first_block!(new_node)
|
90
|
+
appended = false
|
88
91
|
nodes = ast.children.flat_map do |node|
|
89
|
-
block?(node)
|
92
|
+
if block?(node) && !appended
|
93
|
+
appended = true
|
94
|
+
next [new_node, blank_line, node, blank_line]
|
95
|
+
end
|
96
|
+
|
97
|
+
[node]
|
90
98
|
end
|
91
99
|
nodes << new_node unless nodes.include? new_node
|
92
100
|
|
data/lib/tweezer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tweezer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Griffin Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|