rebundler 0.5.1 → 0.6.0
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 +11 -0
- data/README.md +1 -1
- data/lib/rebundler/gem_declaration.rb +44 -4
- data/lib/rebundler/gem_set.rb +4 -1
- data/lib/rebundler/version.rb +1 -1
- data/lib/rebundler/visitor.rb +7 -9
- data/lib/rebundler.rb +1 -1
- metadata +31 -4
- data/lib/rebundler/summarizer.rb +0 -33
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5b1b0b72d8ab93bb647d7798d0a5baf75b453e279a82488c4e4fb91d27f59889
|
|
4
|
+
data.tar.gz: 74d512496ca8a94348cf3dadd24f866d95d7c84651185a976846fd29b0c0d41f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b821a15b955e764523e0e37bc84c7f44873fa4b9ba73e6223897d862ef96ee90df82412e539968d18ade95460eacfd8956cd03f4f9c0128e48c88bf365059a73
|
|
7
|
+
data.tar.gz: 2d78eec32c5ccb0d4d3378ee024919516e8ecbddcd57ed227f0d63ef9368d15c6e1b3c792c2f30919831167e2f2b1f56ae984ce5ccda81833047e4a7c5b6faab
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
## [0.6.0] - 2026-06-18
|
|
2
|
+
|
|
3
|
+
- Add support for the `install_if` directive. `install_if` blocks are now parsed and
|
|
4
|
+
formatted like other directive blocks (`group`, `path`, etc.).
|
|
5
|
+
- Fixed a crash when a block was empty.
|
|
6
|
+
- Fall back to a gem's `description` when its `summary` is `nil` or blank, so the
|
|
7
|
+
generated trailing comment is still populated.
|
|
8
|
+
- Declare `prism` and `zeitwerk` as runtime dependencies in the gemspec (they were
|
|
9
|
+
previously only in the Gemfile), fixing standalone installs of the gem.
|
|
10
|
+
- Internal refactoring (inlined the summarizer into `GemDeclaration`) and dependency updates.
|
|
11
|
+
|
|
1
12
|
## [0.5.1] - 2026-03-13
|
|
2
13
|
|
|
3
14
|
- Remove references to running as a bundler plugin. This does not work well, so decided to remove it.
|
data/README.md
CHANGED
|
@@ -92,7 +92,7 @@ new_content = parser.format(overwrite_comments: true)
|
|
|
92
92
|
|
|
93
93
|
## Development
|
|
94
94
|
|
|
95
|
-
After checking out the repo, run `bundle install` to install dependencies. Then, run `
|
|
95
|
+
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.
|
|
96
96
|
|
|
97
97
|
## Contributing
|
|
98
98
|
|
|
@@ -1,15 +1,55 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Rebundler
|
|
4
|
-
GemDeclaration
|
|
4
|
+
class GemDeclaration
|
|
5
|
+
include Comparable
|
|
6
|
+
|
|
7
|
+
attr_reader :node
|
|
8
|
+
|
|
9
|
+
def initialize(node: nil)
|
|
10
|
+
@node = node
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def name = @node.arguments.child_nodes[0].content
|
|
14
|
+
def normalized_name = name.tr("-_", "").downcase
|
|
15
|
+
|
|
16
|
+
def summary
|
|
17
|
+
gem = find_loaded_gem || find_external_gem
|
|
18
|
+
|
|
19
|
+
return if gem.nil?
|
|
20
|
+
|
|
21
|
+
if gem.summary.nil? || gem.summary == ""
|
|
22
|
+
gem.description
|
|
23
|
+
else
|
|
24
|
+
gem.summary
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
5
28
|
def <=>(other)
|
|
6
|
-
|
|
29
|
+
unless other.is_a?(GemDeclaration)
|
|
30
|
+
raise ArgumentError,
|
|
31
|
+
"comparison of GemDeclaration with #{other.class} failed"
|
|
32
|
+
end
|
|
7
33
|
|
|
8
34
|
normalized_name <=> other.normalized_name
|
|
9
35
|
end
|
|
10
36
|
|
|
11
|
-
|
|
12
|
-
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
def find_loaded_gem
|
|
40
|
+
Gem::Specification.find_by_name(name)
|
|
41
|
+
rescue Gem::MissingSpecError
|
|
42
|
+
nil
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def find_external_gem
|
|
46
|
+
spec = Gem::SpecFetcher.fetcher.spec_for_dependency(Gem::Dependency.new(name))
|
|
47
|
+
|
|
48
|
+
return if spec.nil? || spec.first.empty?
|
|
49
|
+
|
|
50
|
+
spec.first.first.first
|
|
51
|
+
rescue SocketError, Errno::ECONNREFUSED, Errno::ETIMEDOUT, Timeout::Error => e
|
|
52
|
+
raise Rebundler::Error, "Network error while fetching gem info for '#{name}': #{e.message}"
|
|
13
53
|
end
|
|
14
54
|
end
|
|
15
55
|
end
|
data/lib/rebundler/gem_set.rb
CHANGED
|
@@ -16,7 +16,10 @@ module Rebundler
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def <=>(other)
|
|
19
|
-
|
|
19
|
+
unless other.is_a?(GemSet)
|
|
20
|
+
raise ArgumentError,
|
|
21
|
+
"comparison of GemSet with #{other.class} failed"
|
|
22
|
+
end
|
|
20
23
|
|
|
21
24
|
# Default first, then sort by name
|
|
22
25
|
[default ? 0 : 1, name.to_s] <=> [other.default ? 0 : 1, other.name.to_s]
|
data/lib/rebundler/version.rb
CHANGED
data/lib/rebundler/visitor.rb
CHANGED
|
@@ -11,13 +11,18 @@ module Rebundler
|
|
|
11
11
|
def visit_call_node(node)
|
|
12
12
|
case node.name
|
|
13
13
|
when :plugin
|
|
14
|
-
@current_set.plugins <<
|
|
14
|
+
@current_set.plugins << GemDeclaration.new(node:)
|
|
15
15
|
when :gem
|
|
16
|
-
@current_set.gems <<
|
|
16
|
+
@current_set.gems << GemDeclaration.new(node:)
|
|
17
17
|
when :git_source
|
|
18
|
+
# :git_source is a special case where it's a directive with a block that
|
|
19
|
+
# we don't want to add it as a set, which would happen if it's parsed in
|
|
20
|
+
# the condition for DIRECTIVE_AND_BLOCK_NODES below.
|
|
18
21
|
@parser.directives << node
|
|
19
22
|
when *DIRECTIVE_AND_BLOCK_NODES
|
|
20
23
|
if node.block
|
|
24
|
+
return unless node.block.body
|
|
25
|
+
|
|
21
26
|
# Use the full block declaration (e.g., "group :development do") as the unique name
|
|
22
27
|
name = node.location.slice.lines.first.strip
|
|
23
28
|
|
|
@@ -42,12 +47,5 @@ module Rebundler
|
|
|
42
47
|
@parser.gem_sets << set
|
|
43
48
|
end
|
|
44
49
|
end
|
|
45
|
-
|
|
46
|
-
def parse_gem_with_comment(node)
|
|
47
|
-
name = node.arguments.child_nodes[0].content
|
|
48
|
-
summary = Summarizer.summarize(name)
|
|
49
|
-
|
|
50
|
-
GemDeclaration.new(name:, summary:, node:)
|
|
51
|
-
end
|
|
52
50
|
end
|
|
53
51
|
end
|
data/lib/rebundler.rb
CHANGED
|
@@ -8,5 +8,5 @@ module Rebundler
|
|
|
8
8
|
class Error < StandardError; end
|
|
9
9
|
|
|
10
10
|
SORTABLE_NODES = %i[plugin gem].freeze
|
|
11
|
-
DIRECTIVE_AND_BLOCK_NODES = %i[gemspec git group path platforms ruby source].freeze
|
|
11
|
+
DIRECTIVE_AND_BLOCK_NODES = %i[gemspec git group path platforms ruby source install_if].freeze
|
|
12
12
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,42 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rebundler
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dennis Paagman
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
-
dependencies:
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: prism
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '1.9'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '1.9'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: zeitwerk
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '2.8'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '2.8'
|
|
12
40
|
email:
|
|
13
41
|
- dennis@paagman.dev
|
|
14
42
|
executables:
|
|
@@ -29,7 +57,6 @@ files:
|
|
|
29
57
|
- lib/rebundler/gem_set.rb
|
|
30
58
|
- lib/rebundler/parser.rb
|
|
31
59
|
- lib/rebundler/serializer.rb
|
|
32
|
-
- lib/rebundler/summarizer.rb
|
|
33
60
|
- lib/rebundler/version.rb
|
|
34
61
|
- lib/rebundler/visitor.rb
|
|
35
62
|
- mise.toml
|
|
@@ -55,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
55
82
|
- !ruby/object:Gem::Version
|
|
56
83
|
version: '0'
|
|
57
84
|
requirements: []
|
|
58
|
-
rubygems_version: 4.0.
|
|
85
|
+
rubygems_version: 4.0.10
|
|
59
86
|
specification_version: 4
|
|
60
87
|
summary: Rebundler makes your Gemfile look good.
|
|
61
88
|
test_files: []
|
data/lib/rebundler/summarizer.rb
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "timeout"
|
|
4
|
-
|
|
5
|
-
module Rebundler
|
|
6
|
-
class Summarizer
|
|
7
|
-
class << self
|
|
8
|
-
def summarize(name)
|
|
9
|
-
find_loaded_gem_summary(name) || find_external_gem_summary(name)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
private
|
|
13
|
-
|
|
14
|
-
def find_loaded_gem_summary(name)
|
|
15
|
-
gem = Gem::Specification.find_by_name(name)
|
|
16
|
-
|
|
17
|
-
gem.summary
|
|
18
|
-
rescue Gem::MissingSpecError
|
|
19
|
-
nil
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def find_external_gem_summary(name)
|
|
23
|
-
spec = Gem::SpecFetcher.fetcher.spec_for_dependency Gem::Dependency.new(name)
|
|
24
|
-
|
|
25
|
-
return if spec.nil? || spec.first.empty?
|
|
26
|
-
|
|
27
|
-
spec.first.first.first.summary
|
|
28
|
-
rescue SocketError, Errno::ECONNREFUSED, Errno::ETIMEDOUT, Timeout::Error => e
|
|
29
|
-
raise Rebundler::Error, "Network error while fetching gem info for '#{name}': #{e.message}"
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|