gemstar 0.0.1 → 0.0.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 +4 -4
- data/CHANGELOG.md +10 -2
- data/README.md +15 -13
- data/lib/gemstar/change_log.rb +49 -103
- data/lib/gemstar/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: e9eeb335df1b34923f36572389fdf30489fd5e3d2b88e72e602d7cff4c9ace2b
|
|
4
|
+
data.tar.gz: 34c0bf38181ce5f9516967f94acc5ad08ae57230f7d5d6adadacf6d932860125
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 23fad51445796f654d61318b33129d9a9f02136162982623aecafa0afa6271e9244bc6f272fb77e2ff049c944e44164018289be5306a124311c30340572eaf04
|
|
7
|
+
data.tar.gz: 436bb8487ba91671e6ab319775460c2b13f34d0873812edf3d0e429f8c6dba5707da5ed599033153fc86cd3bb276f04c227f8e4a029756b67c9b7989e6153484
|
data/CHANGELOG.md
CHANGED
|
@@ -11,9 +11,17 @@
|
|
|
11
11
|
- actioncable-next uses release tag names?
|
|
12
12
|
- paper_trail not using CHANGELOG.md?
|
|
13
13
|
- playwright-ruby-client uses release tags?
|
|
14
|
-
-
|
|
14
|
+
- bundler itself
|
|
15
|
+
- use changelog files from installed gems where present
|
|
15
16
|
|
|
16
|
-
##
|
|
17
|
+
## Unreleased
|
|
18
|
+
|
|
19
|
+
## 0.0.2
|
|
20
|
+
|
|
21
|
+
- Diff: Fix regex warnings shown in terminal.
|
|
22
|
+
- Diff: Simplify and fix change log section parsing.
|
|
23
|
+
|
|
24
|
+
## 0.0.1
|
|
17
25
|
|
|
18
26
|
- Initial release
|
|
19
27
|
- Add GEMSTAR_DEBUG_GEM_REGEX to debug specific gems.
|
data/README.md
CHANGED
|
@@ -7,32 +7,28 @@ A very preliminary gem to help you keep track of your gems.
|
|
|
7
7
|
|
|
8
8
|
## Installation
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
The easiest way to install gemstar is to use Bundler:
|
|
11
11
|
|
|
12
12
|
```shell
|
|
13
13
|
# Shell
|
|
14
|
-
gem install
|
|
15
|
-
gem specific_install -l https://github.com/FDj/gemstar.git
|
|
14
|
+
gem install gemstar
|
|
16
15
|
```
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
Alternatively, add it to the development group in your Gemfile:
|
|
19
18
|
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
group :development do
|
|
23
|
-
gem "gemstar", github: "FDj/gemstar"
|
|
24
|
-
end
|
|
19
|
+
```
|
|
20
|
+
gem "gemstar", group: :development
|
|
25
21
|
```
|
|
26
22
|
|
|
27
23
|
## Usage
|
|
28
24
|
|
|
29
|
-
###
|
|
25
|
+
### gemstar diff
|
|
30
26
|
|
|
31
27
|
Run this after you've updated your gems.
|
|
32
28
|
|
|
33
29
|
```shell
|
|
34
|
-
# in your project directory:
|
|
35
|
-
|
|
30
|
+
# in your project directory, after bundle update:
|
|
31
|
+
gemstar diff
|
|
36
32
|
```
|
|
37
33
|
|
|
38
34
|
This will generate an html diff report with changelog entries for each gem that was updated:
|
|
@@ -42,7 +38,13 @@ This will generate an html diff report with changelog entries for each gem that
|
|
|
42
38
|
You can also specify from and to hashes or tags to generate a diff report for a specific range of commits:
|
|
43
39
|
|
|
44
40
|
```shell
|
|
45
|
-
|
|
41
|
+
gemstar diff --from 8e3aa96b7027834cdbabc0d8cbd5f9455165e930 --to HEAD
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
To examine a specific Gemfile.lock, pass it like this:
|
|
45
|
+
|
|
46
|
+
```shell
|
|
47
|
+
gemstar diff --lockfile=~/MyProject/Gemfile.lock
|
|
46
48
|
```
|
|
47
49
|
|
|
48
50
|
## Contributing
|
data/lib/gemstar/change_log.rb
CHANGED
|
@@ -16,15 +16,15 @@ module Gemstar
|
|
|
16
16
|
|
|
17
17
|
def sections
|
|
18
18
|
@sections ||= begin
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
s = parse_changelog_sections
|
|
20
|
+
if s.nil? || s.empty?
|
|
21
|
+
s = parse_github_release_sections
|
|
22
|
+
end
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
pp @@candidates_found if Gemstar.debug?
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
s
|
|
27
|
+
end
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def extract_relevant_sections(old_version, new_version)
|
|
@@ -53,11 +53,14 @@ module Gemstar
|
|
|
53
53
|
return nil unless line
|
|
54
54
|
heading = line.to_s
|
|
55
55
|
# 1) Prefer version inside parentheses after a date: "### 2025-11-07 (2.16.0)"
|
|
56
|
-
|
|
56
|
+
# Ensure we ONLY treat it as a version if it actually looks like a version (has a dot),
|
|
57
|
+
# so we don't capture dates like (2025-11-21).
|
|
58
|
+
return $1 if heading[/\(\s*v?(\d+\.\d+(?:\.\d+)?[A-Za-z0-9.\-]*)\s*\)/]
|
|
57
59
|
# 2) Version-first with optional leading markers/labels: "## v1.2.6 - 2025-10-21"
|
|
58
|
-
|
|
60
|
+
# Require a dot in the numeric token to avoid capturing dates like 2025-11-21.
|
|
61
|
+
return $1 if heading[/^\s*(?:#+|=+)?\s*(?:Version\s+)?\[?v?(\d+\.\d+(?:\.\d+)?[A-Za-z0-9.\-]*)\]?/i]
|
|
59
62
|
# 3) Anywhere: first semver-like token with a dot
|
|
60
|
-
return $1 if heading[/\bv?(\d+\.\d+(?:\.\d+)?(?:[A-Za-z0-9.\-]
|
|
63
|
+
return $1 if heading[/\bv?(\d+\.\d+(?:\.\d+)?(?:[A-Za-z0-9.\-])*)\b/]
|
|
61
64
|
nil
|
|
62
65
|
end
|
|
63
66
|
|
|
@@ -123,6 +126,13 @@ module Gemstar
|
|
|
123
126
|
content
|
|
124
127
|
end
|
|
125
128
|
|
|
129
|
+
VERSION_PATTERNS = [
|
|
130
|
+
/^\s*(?:#+|=+)\s*\d{4}-\d{2}-\d{2}\s*\(\s*v?(\d[\w.\-]+)\s*\)/, # prefer this
|
|
131
|
+
/^\s*(?:#+|=+)\s*\[?v?(\d+\.\d+(?:\.\d+)?[A-Za-z0-9.\-]*)\]?\s*(?:—|–|-)\s*\d{4}-\d{2}-\d{2}\b/,
|
|
132
|
+
/^\s*(?:#+|=+)\s*(?:Version\s+)?(?:(?:[^\s\d][^\s]*\s+)+)\[?v?(\d+\.\d+(?:\.\d+)?[A-Za-z0-9.\-]*)\]?(?:\s*[-(].*)?/i,
|
|
133
|
+
/^\s*(?:#+|=+)\s*(?:Version\s+)?\[?v?(\d+\.\d+(?:\.\d+)?[A-Za-z0-9.\-]*)\]?(?:\s*[-(].*)?/i,
|
|
134
|
+
/^\s*(?:Version\s+)?v?(\d+\.\d+(?:\.\d+)?[A-Za-z0-9.\-]*)(?:\s*[-(].*)?/i
|
|
135
|
+
]
|
|
126
136
|
|
|
127
137
|
def parse_changelog_sections
|
|
128
138
|
# If the fetched content looks like a GitHub Releases HTML page, return {}
|
|
@@ -136,108 +146,44 @@ module Gemstar
|
|
|
136
146
|
return {}
|
|
137
147
|
end
|
|
138
148
|
|
|
149
|
+
lines = c.lines
|
|
150
|
+
|
|
151
|
+
if lines.count < 4
|
|
152
|
+
# Skip changelog files that are too short to be useful
|
|
153
|
+
# This is sometimes the case with changelogs just saying "please see GitHub releases"
|
|
154
|
+
puts "parse_changelog_sections #{@metadata.gem_name}: Changelog too short; skipping" if Gemstar.debug?
|
|
155
|
+
return {}
|
|
156
|
+
end
|
|
157
|
+
|
|
139
158
|
sections = {}
|
|
140
159
|
current_key = nil
|
|
141
160
|
current_lines = []
|
|
142
161
|
|
|
143
|
-
|
|
144
|
-
return unless current_key && !current_lines.empty?
|
|
145
|
-
key = current_key
|
|
146
|
-
# If key looks like a date or non-version, try to extract a proper version
|
|
147
|
-
if key =~ /\A\d{4}-\d{2}-\d{2}\z/ || key !~ /\A\d[\w.\-]*\z/
|
|
148
|
-
v = extract_version_from_heading(current_lines.first)
|
|
149
|
-
key = v if v
|
|
150
|
-
end
|
|
151
|
-
if sections.key?(key)
|
|
152
|
-
# Collision: merge by appending with a separator to avoid losing data
|
|
153
|
-
sections[key] += ["\n"] + current_lines
|
|
154
|
-
else
|
|
155
|
-
sections[key] = current_lines.dup
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
c.each_line do |line|
|
|
162
|
+
lines.each do |line|
|
|
160
163
|
# Convert rdoc to markdown:
|
|
161
164
|
line = line.gsub(/^=+/) { |m| "#" * m.length }
|
|
162
165
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if
|
|
166
|
-
new_key = extract_version_from_heading(line) || $1
|
|
167
|
-
elsif line =~ /^\s*(?:#+|=+)\s*(?:Version\s+)?(?:(?:[^\s\d][^\s]*\s+)+)\[?v?(\d[\w.\-]+)\]?(?:\s*[-(].*)?/i
|
|
168
|
-
new_key = extract_version_from_heading(line) || $1
|
|
169
|
-
elsif line =~ /^\s*(?:#+|=+)\s*(?:Version\s+)?\[?v?(\d[\w.\-]+)\]?(?:\s*[-(].*)?/i
|
|
170
|
-
# header without label words before the version
|
|
171
|
-
new_key = extract_version_from_heading(line) || $1
|
|
172
|
-
elsif line =~ /^\s*(?:#+|=+)\s*\d{4}-\d{2}-\d{2}\s*\(\s*v?(\d[\w.\-]+)\s*\)/
|
|
173
|
-
# headings like "### 2025-11-07 (2.16.0)" — prefer the version in parentheses over the leading date
|
|
174
|
-
new_key = extract_version_from_heading(line) || $1
|
|
175
|
-
elsif line =~ /^\s*(?:Version\s+)?v?(\d[\w.\-]+)(?:\s*[-(].*)?/i
|
|
176
|
-
# fallback for lines like "1.4.0 (2025-06-02)"
|
|
166
|
+
m = VERSION_PATTERNS.lazy.map { |re| line.match(re) }.find(&:itself)
|
|
167
|
+
|
|
168
|
+
if m
|
|
177
169
|
new_key = extract_version_from_heading(line) || $1
|
|
178
|
-
end
|
|
179
170
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
171
|
+
if current_key
|
|
172
|
+
sections[current_key] ||= []
|
|
173
|
+
sections[current_key] << current_lines
|
|
174
|
+
current_lines = []
|
|
175
|
+
end
|
|
176
|
+
|
|
183
177
|
current_key = new_key
|
|
184
|
-
current_lines = [line]
|
|
185
|
-
elsif current_key
|
|
186
|
-
current_lines << line
|
|
187
178
|
end
|
|
188
|
-
end
|
|
189
179
|
|
|
190
|
-
|
|
191
|
-
|
|
180
|
+
current_lines << line if current_key
|
|
181
|
+
end
|
|
192
182
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
sections
|
|
197
|
-
if k =~ /\A\d{4}-\d{2}-\d{2}\z/ || k !~ /\A\d[\w.\-]*\z/
|
|
198
|
-
heading = lines.first.to_s
|
|
199
|
-
# 1) Prefer version inside parentheses, e.g., "### 2025-11-07 (2.16.0)"
|
|
200
|
-
if heading[/\(\s*v?(\d[\w.\-]+)\s*\)/]
|
|
201
|
-
key = $1
|
|
202
|
-
normalized[key] = if normalized.key?(key)
|
|
203
|
-
normalized[key] + ["\n"] + lines
|
|
204
|
-
else
|
|
205
|
-
lines
|
|
206
|
-
end
|
|
207
|
-
next
|
|
208
|
-
end
|
|
209
|
-
# 2) Headings like "## v1.2.5 - 2025-10-21" or "## 1.2.5 — 2025-10-21"
|
|
210
|
-
if heading[/^\s*(?:#+|=+)\s*(?:Version\s+)?\[?v?(\d+\.\d+(?:\.\d+)?(?:[A-Za-z0-9.\-]+)?)\]?/]
|
|
211
|
-
key = $1
|
|
212
|
-
normalized[key] = if normalized.key?(key)
|
|
213
|
-
normalized[key] + ["\n"] + lines
|
|
214
|
-
else
|
|
215
|
-
lines
|
|
216
|
-
end
|
|
217
|
-
next
|
|
218
|
-
end
|
|
219
|
-
# 3) Anywhere in the heading, pick the first semver-like token with a dot
|
|
220
|
-
if heading[/\bv?(\d+\.\d+(?:\.\d+)?(?:[A-Za-z0-9.\-]+)?)\b/]
|
|
221
|
-
key = $1
|
|
222
|
-
normalized[key] = if normalized.key?(key)
|
|
223
|
-
normalized[key] + ["\n"] + lines
|
|
224
|
-
else
|
|
225
|
-
lines
|
|
226
|
-
end
|
|
227
|
-
next
|
|
228
|
-
end
|
|
229
|
-
end
|
|
230
|
-
# Default: carry over, merging on collision to avoid loss
|
|
231
|
-
if normalized.key?(k)
|
|
232
|
-
normalized[k] += ["\n"] + lines
|
|
233
|
-
else
|
|
234
|
-
normalized[k] = lines
|
|
235
|
-
end
|
|
236
|
-
end
|
|
237
|
-
sections = normalized unless normalized.empty?
|
|
238
|
-
rescue => e
|
|
239
|
-
# Be conservative; if normalization fails for any reason, keep original sections
|
|
240
|
-
puts "Normalization error in parse_changelog_sections: #{e}" if Gemstar.debug?
|
|
183
|
+
if current_key
|
|
184
|
+
# Flush last section
|
|
185
|
+
sections[current_key] ||= []
|
|
186
|
+
sections[current_key] << current_lines
|
|
241
187
|
end
|
|
242
188
|
|
|
243
189
|
if Gemstar.debug?
|
|
@@ -272,10 +218,10 @@ module Gemstar
|
|
|
272
218
|
return {} if html.nil? || html.strip.empty?
|
|
273
219
|
|
|
274
220
|
doc = begin
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
221
|
+
Nokogiri::HTML5(html)
|
|
222
|
+
rescue => _
|
|
223
|
+
Nokogiri::HTML(html)
|
|
224
|
+
end
|
|
279
225
|
|
|
280
226
|
sections = {}
|
|
281
227
|
|
data/lib/gemstar/version.rb
CHANGED