reissue 0.1.7 → 0.2.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 +14 -6
- data/README.md +11 -2
- data/lib/reissue/markdown.rb +115 -0
- data/lib/reissue/parser.rb +2 -85
- data/lib/reissue/printer.rb +2 -2
- data/lib/reissue/rake.rb +2 -0
- data/lib/reissue/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b4d0a53280207aedc9381894922ca1efb28e0acb20d5bd97bbcb7fe2cd6a7cc
|
4
|
+
data.tar.gz: d649658ae57c53e5d3e78c5096d9248ddf941f85c074e1e3543e0eeda12678d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b7adacabff52f5c82e2a0f703d2f808174caf2af29fd244200ea9f0f9ff91887a31336d69ed0d8e37ff52084128fc01677e70d0fc5d3c12b738ada62f916ede
|
7
|
+
data.tar.gz: 330d439a724f349bc7b1f18ee1a47ca7fecf913749452d460894d5e659a8a7fcc80e13140f6b78d3c36d66ec7d28caa6110877e0cf742a191b6203676ee7bd67
|
data/CHANGELOG.md
CHANGED
@@ -5,18 +5,26 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
6
6
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
7
7
|
|
8
|
-
## [0.1
|
8
|
+
## [0.2.1] - 2024-07-29
|
9
9
|
|
10
|
-
###
|
10
|
+
### Added
|
11
|
+
|
12
|
+
- Release notes and the checksum for the 0.2.0 version
|
11
13
|
|
12
|
-
|
14
|
+
### Changed
|
13
15
|
|
14
|
-
|
16
|
+
- Return the new version from the reissue task
|
17
|
+
|
18
|
+
## [0.2.0] - 2024-07-02
|
15
19
|
|
16
20
|
### Added
|
17
21
|
|
18
|
-
-
|
22
|
+
- Reissue::Markdown class to implement the Reissue::Parser.parse behavior
|
23
|
+
|
24
|
+
### Removed
|
25
|
+
|
26
|
+
- Reissue::Parser implementation
|
19
27
|
|
20
28
|
### Fixed
|
21
29
|
|
22
|
-
-
|
30
|
+
- Handle multiline changes
|
data/README.md
CHANGED
@@ -89,7 +89,7 @@ Reissue::Task.create :your_name_and_namespace do |task|
|
|
89
89
|
# Required: The file to update with the new version number.
|
90
90
|
task.version_file = "path/to/version.rb"
|
91
91
|
|
92
|
-
# Optional: The number of versions to maintain in the changelog.
|
92
|
+
# Optional: The number of versions to maintain in the changelog. Defaults to 2.
|
93
93
|
task.version_limit = 5
|
94
94
|
|
95
95
|
# Optional: A Proc to format the version number. Receives a Gem::Version object, and segment.
|
@@ -97,7 +97,7 @@ Reissue::Task.create :your_name_and_namespace do |task|
|
|
97
97
|
# your special versioning logic
|
98
98
|
end
|
99
99
|
|
100
|
-
# Optional: The file to update with the new version number.
|
100
|
+
# Optional: The file to update with the new version number. Defaults to "CHANGELOG.md".
|
101
101
|
task.changelog_file = "path/to/CHANGELOG.md"
|
102
102
|
|
103
103
|
# Optional: Whether to commit the changes automatically. Defaults to true.
|
@@ -112,6 +112,15 @@ end
|
|
112
112
|
|
113
113
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
114
114
|
|
115
|
+
## Releasing
|
116
|
+
|
117
|
+
Run `rake build:checksum` to build the gem and generate the checksum. This will also update the version number in the gemspec file.
|
118
|
+
|
119
|
+
Run `rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
120
|
+
|
121
|
+
This will leave a new commit with the version number incremented in the version file and the changelog updated with the new version.
|
122
|
+
Push the changes to the repository.
|
123
|
+
|
115
124
|
## Contributing
|
116
125
|
|
117
126
|
Bug reports and pull requests are welcome on GitHub at https://github.com/SOFware/reissue.
|
@@ -0,0 +1,115 @@
|
|
1
|
+
module Reissue
|
2
|
+
class Markdown
|
3
|
+
def self.parse(changelog)
|
4
|
+
new(changelog).to_h
|
5
|
+
end
|
6
|
+
|
7
|
+
def initialize(changelog)
|
8
|
+
@changelog = changelog
|
9
|
+
@versions = {}
|
10
|
+
@header = nil
|
11
|
+
@parts = []
|
12
|
+
end
|
13
|
+
|
14
|
+
def parse
|
15
|
+
return unless @header.nil? && @versions.empty?
|
16
|
+
|
17
|
+
header, *chunks = @changelog.split(/^## /)
|
18
|
+
|
19
|
+
@header = Header.new(header)
|
20
|
+
@versions = Array(chunks).map { |part| Version.new(part) }
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_h
|
24
|
+
parse
|
25
|
+
@header.to_h.merge("versions" => @versions.map(&:to_h))
|
26
|
+
end
|
27
|
+
|
28
|
+
class Header
|
29
|
+
def initialize(chunk)
|
30
|
+
@chunk = chunk.to_s
|
31
|
+
@title = nil
|
32
|
+
@preamble = nil
|
33
|
+
end
|
34
|
+
|
35
|
+
def parse
|
36
|
+
return unless @title.nil? && @preamble.nil?
|
37
|
+
|
38
|
+
scanner = StringScanner.new(@chunk.dup << "\n")
|
39
|
+
scanner.scan(/# ([\w\s]+)$/)
|
40
|
+
@title = scanner[1].to_s.strip
|
41
|
+
# the rest of the text is the preamble
|
42
|
+
@preamble = scanner.rest.strip
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_h
|
46
|
+
parse
|
47
|
+
{
|
48
|
+
"title" => @title,
|
49
|
+
"preamble" => @preamble
|
50
|
+
}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class Version
|
55
|
+
def initialize(chunk)
|
56
|
+
@chunk = chunk
|
57
|
+
@version = nil
|
58
|
+
@date = nil
|
59
|
+
@changes = []
|
60
|
+
end
|
61
|
+
|
62
|
+
def parse
|
63
|
+
return unless @version.nil? && @date.nil? && @changes.empty?
|
64
|
+
# the first line contains the version and date
|
65
|
+
scanner = StringScanner.new(@chunk) << "\n"
|
66
|
+
scanner.scan(/\[?(.[^\]]+)\]? - (.+)$/)
|
67
|
+
@version = scanner[1].to_s.strip
|
68
|
+
@date = scanner[2].to_s.strip || "Unreleased"
|
69
|
+
|
70
|
+
# the rest of the text is the changes
|
71
|
+
@changes = scanner.rest.strip.split("### ").reject(&:empty?).map { |change| Change.new(change) }
|
72
|
+
end
|
73
|
+
|
74
|
+
def to_h
|
75
|
+
parse
|
76
|
+
{
|
77
|
+
"version" => @version,
|
78
|
+
"date" => @date,
|
79
|
+
"changes" => @changes.inject({}) { |h, change| h.merge(change.to_h) }
|
80
|
+
}
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
class Change
|
85
|
+
def initialize(chunk)
|
86
|
+
@chunk = chunk
|
87
|
+
@type = nil
|
88
|
+
@changes = []
|
89
|
+
end
|
90
|
+
|
91
|
+
def parse
|
92
|
+
return unless @type.nil? && @changes.empty?
|
93
|
+
scanner = StringScanner.new(@chunk) << "\n"
|
94
|
+
scanner.scan(/([\w\s]+)$/)
|
95
|
+
|
96
|
+
@type = scanner[1].to_s.strip
|
97
|
+
|
98
|
+
# the rest of the text are the changes
|
99
|
+
@changes = scanner
|
100
|
+
.rest
|
101
|
+
.strip
|
102
|
+
.split(/^-/m)
|
103
|
+
.map { |change| change.strip.gsub(/^- /m, "") }
|
104
|
+
.reject(&:empty?)
|
105
|
+
end
|
106
|
+
|
107
|
+
def to_h
|
108
|
+
parse
|
109
|
+
{
|
110
|
+
@type => @changes.map { |change| change.split("\n").map(&:strip).join("\n ") }
|
111
|
+
}
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
data/lib/reissue/parser.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "strscan"
|
2
|
+
require_relative "markdown"
|
2
3
|
|
3
4
|
module Reissue
|
4
5
|
class Parser
|
@@ -8,94 +9,10 @@ module Reissue
|
|
8
9
|
|
9
10
|
def initialize(changelog)
|
10
11
|
@changelog = changelog
|
11
|
-
@versions = {}
|
12
|
-
@parts = []
|
13
12
|
end
|
14
13
|
|
15
14
|
def parse
|
16
|
-
|
17
|
-
@parts << parse_title(scanner)
|
18
|
-
@parts << parse_preamble(scanner)
|
19
|
-
@parts << parse_versions(scanner)
|
20
|
-
@parts.compact.reduce(&:merge)
|
21
|
-
end
|
22
|
-
|
23
|
-
VERSION_BREAK = "## "
|
24
|
-
CHANGE_BREAK = "### "
|
25
|
-
VERSION_MATCH = /^#{VERSION_BREAK}/
|
26
|
-
VERSION_OR_CHANGE_MATCH = Regexp.union(CHANGE_BREAK, VERSION_BREAK)
|
27
|
-
VERSION_OR_CHANGE_OR_NEWLINE_MATCH = Regexp.union(/\n/, CHANGE_BREAK, VERSION_BREAK)
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def parse_title(scanner)
|
32
|
-
scanner.scan(/# ([\w\s]+)$/)
|
33
|
-
title = scanner[1].to_s.strip
|
34
|
-
{"title" => title}
|
35
|
-
end
|
36
|
-
|
37
|
-
def parse_preamble(scanner)
|
38
|
-
preamble = scanner.scan_until(VERSION_MATCH)
|
39
|
-
preamble = preamble.to_s.gsub(VERSION_BREAK, "").strip
|
40
|
-
scanner.unscan unless preamble.empty?
|
41
|
-
{"preamble" => preamble.strip}
|
42
|
-
end
|
43
|
-
|
44
|
-
def parse_versions(scanner)
|
45
|
-
until scanner.eos?
|
46
|
-
scanner.skip(/\s+/)
|
47
|
-
next_line = scanner.scan_until(VERSION_OR_CHANGE_OR_NEWLINE_MATCH)
|
48
|
-
break if next_line.nil? || next_line.strip.empty?
|
49
|
-
unless next_line.match?(VERSION_OR_CHANGE_MATCH)
|
50
|
-
parse_versions(scanner)
|
51
|
-
end
|
52
|
-
if next_line.match?(VERSION_MATCH)
|
53
|
-
scanner.scan_until(/(.+)\n/)
|
54
|
-
version, date = scanner[1].split(" - ")
|
55
|
-
date ||= "Unreleased"
|
56
|
-
version = version.gsub(VERSION_BREAK, "").strip.tr("[]", "")
|
57
|
-
changes = parse_changes(scanner)
|
58
|
-
@versions[version] = {"version" => version, "date" => date, "changes" => changes}
|
59
|
-
parse_versions(scanner)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
{"versions" => @versions.values}
|
63
|
-
end
|
64
|
-
|
65
|
-
def parse_changes(scanner, changes: {})
|
66
|
-
return changes if scanner.eos?
|
67
|
-
scanner.skip(/\s+/)
|
68
|
-
|
69
|
-
next_line = scanner.scan_until(/\n/)
|
70
|
-
if next_line.nil? || next_line.strip.empty?
|
71
|
-
return changes
|
72
|
-
elsif next_line.match?(VERSION_MATCH)
|
73
|
-
scanner.unscan
|
74
|
-
return changes
|
75
|
-
end
|
76
|
-
|
77
|
-
if next_line.match?(CHANGE_BREAK)
|
78
|
-
change_type = next_line.gsub(CHANGE_BREAK, "").strip
|
79
|
-
changes[change_type] = parse_change_list(scanner)
|
80
|
-
end
|
81
|
-
parse_changes(scanner, changes: changes)
|
82
|
-
end
|
83
|
-
|
84
|
-
def parse_change_list(scanner, collection: [])
|
85
|
-
return collection if scanner.eos?
|
86
|
-
scanner.skip(/\s+/)
|
87
|
-
change = scanner.scan_until(/\n/)
|
88
|
-
if change.nil? || change.strip.empty?
|
89
|
-
return collection
|
90
|
-
elsif change.match?(VERSION_OR_CHANGE_MATCH)
|
91
|
-
scanner.unscan
|
92
|
-
return collection
|
93
|
-
else
|
94
|
-
item = change.sub(/^\s?-\s?/, "").strip
|
95
|
-
collection << item
|
96
|
-
parse_change_list(scanner, collection:)
|
97
|
-
end
|
98
|
-
collection.reject(&:empty?).compact
|
15
|
+
Markdown.parse(@changelog).to_h
|
99
16
|
end
|
100
17
|
end
|
101
18
|
end
|
data/lib/reissue/printer.rb
CHANGED
@@ -25,8 +25,8 @@ module Reissue
|
|
25
25
|
{}
|
26
26
|
end
|
27
27
|
version_string = "## [#{version}] - #{date}"
|
28
|
-
changes_string = changes.map do |section,
|
29
|
-
format_section(section,
|
28
|
+
changes_string = changes.map do |section, section_changes|
|
29
|
+
format_section(section, section_changes)
|
30
30
|
end.join("\n\n")
|
31
31
|
[version_string, changes_string].filter_map { |str| str unless str.empty? }.join("\n\n")
|
32
32
|
end.then do |data|
|
data/lib/reissue/rake.rb
CHANGED
data/lib/reissue/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reissue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Gay
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- lib/reissue.rb
|
39
39
|
- lib/reissue/changelog_updater.rb
|
40
40
|
- lib/reissue/gem.rb
|
41
|
+
- lib/reissue/markdown.rb
|
41
42
|
- lib/reissue/parser.rb
|
42
43
|
- lib/reissue/printer.rb
|
43
44
|
- lib/reissue/rake.rb
|