rebundler 0.6.0 → 0.6.1
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +42 -5
- data/lib/rebundler/gem_declaration.rb +3 -1
- data/lib/rebundler/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bd90571682828dd3a39d81faadcca42fb3003f2cdac7709b060b375dd43c44db
|
|
4
|
+
data.tar.gz: d3d922f26bc42111b9f333d714f8c89776f6a7d4c2541da245acbc29d803e4e8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ff8197f9fc485081470bc387a897a702e05e34b2f5a15d910f6227df07f9cf917b184897294f71fc511710106b52d1c6fa1efbf134c6c4ab8e38e73484dd0f16
|
|
7
|
+
data.tar.gz: 99f3ec9e1ea7d21c01b1622137573273422d56ac7dd7e6aa29cf7c9a8c0d6239dc37ba7419a365a530b87897fb6e42ebae229f465082a0d58832799817426570
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## [0.6.1] - 2026-06-18
|
|
2
|
+
|
|
3
|
+
- Include pre-release versions when fetching external gem info, so gems published only
|
|
4
|
+
as pre-releases (e.g. `typesense-rails`) are found and get a generated trailing
|
|
5
|
+
comment. Stable gems still resolve to their latest stable version.
|
|
6
|
+
|
|
1
7
|
## [0.6.0] - 2026-06-18
|
|
2
8
|
|
|
3
9
|
- Add support for the `install_if` directive. `install_if` blocks are now parsed and
|
data/README.md
CHANGED
|
@@ -10,19 +10,46 @@ Rebundler automatically reorders and annotates your Gemfile.
|
|
|
10
10
|
|
|
11
11
|
## Example
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Take this small Gemfile:
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
```ruby
|
|
16
|
+
source "https://rubygems.org"
|
|
17
|
+
|
|
18
|
+
gem "rails"
|
|
19
|
+
gem "puma"
|
|
20
|
+
gem "avo"
|
|
21
|
+
|
|
22
|
+
group :development do
|
|
23
|
+
gem "herb"
|
|
24
|
+
end
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
After running Rebundler, the gems are sorted, and each one is annotated with its description:
|
|
28
|
+
|
|
29
|
+
```ruby
|
|
30
|
+
source "https://rubygems.org"
|
|
31
|
+
|
|
32
|
+
gem "avo" # Admin panel framework and Content Management System for Ruby on Rails.
|
|
33
|
+
gem "puma" # A Ruby/Rack web server built for parallelism.
|
|
34
|
+
gem "rails" # Full-stack web application framework.
|
|
35
|
+
|
|
36
|
+
group :development do
|
|
37
|
+
gem "herb" # The modern HTML+ERB Toolchain
|
|
38
|
+
end
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Try it online
|
|
42
|
+
|
|
43
|
+
You can play around with Rebundler in the [Rebundler Playground](https://rebundler.dev/). Just paste your Gemfile and hit **Rebundle**. It encodes the Gemfile in a hash in the URL, so you can easily share the result with others.
|
|
18
44
|
|
|
19
45
|
## Known limitations
|
|
20
46
|
|
|
21
47
|
- **Probably does not work with all possible Gemfile configurations.** It is designed to work with the most common setups right now. If you encounter an issue, please open an issue on GitHub. I strive to support most sensible configurations.
|
|
48
|
+
- **Non-trailing comments are discarded.** Rebundler keeps existing trailing comments on `gem` lines, but standalone comments and commented-out gems are removed.
|
|
22
49
|
|
|
23
50
|
## Installation
|
|
24
51
|
|
|
25
|
-
|
|
52
|
+
Add it to your Gemfile with `bundle add rebundler`, or install it standalone with `gem install rebundler`. There are two ways to run Rebundler.
|
|
26
53
|
|
|
27
54
|
### 1. Writing mode
|
|
28
55
|
|
|
@@ -90,6 +117,16 @@ Pass `overwrite_comments: true` to replace existing trailing comments on `gem` l
|
|
|
90
117
|
new_content = parser.format(overwrite_comments: true)
|
|
91
118
|
```
|
|
92
119
|
|
|
120
|
+
## How it works
|
|
121
|
+
|
|
122
|
+
Since Gemfiles are just regular Ruby files, Rebundler parses them with [Prism](https://github.com/ruby/prism). It walks the AST using Prism's visitor pattern to find `gem` declarations and groups, while keeping generic setup methods like `source`, `ruby`, and `git_source` at the top.
|
|
123
|
+
|
|
124
|
+
Gems defined at the top level are grouped together. Gems inside blocks (like `group :development do ... end`) stay within their block, and duplicate groups are automatically merged. Within each group, gems are sorted alphabetically.
|
|
125
|
+
|
|
126
|
+
Prism is only a parser, not a formatter, so Rebundler reconstructs the Gemfile with some string manipulation. Because Prism records the exact line and column of every node, Rebundler copies the original source for each gem verbatim — which keeps your existing style intact. It then loads each gem's description from your local bundle (fetching it from RubyGems if it's missing) and appends it as a trailing comment.
|
|
127
|
+
|
|
128
|
+
By default, existing trailing comments are kept and other comments are discarded.
|
|
129
|
+
|
|
93
130
|
## Development
|
|
94
131
|
|
|
95
132
|
After checking out the repo, run `bundle install` to install dependencies. Then, run `bundle exec minitest` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
@@ -43,7 +43,9 @@ module Rebundler
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def find_external_gem
|
|
46
|
-
|
|
46
|
+
dependency = Gem::Dependency.new(name).tap { |d| d.prerelease = true } # Also find prelease gems
|
|
47
|
+
|
|
48
|
+
spec = Gem::SpecFetcher.fetcher.spec_for_dependency(dependency)
|
|
47
49
|
|
|
48
50
|
return if spec.nil? || spec.first.empty?
|
|
49
51
|
|
data/lib/rebundler/version.rb
CHANGED