reissue 0.1.5 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe285dfda18d82a77561abf6281b96f1fb2e3739cbbf5c7b6b072f6e3fe12c94
4
- data.tar.gz: 36c3e171e17214892f9cef24724c3c901cc56406c39218a4239a656ac02a354e
3
+ metadata.gz: c277981b6bc7dc46a2ae0d84bddd6b8f04a7328d2bd0949d380bb948cb3acbff
4
+ data.tar.gz: d9078fed64c4fc984e150a6c03bcdcd912663e3f8c9d550b571b8ba77b55a644
5
5
  SHA512:
6
- metadata.gz: 189dbe15b33aff0e110d5b823e24cbc8444242f90a7f2e5543a7cce414213d428795dac6c7fedbe1e7eef6b1786238ecae61b4e0ae5e56947ee1e2ef77bac4cd
7
- data.tar.gz: 39a8b27c26db53c0fe31ac39b0b6d0c5cef559bb67d3100b585ab5ee01a29b83907eb3241118dd481e8572647107f27101926ee11144cb1281f64176379f1ff3
6
+ metadata.gz: 3d1677cb2633cc8b3b19c5842fb7edbc7ef46e6f8299b5a8886385822ad07f2657f2f3ff44c77a0bb68027c3227a4ce8ec298bd00b8d585f765368f2a64f4673
7
+ data.tar.gz: 27d09c82326c667a357cd77c8f1536dbb163e72445ff6b1d02f97738a1bcc0ba28080e74f2ab2e21d6cf42fbf3c43c0e6b54607b9c4052e7791603f47c14e046
data/CHANGELOG.md CHANGED
@@ -5,15 +5,18 @@ 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.5] - 2024-06-09
8
+ ## [0.1.7] - 2024-06-10
9
9
 
10
10
  ### Fixed
11
11
 
12
- - Fixed incorrect handling of missing empty last line
12
+ - Pass the version_redo_proc to the Reissue.call in the reissue task.
13
13
 
14
- ## [0.1.4] - 2024-06-09
14
+ ## [0.1.6] - 2024-06-10
15
+
16
+ ### Added
17
+
18
+ - The ability to specify the version_redo_proc to customize the version number update process.
15
19
 
16
20
  ### Fixed
17
21
 
18
- - Handle changlog files without an empty last line
19
- - Handle empty version_limit in reformat task
22
+ - Incorrect testing of Reissue.reformat
data/README.md CHANGED
@@ -80,26 +80,31 @@ require "reissue/rake"
80
80
 
81
81
  Reissue::Task.create :your_name_and_namespace do |task|
82
82
 
83
- # Required: The file to update with the new version number.
84
- task.version_file = "path/to/version.rb"
85
-
86
83
  # Optional: The name of the task. Defaults to "reissue".
87
84
  task.name = "your_name_and_namespace"
88
85
 
89
- # Optional: The description of the task.
86
+ # Optional: The description of the main task.
90
87
  task.description = "Prepare the next version of the gem."
91
88
 
92
- # Optional: The file to update with the new version number.
93
- task.changelog_file = "path/to/CHANGELOG.md"
89
+ # Required: The file to update with the new version number.
90
+ task.version_file = "path/to/version.rb"
94
91
 
95
92
  # Optional: The number of versions to maintain in the changelog.
96
93
  task.version_limit = 5
97
94
 
95
+ # Optional: A Proc to format the version number. Receives a Gem::Version object, and segment.
96
+ task.version_redo_proc = ->(version, segment) do
97
+ # your special versioning logic
98
+ end
99
+
100
+ # Optional: The file to update with the new version number.
101
+ task.changelog_file = "path/to/CHANGELOG.md"
102
+
98
103
  # Optional: Whether to commit the changes automatically. Defaults to true.
99
104
  task.commit = false
100
105
 
101
106
  # Optional: Whether or not to commit the results of the finalize task. Defaults to true.
102
- task.finalize_commit = false
107
+ task.commit_finalize = false
103
108
  end
104
109
  ```
105
110
 
data/lib/reissue/rake.rb CHANGED
@@ -22,15 +22,18 @@ module Reissue
22
22
  # The path to the version file. Required.
23
23
  attr_accessor :version_file
24
24
 
25
+ # The number of versions to retain in the changelog file. Defaults to 2.
26
+ attr_accessor :version_limit
27
+
28
+ # A proc that can be used to create the new version string.
29
+ attr_accessor :version_redo_proc
30
+
25
31
  # The path to the changelog file.
26
32
  attr_accessor :changelog_file
27
33
 
28
34
  # Additional paths to add to the commit.
29
35
  attr_accessor :updated_paths
30
36
 
31
- # The number of versions to retain in the changelog file. Defaults to 2.
32
- attr_accessor :version_limit
33
-
34
37
  # Whether to commit the changes. Default: true.
35
38
  attr_accessor :commit
36
39
 
@@ -46,13 +49,14 @@ module Reissue
46
49
  @commit = true
47
50
  @commit_finalize = true
48
51
  @version_limit = 2
52
+ @version_redo_proc = nil
49
53
  end
50
54
 
51
55
  def define
52
56
  desc description
53
57
  task name, [:segment] do |task, args|
54
58
  segment = args[:segment] || "patch"
55
- new_version = Reissue.call(segment:, version_file:, version_limit:)
59
+ new_version = Reissue.call(segment:, version_file:, version_limit:, version_redo_proc:)
56
60
  if defined?(Bundler)
57
61
  Bundler.with_unbundled_env do
58
62
  system("bundle install")
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Reissue
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.7"
5
5
  end
@@ -56,11 +56,12 @@ module Reissue
56
56
  # Initializes a new instance of the VersionUpdater class.
57
57
  #
58
58
  # @param version_file [String] The path to the version file.
59
- def initialize(version_file)
59
+ def initialize(version_file, version_redo_proc: nil)
60
60
  @version_file = version_file
61
61
  @original_version = nil
62
62
  @new_version = nil
63
63
  @updated_body = ""
64
+ @version_redo_proc = version_redo_proc
64
65
  end
65
66
 
66
67
  # Updates the version segment and writes the updated version to the file.
@@ -76,6 +77,18 @@ module Reissue
76
77
  @new_version
77
78
  end
78
79
 
80
+ # A proc that can be used to redo the version string.
81
+ attr_accessor :version_redo_proc
82
+
83
+ # Creates a new version string based on the original version and the specified segment.
84
+ def redo(version, segment)
85
+ if version_redo_proc
86
+ version_redo_proc.call(version, segment)
87
+ else
88
+ version.redo(segment)
89
+ end
90
+ end
91
+
79
92
  # Updates the specified segment of the version string.
80
93
  #
81
94
  # @param segment [Symbol] The segment to update (:major, :minor, or :patch).
@@ -84,7 +97,7 @@ module Reissue
84
97
  version_file = File.read(@version_file)
85
98
  @updated_body = version_file.gsub(version_regex) do |string|
86
99
  @original_version = ::Gem::Version.new(string)
87
- @new_version = ::Gem::Version.new(string).redo(segment).to_s
100
+ @new_version = self.redo(::Gem::Version.new(string), segment).to_s
88
101
  end
89
102
  @new_version
90
103
  end
data/lib/reissue.rb CHANGED
@@ -22,9 +22,10 @@ module Reissue
22
22
  segment: "patch",
23
23
  date: "Unreleased",
24
24
  changes: {},
25
- version_limit: 2
25
+ version_limit: 2,
26
+ version_redo_proc: nil
26
27
  )
27
- version_updater = VersionUpdater.new(version_file)
28
+ version_updater = VersionUpdater.new(version_file, version_redo_proc:)
28
29
  new_version = version_updater.call(segment, version_file:)
29
30
  if changelog_file
30
31
  changelog_updater = ChangelogUpdater.new(changelog_file)
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.5
4
+ version: 0.1.7
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-06-09 00:00:00.000000000 Z
11
+ date: 2024-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake