reissue 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +38 -0
- data/Rakefile +28 -0
- data/lib/reissue/changelog_updater.rb +68 -0
- data/lib/reissue/version.rb +5 -0
- data/lib/reissue/version_updater.rb +74 -0
- data/lib/reissue.rb +35 -0
- metadata +67 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cea3fe8e5fffe1889e022f6acb6caf168c28e3af84c94639fbda06ce33dbf326
|
4
|
+
data.tar.gz: 68e0a7d97426359fdd708fbf147e62fc0904acaa93f245f3f1e4f39f7d1d940a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 87626ce0220e19646aab027249f9555a5c201767db04ab146b2bb962aad302423a2f067a93c8c9993d62bafd208de0ff470c9b45376e7030efa4b2fa6c1f1d08
|
7
|
+
data.tar.gz: 159120e2c1656e1d30470f57bb9c7f2914747f1d8fd8ae88d2fa6f17a9bff8267f7c29be71d0c49c21d6898cff850532578ab1a2263c5cbcb5a4d0266e254966
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# Change log
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/).
|
6
|
+
|
7
|
+
## 0.1.0 - 2024-04-11
|
8
|
+
### Added:
|
9
|
+
- Initial release
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 SOFware LLC
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Reissue
|
2
|
+
|
3
|
+
Prepare the releases of your Ruby gems with ease.
|
4
|
+
|
5
|
+
When creating versioned software, it is important to keep track of the changes and the versions that are released.
|
6
|
+
|
7
|
+
After each release of a gem, you should immediatly bump the version with a new number and update the changelog with a place
|
8
|
+
to capture the information about new changes.
|
9
|
+
|
10
|
+
Reissue helps you to prepare the next version of your project by providing tools which will update version numbers and
|
11
|
+
update the changelog with a new version and a date.
|
12
|
+
|
13
|
+
Use Reissue to prepare your first commit going into the new version.
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
Install the gem and add to the application's Gemfile by executing:
|
18
|
+
|
19
|
+
$ bundle add reissue
|
20
|
+
|
21
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
22
|
+
|
23
|
+
$ gem install reissue
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Build your own release with rake tasks provided by the gem. The following tasks are available:
|
28
|
+
|
29
|
+
- `rake reissue[segment]` - Prepare a new version for future work for the given version segment.
|
30
|
+
- `rake reissue:finalize` - Update the CHANGELOG.md file with a date for the latest version.
|
31
|
+
|
32
|
+
## Development
|
33
|
+
|
34
|
+
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.
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[SOFware]/reissue.
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << "test"
|
8
|
+
t.libs << "lib"
|
9
|
+
t.warning = true
|
10
|
+
t.test_files = FileList["test/**/test_*.rb"]
|
11
|
+
end
|
12
|
+
|
13
|
+
task default: :test
|
14
|
+
|
15
|
+
desc "Prepare the code for work on a new version."
|
16
|
+
task :reissue, [:segment] => ["build:checksum"] do |task, args|
|
17
|
+
require "reissue"
|
18
|
+
segment = args[:segment] || "patch"
|
19
|
+
Reissue.call(segment: segment, version_file: "lib/reissue/version.rb")
|
20
|
+
end
|
21
|
+
|
22
|
+
namespace :reissue do
|
23
|
+
task :finalize, [:date] do |task, args|
|
24
|
+
require "reissue"
|
25
|
+
date = args[:date] || Time.now.strftime("%Y-%m-%d")
|
26
|
+
Reissue.finalize(date, changelog_file: "CHANGELOG.md")
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require "keepachangelog"
|
2
|
+
|
3
|
+
module Reissue
|
4
|
+
# Updates the changelog file with new versions and changes.
|
5
|
+
class ChangelogUpdater
|
6
|
+
def initialize(changelog_file)
|
7
|
+
@changelog_file = changelog_file
|
8
|
+
@changelog = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_reader :changelog
|
12
|
+
|
13
|
+
# Updates the changelog with a new version and its changes.
|
14
|
+
#
|
15
|
+
# @param version [String] The version number.
|
16
|
+
# @param date [String] The release date (default: "Unreleased").
|
17
|
+
# @param changes [Hash] The changes for the version (default: {}).
|
18
|
+
# @param changelog_file [String] The path to the changelog file (default: @changelog_file).
|
19
|
+
def call(version, date: "Unreleased", changes: {}, changelog_file: @changelog_file)
|
20
|
+
update(version, date: date, changes: changes)
|
21
|
+
write(changelog_file)
|
22
|
+
changelog
|
23
|
+
end
|
24
|
+
|
25
|
+
def finalize(date: Date.today, changelog_file: @changelog_file)
|
26
|
+
@changelog = Keepachangelog::MarkdownParser.parse(File.read(changelog_file))
|
27
|
+
# find the highest version number and if it is unreleased, update the date
|
28
|
+
version = changelog["versions"].keys.max
|
29
|
+
version_date = changelog.dig("versions", version, "date")
|
30
|
+
if version_date.nil? || version_date == "Unreleased"
|
31
|
+
updated = changelog["versions"].delete(version)
|
32
|
+
new_version = version.sub(/\s-.*/, "")
|
33
|
+
changelog["versions"][new_version] = updated.merge("date" => date)
|
34
|
+
end
|
35
|
+
write(changelog_file)
|
36
|
+
changelog
|
37
|
+
end
|
38
|
+
|
39
|
+
# Updates the changelog with a new version and its changes.
|
40
|
+
#
|
41
|
+
# @param version [String] The version number.
|
42
|
+
# @param date [String] The release date (default: "Unreleased").
|
43
|
+
# @param changes [Hash] The changes for the version (default: {}).
|
44
|
+
def update(version, date: "Unreleased", changes: {})
|
45
|
+
@changelog = Keepachangelog::MarkdownParser.parse(File.read(@changelog_file))
|
46
|
+
|
47
|
+
changelog["versions"][version] = { "date" => date, "changes" => changes }
|
48
|
+
changes.each do |section, change|
|
49
|
+
changelog["versions"][version]["changes"][section] = change
|
50
|
+
end
|
51
|
+
changelog
|
52
|
+
end
|
53
|
+
|
54
|
+
# Returns the string representation of the changelog.
|
55
|
+
#
|
56
|
+
# @return [String] The Markdown string representation of the changelog.
|
57
|
+
def to_s
|
58
|
+
Keepachangelog::MarkdownPrinter.new(changelog["versions"]).to_s
|
59
|
+
end
|
60
|
+
|
61
|
+
# Writes the changelog to the specified file.
|
62
|
+
#
|
63
|
+
# @param changelog_file [String] The path to the changelog file (default: @changelog_file).
|
64
|
+
def write(changelog_file = @changelog_file)
|
65
|
+
File.write(changelog_file, to_s)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Reissue
|
2
|
+
# Provides versioning functionality for the application.
|
3
|
+
module Versioning
|
4
|
+
# Provides versioning functionality for the application.
|
5
|
+
refine Gem::Version do
|
6
|
+
# Redoes the version based on the specified segment_name.
|
7
|
+
#
|
8
|
+
# @param segment_name [Symbol] The segment_name to redo the version.
|
9
|
+
# Possible values are :major, :minor, or any other symbol.
|
10
|
+
# @return [Gem::Version] The updated version.
|
11
|
+
def redo(segment_name)
|
12
|
+
if segment_name.to_s == "major"
|
13
|
+
Gem::Version.new("#{segments[0].to_i + 1}.0.0")
|
14
|
+
elsif segment_name.to_s == "minor"
|
15
|
+
Gem::Version.new("#{segments[0]}.#{segments[1].to_i + 1}.0")
|
16
|
+
else
|
17
|
+
Gem::Version.new("#{segments[0]}.#{segments[1]}.#{segments[2].to_i + 1}")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class VersionUpdater
|
24
|
+
using Versioning
|
25
|
+
|
26
|
+
# Initializes a new instance of the VersionUpdater class.
|
27
|
+
#
|
28
|
+
# @param version_file [String] The path to the version file.
|
29
|
+
def initialize(version_file)
|
30
|
+
@version_file = version_file
|
31
|
+
@original_version = nil
|
32
|
+
@new_version = nil
|
33
|
+
@updated_body = ""
|
34
|
+
end
|
35
|
+
|
36
|
+
# Updates the version segment and writes the updated version to the file.
|
37
|
+
#
|
38
|
+
# This allows you to read from one file and write to another.
|
39
|
+
#
|
40
|
+
# @param segment [Symbol] The segment to update (:major, :minor, or :patch).
|
41
|
+
# @param version_file [String] The version_file to the version file (optional, defaults to @version_file).
|
42
|
+
# @return [String] The updated version string.
|
43
|
+
def call(segment, version_file: @version_file)
|
44
|
+
update(segment)
|
45
|
+
write(version_file)
|
46
|
+
@new_version
|
47
|
+
end
|
48
|
+
|
49
|
+
# Updates the specified segment of the version string.
|
50
|
+
#
|
51
|
+
# @param segment [Symbol] The segment to update (:major, :minor, or :patch).
|
52
|
+
# @return [String] The updated version string.
|
53
|
+
def update(segment)
|
54
|
+
version_file = File.read(@version_file)
|
55
|
+
@updated_body = version_file.gsub(version_regex) do |string|
|
56
|
+
@original_version = Gem::Version.new(string)
|
57
|
+
@new_version = Gem::Version.new(string).redo(segment).to_s
|
58
|
+
end
|
59
|
+
@new_version
|
60
|
+
end
|
61
|
+
|
62
|
+
# Regular expression pattern for matching the version string.
|
63
|
+
#
|
64
|
+
# @return [Regexp] The version regex pattern.
|
65
|
+
def version_regex = /(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)/
|
66
|
+
|
67
|
+
# Writes the updated version to the specified file.
|
68
|
+
#
|
69
|
+
# @param version_file [String] The version_file to the version file (optional, defaults to @version_file).
|
70
|
+
def write(version_file = @version_file)
|
71
|
+
File.write(version_file, @updated_body)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/lib/reissue.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "reissue/version"
|
4
|
+
require_relative "reissue/version_updater"
|
5
|
+
require_relative "reissue/changelog_updater"
|
6
|
+
|
7
|
+
# Reissue is a module that provides functionality for updating version numbers and changelogs.
|
8
|
+
module Reissue
|
9
|
+
# Updates the version number and changelog.
|
10
|
+
#
|
11
|
+
# @param version_file [String] The path to the version file.
|
12
|
+
# @param changelog_file [String] The path to the changelog file.
|
13
|
+
# @param segment [String] The segment of the version number to update.
|
14
|
+
# @param date [String] The release date.
|
15
|
+
# @param changes [Hash] The changes made in this release.
|
16
|
+
# @return [String] The new version number.
|
17
|
+
def self.call(version_file:, changelog_file: "CHANGELOG.md", segment: "patch", date: "Unreleased", changes: {})
|
18
|
+
version_updater = VersionUpdater.new(version_file)
|
19
|
+
new_version = version_updater.call(segment, version_file:)
|
20
|
+
if changelog_file
|
21
|
+
changelog_updater = ChangelogUpdater.new(changelog_file)
|
22
|
+
changelog_updater.call(new_version, date:, changes:, changelog_file:)
|
23
|
+
end
|
24
|
+
new_version
|
25
|
+
end
|
26
|
+
|
27
|
+
# Finalizes the changelog for an unreleased version to set the release date.
|
28
|
+
#
|
29
|
+
# @param date [String] The release date.
|
30
|
+
# @param changelog_file [String] The path to the changelog file.
|
31
|
+
def self.finalize(date = Date.today, changelog_file: "CHANGELOG.md")
|
32
|
+
changelog_updater = ChangelogUpdater.new(changelog_file)
|
33
|
+
changelog_updater.finalize(date:, changelog_file:)
|
34
|
+
end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: reissue
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jim Gay
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-04-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: keepachangelog
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: This gem helps you to prepare for releases of new versions of your code.
|
28
|
+
email:
|
29
|
+
- jim@saturnflyer.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- CHANGELOG.md
|
35
|
+
- LICENSE.txt
|
36
|
+
- README.md
|
37
|
+
- Rakefile
|
38
|
+
- lib/reissue.rb
|
39
|
+
- lib/reissue/changelog_updater.rb
|
40
|
+
- lib/reissue/version.rb
|
41
|
+
- lib/reissue/version_updater.rb
|
42
|
+
homepage: https://github.com/SOFware/reissue
|
43
|
+
licenses: []
|
44
|
+
metadata:
|
45
|
+
homepage_uri: https://github.com/SOFware/reissue
|
46
|
+
source_code_uri: https://github.com/SOFware/reissue
|
47
|
+
changelog_uri: https://github.com/SOFware/reissue/blob/main/CHANGELOG.md
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 3.0.0
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubygems_version: 3.5.5
|
64
|
+
signing_key:
|
65
|
+
specification_version: 4
|
66
|
+
summary: Keep your versions and changelogs up to date and prepared for release.
|
67
|
+
test_files: []
|