gem_hadar 2.12.0 → 2.13.0
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/gem_hadar.gemspec +3 -3
- data/lib/gem_hadar/changelog_generator.rb +47 -1
- data/lib/gem_hadar/version.rb +1 -1
- data/lib/gem_hadar/warn.rb +18 -1
- data/lib/gem_hadar.rb +97 -29
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0b073276ec181a5e9a9b2683fe8da14ac53c41f9234c643920883e575d7bc843
|
|
4
|
+
data.tar.gz: 805eb33b1fcbd4adc8b2c14dfc56a8d2c38564331d7534ebf5220355f8388920
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2ca31b3c96e97f75ac16187337814ac43cc876c873342a0fb78daf4eaaecdfb3c1e56fd0ea3dc55ba657798e1b88e58a2084555b5e962891713b32397d9e4c9b
|
|
7
|
+
data.tar.gz: 97013a6905db1762f5f0c19fdfa329e1db0311f0d5044f6a0810a5ac89cf5e6133667c84af098c2c3dc9917eeb8876d55d4b5500f03d8d0f53c4cc5b8902fd79
|
data/gem_hadar.gemspec
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
# stub: gem_hadar 2.
|
|
2
|
+
# stub: gem_hadar 2.13.0 ruby lib
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
5
|
s.name = "gem_hadar".freeze
|
|
6
|
-
s.version = "2.
|
|
6
|
+
s.version = "2.13.0".freeze
|
|
7
7
|
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
|
9
9
|
s.require_paths = ["lib".freeze]
|
|
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
|
|
|
23
23
|
|
|
24
24
|
s.specification_version = 4
|
|
25
25
|
|
|
26
|
-
s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 2.
|
|
26
|
+
s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 2.13".freeze])
|
|
27
27
|
s.add_development_dependency(%q<all_images>.freeze, [">= 0".freeze])
|
|
28
28
|
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.13".freeze])
|
|
29
29
|
s.add_development_dependency(%q<simplecov>.freeze, [">= 0".freeze])
|
|
@@ -134,7 +134,7 @@ class GemHadar
|
|
|
134
134
|
|
|
135
135
|
changelog = generate_changelog(versions, changelog:)
|
|
136
136
|
|
|
137
|
-
changelog
|
|
137
|
+
changelog.unshift "# Changes\n"
|
|
138
138
|
|
|
139
139
|
output << changelog.join("")
|
|
140
140
|
end
|
|
@@ -167,8 +167,54 @@ class GemHadar
|
|
|
167
167
|
inject_into_filename(filename, changelog)
|
|
168
168
|
end
|
|
169
169
|
|
|
170
|
+
# The changelog_exist? method checks whether a changelog file exists in the
|
|
171
|
+
# project.
|
|
172
|
+
#
|
|
173
|
+
# This method verifies the presence of a changelog file by checking if the
|
|
174
|
+
# file path determined by changelog_filename exists in the filesystem.
|
|
175
|
+
#
|
|
176
|
+
# @return [ TrueClass, FalseClass ] true if the changelog file exists,
|
|
177
|
+
# false otherwise
|
|
178
|
+
def changelog_exist?
|
|
179
|
+
changelog_filename.exist?
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
# The changelog_version_added? method checks whether a specific version has
|
|
183
|
+
# already been added to the changelog file.
|
|
184
|
+
#
|
|
185
|
+
# This method verifies if a given version is present in the changelog file
|
|
186
|
+
# by examining each line for a match with the version tag.
|
|
187
|
+
#
|
|
188
|
+
# @param version [ String ] the version to check for in the changelog
|
|
189
|
+
#
|
|
190
|
+
# @return [ TrueClass, FalseClass ] true if the version is found in the
|
|
191
|
+
# changelog, false otherwise
|
|
192
|
+
#
|
|
193
|
+
# @raise [ ArgumentError ] if the changelog file does not exist
|
|
194
|
+
def changelog_version_added?(version)
|
|
195
|
+
version = GemHadar::VersionSpec[version]
|
|
196
|
+
changelog_exist? or
|
|
197
|
+
raise ArgumentError, "Changelog #{changelog_filename.to_s} doesn't exist!"
|
|
198
|
+
File.new(changelog_filename).any? do |line|
|
|
199
|
+
line =~ /#{version.tag}/ and return true
|
|
200
|
+
end
|
|
201
|
+
false
|
|
202
|
+
end
|
|
203
|
+
|
|
170
204
|
private
|
|
171
205
|
|
|
206
|
+
# The changelog_filename method returns the Pathname object for the
|
|
207
|
+
# changelog file path.
|
|
208
|
+
#
|
|
209
|
+
# This method accesses the changelog_filename attribute from the associated
|
|
210
|
+
# GemHadar instance and wraps it in a Pathname object for convenient file
|
|
211
|
+
# path manipulation.
|
|
212
|
+
#
|
|
213
|
+
# @return [ Pathname ] the Pathname object representing the changelog file path
|
|
214
|
+
def changelog_filename
|
|
215
|
+
Pathname.new(@gem_hadar.changelog_filename)
|
|
216
|
+
end
|
|
217
|
+
|
|
172
218
|
# The ollama_generate method delegates AI generation requests to the
|
|
173
219
|
# associated GemHadar instance.
|
|
174
220
|
#
|
data/lib/gem_hadar/version.rb
CHANGED
data/lib/gem_hadar/warn.rb
CHANGED
|
@@ -29,7 +29,7 @@ class GemHadar
|
|
|
29
29
|
# @param msgs [ Array<String> ] the array of message strings to display as warnings
|
|
30
30
|
def warn(*msgs)
|
|
31
31
|
msgs.map! do |a|
|
|
32
|
-
a.respond_to?(:to_str) ? color(
|
|
32
|
+
a.respond_to?(:to_str) ? color(220) { a.to_str } : a
|
|
33
33
|
end
|
|
34
34
|
super(*msgs, uplevel: 1)
|
|
35
35
|
end
|
|
@@ -49,5 +49,22 @@ class GemHadar
|
|
|
49
49
|
end
|
|
50
50
|
super(*msgs)
|
|
51
51
|
end
|
|
52
|
+
|
|
53
|
+
# The abort method formats and displays failure messages using red colored
|
|
54
|
+
# output.
|
|
55
|
+
#
|
|
56
|
+
# This method takes an array of message objects, applies red color formatting
|
|
57
|
+
# to string representations of the messages, and then passes them to the
|
|
58
|
+
# superclass's abort method for display. The uplevel: 1 option ensures that
|
|
59
|
+
# the failure message originates from the caller's context rather than from
|
|
60
|
+
# within this method itself.
|
|
61
|
+
#
|
|
62
|
+
# @param msgs [ Array<Object> ] the array of message objects to display as failures
|
|
63
|
+
def abort(*msgs)
|
|
64
|
+
msgs.map! do |a|
|
|
65
|
+
a.respond_to?(:to_str) ? color(208) { a.to_str } : a
|
|
66
|
+
end
|
|
67
|
+
super(*msgs)
|
|
68
|
+
end
|
|
52
69
|
end
|
|
53
70
|
end
|
data/lib/gem_hadar.rb
CHANGED
|
@@ -598,6 +598,17 @@ class GemHadar
|
|
|
598
598
|
@rvm
|
|
599
599
|
end
|
|
600
600
|
|
|
601
|
+
# The changelog_filename attribute accessor for configuring the gem's
|
|
602
|
+
# changelog file name.
|
|
603
|
+
#
|
|
604
|
+
# This method sets up a DSL accessor for the changelog_filename attribute,
|
|
605
|
+
# which specifies the name of the changelog file to be used in the project.
|
|
606
|
+
# It provides a way to define a custom changelog filename that will be used
|
|
607
|
+
# during documentation generation and version management tasks.
|
|
608
|
+
#
|
|
609
|
+
# @return [ String, nil ] the name of the changelog file or nil if disabled.
|
|
610
|
+
dsl_accessor :changelog_filename
|
|
611
|
+
|
|
601
612
|
# The default_task_dependencies method manages the list of dependencies for
|
|
602
613
|
# the default Rake task.
|
|
603
614
|
#
|
|
@@ -913,8 +924,7 @@ class GemHadar
|
|
|
913
924
|
task :update do
|
|
914
925
|
answer = ask?("Which gem_hadar version? ", /^((?:\d+.){2}(?:\d+))$/)
|
|
915
926
|
unless answer
|
|
916
|
-
|
|
917
|
-
exit 1
|
|
927
|
+
abort "Invalid version specification!"
|
|
918
928
|
end
|
|
919
929
|
gem_hadar_version = answer[0]
|
|
920
930
|
filename = "#{name}.gemspec"
|
|
@@ -1099,6 +1109,37 @@ class GemHadar
|
|
|
1099
1109
|
end
|
|
1100
1110
|
end
|
|
1101
1111
|
|
|
1112
|
+
# The version_tag_local method retrieves the Git revision hash for the current version tag
|
|
1113
|
+
#
|
|
1114
|
+
# This method executes a Git command to obtain the full revision hash (commit SHA) associated
|
|
1115
|
+
# with the current gem version tag. It constructs the tag name using the GemHadar::VersionSpec
|
|
1116
|
+
# class and then uses Git's rev-parse command to resolve the tag to its corresponding commit.
|
|
1117
|
+
#
|
|
1118
|
+
# @return [ String ] the Git revision hash for the current version tag
|
|
1119
|
+
# @return [ String ] an empty string if the Git command fails
|
|
1120
|
+
# @return [ String ] the output of the Git rev-parse command as a string
|
|
1121
|
+
def version_tag_local
|
|
1122
|
+
`git show-ref #{GemHadar::VersionSpec[version].tag.inspect}`.
|
|
1123
|
+
chomp.sub(/\s.*/, '').full?
|
|
1124
|
+
end
|
|
1125
|
+
memoize method: :version_tag_local
|
|
1126
|
+
|
|
1127
|
+
# The version_tag_remote method retrieves the Git revision hash for the remote version tag
|
|
1128
|
+
#
|
|
1129
|
+
# This method executes a Git command to obtain the full revision hash (commit SHA) associated
|
|
1130
|
+
# with the current gem version tag on the remote repository. It constructs the tag name using
|
|
1131
|
+
# the GemHadar::VersionSpec class and then uses Git's ls-remote command to resolve the tag
|
|
1132
|
+
# to its corresponding commit on the specified remote.
|
|
1133
|
+
#
|
|
1134
|
+
# @return [ String ] the Git revision hash for the remote version tag
|
|
1135
|
+
# @return [ String ] an empty string if the Git command fails or no remote tag is found
|
|
1136
|
+
# @return [ String ] the output of the Git ls-remote command as a string
|
|
1137
|
+
def version_tag_remote
|
|
1138
|
+
`git ls-remote --tags #{git_remote} #{GemHadar::VersionSpec[version].tag.inspect}`.
|
|
1139
|
+
chomp.sub(/\s.*/, '').full?
|
|
1140
|
+
end
|
|
1141
|
+
memoize method: :version_tag_remote
|
|
1142
|
+
|
|
1102
1143
|
# The version_tag_task method defines a Rake task that creates a Git tag for
|
|
1103
1144
|
# the current version.
|
|
1104
1145
|
#
|
|
@@ -1110,24 +1151,29 @@ class GemHadar
|
|
|
1110
1151
|
# overwrite it forcefully.
|
|
1111
1152
|
def version_tag_task
|
|
1112
1153
|
namespace :version do
|
|
1154
|
+
namespace :tag do
|
|
1155
|
+
desc "show local tag revision"
|
|
1156
|
+
task :local do
|
|
1157
|
+
system 'git fetch --tags'
|
|
1158
|
+
puts version_tag_local
|
|
1159
|
+
end
|
|
1160
|
+
|
|
1161
|
+
desc "show remote tag revision"
|
|
1162
|
+
task :remote do
|
|
1163
|
+
puts version_tag_remote
|
|
1164
|
+
end
|
|
1165
|
+
end
|
|
1166
|
+
|
|
1113
1167
|
desc "Tag this commit as version #{version}"
|
|
1114
|
-
task :tag do
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
else
|
|
1122
|
-
if ask?("Different version tag #{version} already exists. Overwrite with "\
|
|
1123
|
-
"force? (yes/NO) ", /\Ayes\z/i)
|
|
1124
|
-
force = true
|
|
1125
|
-
retry
|
|
1126
|
-
else
|
|
1127
|
-
exit 1
|
|
1128
|
-
end
|
|
1129
|
-
end
|
|
1168
|
+
task :tag => :modified do
|
|
1169
|
+
version_spec = GemHadar::VersionSpec[version]
|
|
1170
|
+
if sha = version_tag_remote
|
|
1171
|
+
abort <<~EOT.chomp
|
|
1172
|
+
Remote version tag #{version_spec.tag.inspect} already exists and points to #{sha.inspect}!"
|
|
1173
|
+
Call version:bump first to create a new version before release.
|
|
1174
|
+
EOT
|
|
1130
1175
|
end
|
|
1176
|
+
sh "git tag -a -m 'Version #{version_spec.untag}' -f #{version_spec.tag.inspect}"
|
|
1131
1177
|
end
|
|
1132
1178
|
end
|
|
1133
1179
|
end
|
|
@@ -1258,8 +1304,7 @@ class GemHadar
|
|
|
1258
1304
|
exit 1
|
|
1259
1305
|
end
|
|
1260
1306
|
else
|
|
1261
|
-
|
|
1262
|
-
exit 1
|
|
1307
|
+
abort "Cannot push gem to rubygems: #{path.inspect} doesn't exist."
|
|
1263
1308
|
end
|
|
1264
1309
|
end
|
|
1265
1310
|
end
|
|
@@ -1346,6 +1391,23 @@ class GemHadar
|
|
|
1346
1391
|
end
|
|
1347
1392
|
end
|
|
1348
1393
|
|
|
1394
|
+
# The modified_task method defines a Rake task that checks for uncommitted
|
|
1395
|
+
# changes in the Git repository
|
|
1396
|
+
#
|
|
1397
|
+
# This method creates a Rake task named :modified that runs a Git status
|
|
1398
|
+
# command to identify any modified files that are not yet committed. If any
|
|
1399
|
+
# changed files are found, it aborts the task execution and displays a
|
|
1400
|
+
# message
|
|
1401
|
+
# listing all the uncommitted files
|
|
1402
|
+
def modified_task
|
|
1403
|
+
task :modified do
|
|
1404
|
+
changed_files = `git status --porcelain`.gsub(/^\s*\S\s+/, '').lines
|
|
1405
|
+
unless changed_files.empty?
|
|
1406
|
+
abort "There are still modified files:\n#{changed_files * ''}"
|
|
1407
|
+
end
|
|
1408
|
+
end
|
|
1409
|
+
end
|
|
1410
|
+
|
|
1349
1411
|
# The push_task_dependencies method manages the list of dependencies for the push task.
|
|
1350
1412
|
#
|
|
1351
1413
|
# This method sets up a DSL accessor for the push_task_dependencies attribute,
|
|
@@ -1373,13 +1435,7 @@ class GemHadar
|
|
|
1373
1435
|
gem_push_task
|
|
1374
1436
|
git_remotes_task
|
|
1375
1437
|
github_release_task
|
|
1376
|
-
|
|
1377
|
-
changed_files = `git status --porcelain`.gsub(/^\s*\S\s+/, '').lines
|
|
1378
|
-
unless changed_files.empty?
|
|
1379
|
-
warn "There are still modified files:\n#{changed_files * ''}"
|
|
1380
|
-
exit 1
|
|
1381
|
-
end
|
|
1382
|
-
end
|
|
1438
|
+
modified_task
|
|
1383
1439
|
desc "Push all changes for version #{version} into the internets."
|
|
1384
1440
|
task :push => push_task_dependencies
|
|
1385
1441
|
end
|
|
@@ -1393,7 +1449,7 @@ class GemHadar
|
|
|
1393
1449
|
# with a single command.
|
|
1394
1450
|
def release_task
|
|
1395
1451
|
desc "Release the new version #{version} for the gem #{name}."
|
|
1396
|
-
task :release => :push
|
|
1452
|
+
task :release => [ :'changes:added', :push ]
|
|
1397
1453
|
end
|
|
1398
1454
|
|
|
1399
1455
|
# The compile_task method sets up a Rake task to compile project extensions.
|
|
@@ -1606,6 +1662,7 @@ class GemHadar
|
|
|
1606
1662
|
# - :changes:range - Show changes for a specific Git range
|
|
1607
1663
|
# - :changes:full - Generate complete changelog from first tag
|
|
1608
1664
|
# - :changes:add - Append to existing changelog file
|
|
1665
|
+
# - :changes:added - Check if the current version was added to changelog file
|
|
1609
1666
|
def changes_task
|
|
1610
1667
|
namespace :changes do
|
|
1611
1668
|
desc 'Show changes since last version tag'
|
|
@@ -1670,9 +1727,18 @@ class GemHadar
|
|
|
1670
1727
|
|
|
1671
1728
|
desc 'Append new entries to existing changelog file'
|
|
1672
1729
|
task :add do
|
|
1673
|
-
filename = ARGV[1]
|
|
1730
|
+
filename = ARGV[1] || changelog_filename
|
|
1731
|
+
filename or raise 'Need file to add to'
|
|
1674
1732
|
GemHadar::ChangelogGenerator.new(self).add_to_file(filename)
|
|
1675
1733
|
end
|
|
1734
|
+
|
|
1735
|
+
desc 'Check if current version was added to the changelog'
|
|
1736
|
+
task :added do
|
|
1737
|
+
changelog_filename or next
|
|
1738
|
+
GemHadar::ChangelogGenerator.new(self).changelog_version_added?(version) and next
|
|
1739
|
+
abort "Version #{GemHadar::VersionSpec[version].untag} has not been "\
|
|
1740
|
+
"documented in changelog #{changelog_filename.inspect} file."
|
|
1741
|
+
end
|
|
1676
1742
|
end
|
|
1677
1743
|
|
|
1678
1744
|
# Main changes task that shows help when called directly
|
|
@@ -1685,6 +1751,7 @@ class GemHadar
|
|
|
1685
1751
|
rake changes:range <range> Show changes for a specific Git range (e.g., v1.0.0..v1.2.0)
|
|
1686
1752
|
rake changes:full [file] Generate complete changelog from first tag
|
|
1687
1753
|
rake changes:add <file> Append new entries to existing changelog file
|
|
1754
|
+
rake changes:added Check if current version was added to changelog
|
|
1688
1755
|
|
|
1689
1756
|
Examples:
|
|
1690
1757
|
rake changes:pending
|
|
@@ -1693,6 +1760,7 @@ class GemHadar
|
|
|
1693
1760
|
rake changes:full
|
|
1694
1761
|
rake changes:full CHANGES.md
|
|
1695
1762
|
rake changes:add CHANGES.md
|
|
1763
|
+
rake changes:added
|
|
1696
1764
|
EOT
|
|
1697
1765
|
end
|
|
1698
1766
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gem_hadar
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.13.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Florian Frank
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - "~>"
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '2.
|
|
18
|
+
version: '2.13'
|
|
19
19
|
type: :development
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: '2.
|
|
25
|
+
version: '2.13'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: all_images
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|