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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 80dede87ff46bc8aefd962ccd46dffcb199357eca04173b9610f85e74c74111a
4
- data.tar.gz: dfd221d5ec0cdd3c3511fdd1e7980fb8bc00050afab9d69cdb81c43d1673fee6
3
+ metadata.gz: e9eeb335df1b34923f36572389fdf30489fd5e3d2b88e72e602d7cff4c9ace2b
4
+ data.tar.gz: 34c0bf38181ce5f9516967f94acc5ad08ae57230f7d5d6adadacf6d932860125
5
5
  SHA512:
6
- metadata.gz: 4d160d053c3e60ef38d7b129876159a2d696015857d917f1dceb82afcd3e648d8e5736232535a9d79ef84e11681591019245317f5f15c3d7b24d06292e6c15f7
7
- data.tar.gz: bcadfa71fac1e0be9c6777217cba5797e729ead523383a7f049984e47f9b9c24952cb9ae2d7a4eb7f03615cc8f4aeaafa13961cbedcfde9dd94684d601bcb0f2
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
- - support ```ruby ```
14
+ - bundler itself
15
+ - use changelog files from installed gems where present
15
16
 
16
- ## 0.1
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
- Until it's released on RubyGems, you can install it from GitHub:
10
+ The easiest way to install gemstar is to use Bundler:
11
11
 
12
12
  ```shell
13
13
  # Shell
14
- gem install specific_install
15
- gem specific_install -l https://github.com/FDj/gemstar.git
14
+ gem install gemstar
16
15
  ```
17
16
 
18
- Or adding to your project:
17
+ Alternatively, add it to the development group in your Gemfile:
19
18
 
20
- ```ruby
21
- # Gemfile
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
- ### `gemstar diff`
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
- bundle exec gemstar diff
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
- bundle exec gemstar diff --from 8e3aa96b7027834cdbabc0d8cbd5f9455165e930 --to HEAD
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
@@ -16,15 +16,15 @@ module Gemstar
16
16
 
17
17
  def sections
18
18
  @sections ||= begin
19
- s = parse_changelog_sections
20
- if s.nil? || s.empty?
21
- s = parse_github_release_sections
22
- end
19
+ s = parse_changelog_sections
20
+ if s.nil? || s.empty?
21
+ s = parse_github_release_sections
22
+ end
23
23
 
24
- pp @@candidates_found if Gemstar.debug?
24
+ pp @@candidates_found if Gemstar.debug?
25
25
 
26
- s
27
- end
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
- return $1 if heading[/\(\s*v?(\d[\w.\-]+)\s*\)/]
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
- return $1 if heading[/^\s*(?:#+|=+)?\s*(?:Version\s+)?\[?v?(\d[\w.\-]+)\]?/i]
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.\-]+)?)\b/]
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
- flush_current = lambda do
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
- new_key = nil
164
- # Keep-a-Changelog style: version first with trailing date, e.g. "## v1.2.6 - 2025-10-21"
165
- if line =~ /^\s*(?:#+|=+)\s*\[?v?(\d[\w.\-]+)\]?\s*(?:—|–|-)\s*\d{4}-\d{2}-\d{2}\b/
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
- if new_key
181
- # Flush previous section before starting a new one
182
- flush_current.call
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
- # Flush the last captured section
191
- flush_current.call
180
+ current_lines << line if current_key
181
+ end
192
182
 
193
- # Normalize keys: ensure all keys are versions; fix any leftover date-like keys conservatively
194
- begin
195
- normalized = {}
196
- sections.each do |k, lines|
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
- Nokogiri::HTML5(html)
276
- rescue => _
277
- Nokogiri::HTML(html)
278
- end
221
+ Nokogiri::HTML5(html)
222
+ rescue => _
223
+ Nokogiri::HTML(html)
224
+ end
279
225
 
280
226
  sections = {}
281
227
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gemstar # :nodoc:
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
 
6
6
  def self.debug?
7
7
  return @debug if defined?(@debug)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemstar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Dejako