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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b1b0b72d8ab93bb647d7798d0a5baf75b453e279a82488c4e4fb91d27f59889
4
- data.tar.gz: 74d512496ca8a94348cf3dadd24f866d95d7c84651185a976846fd29b0c0d41f
3
+ metadata.gz: bd90571682828dd3a39d81faadcca42fb3003f2cdac7709b060b375dd43c44db
4
+ data.tar.gz: d3d922f26bc42111b9f333d714f8c89776f6a7d4c2541da245acbc29d803e4e8
5
5
  SHA512:
6
- metadata.gz: b821a15b955e764523e0e37bc84c7f44873fa4b9ba73e6223897d862ef96ee90df82412e539968d18ade95460eacfd8956cd03f4f9c0128e48c88bf365059a73
7
- data.tar.gz: 2d78eec32c5ccb0d4d3378ee024919516e8ecbddcd57ed227f0d63ef9368d15c6e1b3c792c2f30919831167e2f2b1f56ae984ce5ccda81833047e4a7c5b6faab
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
- This is a real life example from my own project. That looks a lot better, doesn't it?
13
+ Take this small Gemfile:
14
14
 
15
- | Before | After |
16
- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
17
- | ![image](https://github.com/user-attachments/assets/42a76744-111b-4f73-bc62-8723637e6655) | ![image](https://github.com/user-attachments/assets/3ea6c70e-2239-4511-9040-c4db58203ec4) |
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
- First add `rebundler` to your Gemfile. `bundle add rebundler`. There are two ways to run Rebundler.
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
- spec = Gem::SpecFetcher.fetcher.spec_for_dependency(Gem::Dependency.new(name))
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rebundler
4
- VERSION = "0.6.0"
4
+ VERSION = "0.6.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rebundler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Paagman