gem_hadar 1.25.0 → 1.26.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5277b0542113dc8de861927c702b9a17c0dc30fc000b0aad88f77559177bd562
4
- data.tar.gz: 32cfd43ba8dd14a74fd0db9cfba009851866f22bb78decd0dd6cbdd0f3cb9b62
3
+ metadata.gz: f3fefed7b5fd9123e2944de9cf2defcd9f1794aaa7d0058621539b22a2e076d3
4
+ data.tar.gz: 8734f8f3cf30c0a0b501e5484a58bc5b4bbc4190258133f6de7b1105f17c7383
5
5
  SHA512:
6
- metadata.gz: a77a1a309790aac939d7aff2f3973c495baa92a3d36e3443747e7243aa0a6e09781a7162ddde5e36868316b85db3ab58c20bcb3f137b818dc5f458ed3b741fd1
7
- data.tar.gz: 8754d4b122caf5a5df4af137097440e84a4841f8c0b83fec7e635716997c59cbba36671e6b6b03230dbe1bceb319e131fbfb9c2734a155c8d5771692bfe31289
6
+ metadata.gz: 867a63019ba90544ba9b0c91478482128d3527221d9c11473929d9f18b5c74673d2fc3ab5844bc26779680b724965a9a7a455518286c5ca9a496342371c31c1a
7
+ data.tar.gz: a6fa278536336a668d025947b3d9f274d4cc02ae9e2a3d50bb2a2a87b42ee2d351bfb191d9eb472bd215b521c34b561c4ee5d9f15cfcec93576f98871df23c10
data/README.md CHANGED
@@ -2,7 +2,76 @@
2
2
 
3
3
  ## Description
4
4
 
5
- Ruby library that provides support for building gems.
5
+ The `gem_hadar` gem is a Ruby library that provides support for building gems
6
+ using rake tasks. It is a comprehensive Ruby gem automation tool that provides:
7
+
8
+ - **Automated gem building and packaging** - Complete build workflows with
9
+ 🛠️Rake task orchestration
10
+ - **Git workflow automation** - Version management, tagging, remote operations,
11
+ and repository setup with 🔄git integration
12
+ - **GitHub release management** - Automated release creation with 🤖AI-powered
13
+ changelog generation using Ollama
14
+ - **Testing framework integration** - Built-in support for RSpec, Test::Unit,
15
+ and RCov code coverage testing with 🧪testing tools
16
+ - **Documentation generation** - YARD integration with private/public
17
+ documentation tasks and coverage reporting with 📚documentation
18
+ - **RVM configuration management** - Automatic .rvmrc file generation for
19
+ consistent development environments with 🎯RVM setup
20
+ - **CI/CD pipeline capabilities** - Complete workflows from build to publish
21
+ with dependency management using ⚙️CI/CD automation
22
+ - **Semantic versioning automation** - 👾AI-powered version bump suggestions
23
+ based on code changes
24
+ - **Extension compilation support** - Automatic compilation of C extensions
25
+ when needed with 🏗️extension building
26
+ - **DSL-based configuration** - Simple block syntax in Rakefile for easy
27
+ workflow setup with 📝configuration
28
+ - **Gemfile and .gitignore automation** - Automatic creation and management of
29
+ essential project files with 📦dependency management
30
+
31
+ ## Workflow Diagrams
32
+
33
+ ### Gem Build Process
34
+ ```mermaid
35
+ graph LR
36
+ A[Source Code] --> B[Gemfile Setup]
37
+ B --> C[Bundle Install]
38
+ C --> D[Run Tests]
39
+ D --> E[Generate Documentation]
40
+ E --> F[Build Gem]
41
+ F --> G[Version Bump]
42
+ G --> H[Push to GitHub]
43
+ G --> I[Push to Rubygems]
44
+ I --> J[AI Changelog]
45
+ H --> J[AI Changelog]
46
+ J --> K[Create Release]
47
+ ```
48
+
49
+ ### AI Versioning Flow
50
+
51
+ ```mermaid
52
+ graph LR
53
+ A[Code Changes] --> B[Semantic Analysis]
54
+ B --> C[AI Suggestion]
55
+ C --> D[Version Decision]
56
+ D --> E[Changelog Generation]
57
+ E --> F[Release Creation]
58
+ ```
59
+
60
+ ### Testing Suite Overview
61
+
62
+ ```mermaid
63
+ graph TD
64
+ A[Test Run] --> B[RSpec Tests]
65
+ A[Test Run] --> C[Test::Unit Tests]
66
+ B --> D[Code Coverage]
67
+ C --> D[Code Coverage]
68
+ D --> E[Failures?]
69
+ E -->|Yes| F[Fix Code]
70
+ E -->|No| G[Proceed]
71
+ F --> H[Re-run Tests]
72
+ H --> I[Success]
73
+ I --> J[Build Gem]
74
+ ```
6
75
 
7
76
  ## Download
8
77
 
@@ -12,37 +81,183 @@ The source of this library is located at
12
81
 
13
82
  or can be installed via
14
83
 
15
- ```
84
+ ```bash
16
85
  $ gem install gem_hadar
17
86
  ```
18
87
 
19
88
  ## Usage
20
89
 
21
- Create a new directory and excecute
90
+ ### Pre-requisites
22
91
 
23
- ```
92
+ Before using `gem_hadar`, ensure you have initialized a Git repository in your
93
+ project directory. Many of the gem's commands assume Git is available and
94
+ properly configured in the current working directory.
95
+
96
+ ### Quick Start with Generator
97
+
98
+ Create a new directory and execute:
99
+
100
+ ```bash
24
101
  $ gem_hadar
25
102
  ```
26
103
 
27
- Edit the created Rakefile until
104
+ This generates a basic gem structure with a Rakefile. Edit the generated Rakefile until:
28
105
 
29
- ```
106
+ ```bash
30
107
  $ rake gemspec
31
108
  ```
32
109
 
33
110
  and then
34
111
 
112
+ ```bash
113
+ $ rake build
114
+ ```
115
+
116
+ are performed as desired.
117
+
118
+ ### YARD Documentation
119
+
120
+ `gem_hadar` supports generating YARD documentation. To generate documentation, run:
121
+
122
+ ```bash
123
+ $ rake doc
35
124
  ```
125
+
126
+ This will create documentation in the `doc` directory using YARD.
127
+
128
+ ### Rakefile Configuration Example
129
+
130
+ For more advanced control, here's a complete Rakefile configuration example:
131
+
132
+ ```ruby
133
+ # Rakefile
134
+ require 'gem_hadar'
135
+
136
+ GemHadar do
137
+ # Set developing to true if you don't have a homepage set yet
138
+ #developing true
139
+
140
+ name 'mygemname'
141
+ path_name 'mygem'
142
+ path_module 'Mygem'
143
+ author 'My name'
144
+ email 'my@mail'
145
+ homepage "https://github.com/younameit/mygem"
146
+ summary 'Precious gem'
147
+ description 'Precious detailed gem'
148
+ test_dir 'spec'
149
+ ignore 'pkg', 'Gemfile.lock', '.DS_Store'
150
+
151
+ readme 'README.md'
152
+ title "#{name.camelize} -- My library"
153
+ licenses << 'Apache-2.0'
154
+
155
+ dependency 'sinatra', '~> 3.2'
156
+ development_dependency 'rake'
157
+ development_dependency 'rspec'
158
+ end
159
+ ```
160
+
161
+ Note that `gem_hadar` is ["self hosted"](Rakefile)
162
+
163
+ ### Available Tasks
164
+
165
+ You can list all available tasks with:
166
+
167
+ ```bash
168
+ $ rake -T
169
+ ```
170
+
171
+ #### Core Tasks
172
+
173
+ - `rake build` - Build task (builds all packages for a release)
174
+ - `rake release` - Release the new version 1.2.3 for the gem foo
175
+
176
+ #### Build Tasks
177
+
178
+ - `rake gemspec` - Create a gemspec file
179
+ - `rake package` - Build all the packages
180
+ - `rake gem` - Build the gem file foo-1.2.3.gem
181
+ - `rake clobber` - Remove any generated files
182
+ - `rake clobber_package` - Remove package products
183
+ - `rake repackage` - Force a rebuild of the package files
184
+
185
+ #### Version Management
186
+
187
+ - `rake version` - Writing version information for foo
188
+ - `rake version:show` - Displaying the current version
189
+ - `rake version:list` - List all versions in order
190
+ - `rake version:diff` - Displaying the diff from env var VERSION to the next version or HEAD
191
+ - `rake version:tag` - Tag this commit as version 1.2.3
192
+ - `rake version:bump` - Bump version with AI suggestion
193
+ - `rake version:bump:major` - Bump major version
194
+ - `rake version:bump:minor` - Bump minor version
195
+ - `rake version:bump:build` - Bump build version
196
+ - `rake version:push` - Push version 1.2.3 to all git remotes: origin
197
+ - `rake version:origin:push` - Push version 1.2.3 to git remote origin
198
+
199
+ #### Documentation
200
+
201
+ - `rake doc` - Create yard documentation (including private)
202
+ - `rake yard_doc` - Generate YARD Documentation
203
+ - `rake yard:doc` - Create yard documentation
204
+ - `rake yard:private` - Create yard documentation (including private)
205
+ - `rake yard:public` - Create yard documentation
206
+ - `rake yard:clean` - Clean the yard documentation
207
+ - `rake yard:view` - View the yard documentation
208
+ - `rake yard:list-undoc` - List all undocumented classes/modules/methods
209
+
210
+ #### Testing & Development
211
+
212
+ - `rake run_specs` - Run RSpec code examples
213
+ - `rake clean` - Remove any temporary products
214
+ - `rake gems:install` - Install all gems from the Gemfile
215
+ - `rake gem_hadar:update` - Update `gem_hadar` to a different version
216
+ - `rake rvm` - Create .rvmrc file
217
+ - `rake default` - Default task
218
+ - `rake compile` - Compile project extensions (if configured)
219
+
220
+ #### Publishing Tasks
221
+ - `rake push` - Push all changes for version 1.2.3 into the internets
222
+ - `rake github:release` - Create a new GitHub release for the current version
223
+ with AI-generated changelog
224
+
225
+ ### Update Version
226
+
227
+ Use one of the following rake tasks to bump the version:
228
+
229
+ - `rake version:bump:major` - Bump major version (e.g., 1.2.3 → 2.0.0)
230
+ - `rake version:bump:minor` - Bump minor version (e.g., 1.2.3 → 1.3.0)
231
+ - `rake version:bump:build` - Bump build version (e.g., 1.2.3 → 1.2.4)
232
+ - `rake version:bump` - Get AI-powered suggestion for appropriate bump level
233
+
234
+ Or bump your [VERSION](./VERSION) file by hand.
235
+
236
+ ### Release
237
+
238
+ ```bash
36
239
  $ rake build
37
240
  ```
38
241
 
39
- are perfomed as desired.
242
+ This command will execute a series of dependent tasks in order: cleaning
243
+ previous builds, generating the gem specification, packaging the gem, and
244
+ creating a git tag with the current version in git.
245
+
246
+ After all the files have been changed correctly and the git tags have been
247
+ moved forward to the appropriate commit you can finally enter:
248
+
249
+ ```bash
250
+ $ rake release
251
+ ```
252
+
253
+ The `rake release` command performs the final publishing steps: pushing the
254
+ master branch and version tag to all git remotes, pushing the gem package to
255
+ RubyGems.org, and creating a GitHub release with AI-generated changelog.
40
256
 
41
257
  ## Author
42
258
 
43
- Florian Frank \<mailto:flori@ping.de\>
44
- **GemHadar** was written by [Florian Frank](mailto:flori@ping.de)
259
+ **GemHadar** was written by [Florian Frank](mailto:flori@ping.de).
45
260
 
46
261
  ## License
47
262
 
48
- This software is licensed under the _MIT_ license.
263
+ This software is licensed under the [MIT](./LICENSE) license.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.25.0
1
+ 1.26.0
data/gem_hadar.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: gem_hadar 1.25.0 ruby lib
2
+ # stub: gem_hadar 1.26.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "gem_hadar".freeze
6
- s.version = "1.25.0".freeze
6
+ s.version = "1.26.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]
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
 
23
23
  s.specification_version = 4
24
24
 
25
- s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.24".freeze])
25
+ s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.26".freeze])
26
26
  s.add_runtime_dependency(%q<tins>.freeze, ["~> 1.0".freeze])
27
27
  s.add_runtime_dependency(%q<term-ansicolor>.freeze, ["~> 1.0".freeze])
28
28
  s.add_runtime_dependency(%q<ollama-ruby>.freeze, ["~> 1.0".freeze])
@@ -1,4 +1,12 @@
1
1
  module GemHadar::PromptTemplate
2
+ # The default_git_release_system_prompt method returns the system prompt used
3
+ # for generating GitHub release changelogs.
4
+ #
5
+ # This prompt instructs the AI model to act as a Ruby programmer who creates
6
+ # markdown-formatted changelog entries for new releases. The generated
7
+ # content helps users understand what has changed in the software.
8
+ #
9
+ # @return [ String ] the system prompt for GitHub release changelog generation
2
10
  def default_git_release_system_prompt
3
11
  <<~EOT
4
12
  You are a Ruby programmer generating changelog messages in markdown
@@ -7,6 +15,15 @@ module GemHadar::PromptTemplate
7
15
  EOT
8
16
  end
9
17
 
18
+ # The default_git_release_prompt method returns the prompt used for
19
+ # generating GitHub release changelogs.
20
+ #
21
+ # This prompt instructs the AI model to create a markdown-formatted changelog
22
+ # entry for a new release. It specifies guidelines for what constitutes
23
+ # significant changes, emphasizing the exclusion of trivial updates
24
+ # and the inclusion of only verified and impactful modifications.
25
+ #
26
+ # @return [ String ] the prompt template for GitHub release changelog generation
10
27
  def default_git_release_prompt
11
28
  <<~EOT
12
29
  Output the content of a changelog for the new release of %{name} %{version}
@@ -30,6 +47,16 @@ module GemHadar::PromptTemplate
30
47
  EOT
31
48
  end
32
49
 
50
+ # The default_version_bump_system_prompt method returns the system prompt
51
+ # used for generating semantic version bump suggestions.
52
+ #
53
+ # This prompt instructs the AI model to act as an expert in semantic versioning,
54
+ # analyzing provided changes and determining whether a major, minor, or build
55
+ # version bump is appropriate. It requires the model to provide a brief
56
+ # explanation of its reasoning followed by a single line containing only one
57
+ # word: 'major', 'minor', or 'build'.
58
+ #
59
+ # @return [ String ] the system prompt for semantic version bump suggestion generation
33
60
  def default_version_bump_system_prompt
34
61
  <<~EOT
35
62
  You are an expert at semantic versioning. Analyze the provided changes
@@ -40,6 +67,16 @@ module GemHadar::PromptTemplate
40
67
  EOT
41
68
  end
42
69
 
70
+ # The default_version_bump_prompt method returns the prompt template used for
71
+ # generating semantic version bump suggestions.
72
+ #
73
+ # This prompt instructs the AI model to analyze provided changes and
74
+ # determine whether a major, minor, or build version bump is appropriate
75
+ # according to Semantic Versioning principles. It requires the model to first
76
+ # provide a brief explanation of its reasoning, followed by a single line
77
+ # containing only one word: 'major', 'minor', or 'build'.
78
+ #
79
+ # @return [ String ] the prompt template for semantic version bump suggestion generation
43
80
  def default_version_bump_prompt
44
81
  <<~EOT
45
82
  Given the current version %{version} and the following changes:
@@ -1,6 +1,10 @@
1
1
  class GemHadar::Setup
2
2
  include FileUtils
3
3
 
4
+ # The perform method sets up the basic project structure by creating the lib
5
+ # directory, initializing a VERSION file with '0.0.0' if it doesn't exist,
6
+ # and creating a default Rakefile with basic GemHadar configuration if one
7
+ # doesn't already exist.
4
8
  def perform
5
9
  mkdir_p 'lib'
6
10
  unless File.exist?('VERSION')
@@ -4,12 +4,26 @@ class GemHadar::TemplateCompiler
4
4
  include Tins::BlockSelf
5
5
  include Tins::MethodMissingDelegator::DelegatorModule
6
6
 
7
+ # The initialize method sets up the template compiler instance by evaluating
8
+ # the provided block in the context of the object.
9
+ #
10
+ # @param block [ Proc ] the block to be evaluated for configuring the template compiler
7
11
  def initialize(&block)
8
12
  super block_self(&block)
9
13
  @values = {}
10
14
  instance_eval(&block)
11
15
  end
12
16
 
17
+ # The compile method processes an ERB template file and writes the rendered
18
+ # output to a destination file.
19
+ #
20
+ # This method reads the content of a source file, treats it as an ERB
21
+ # template, and renders it using the provided binding.
22
+ # The result is then written to a specified destination file, effectively
23
+ # generating a new file based on the template.
24
+ #
25
+ # @param src [ String ] the path to the source ERB template file
26
+ # @param dst [ String ] the path to the destination file where the rendered content will be written
13
27
  def compile(src, dst)
14
28
  template = File.read(src)
15
29
  File.open(dst, 'w') do |output|
@@ -19,6 +33,21 @@ class GemHadar::TemplateCompiler
19
33
  end
20
34
  end
21
35
 
36
+ # The method_missing method handles dynamic attribute access and assignment.
37
+ #
38
+ # This method intercepts calls to undefined methods on the object, allowing
39
+ # for dynamic retrieval and setting of values through method calls. If a
40
+ # method name corresponds to a key in @values and no arguments are provided,
41
+ # it returns the stored value. If a single argument is provided, it stores
42
+ # the argument under the method name as a key in @values. For all other
43
+ # cases, it delegates the call to the superclass implementation.
44
+ #
45
+ # @param id [ Symbol ] the name of the method being called
46
+ # @param a [ Array ] the arguments passed to the method
47
+ # @param b [ Proc ] the block passed to the method
48
+ #
49
+ # @return [ Object ] the value associated with the method name if retrieving,
50
+ # otherwise delegates to super
22
51
  def method_missing(id, *a, &b)
23
52
  if a.empty? && id && @values.key?(id)
24
53
  @values[id]
@@ -1,4 +1,16 @@
1
1
  module GemHadar::Utils
2
+ # The xdg_config_filename method constructs the full path to a configuration
3
+ # file based on the XDG Base Directory specification.
4
+ #
5
+ # It first checks if the XDG_CONFIG_HOME environment variable is set and not
6
+ # empty. If it is set, the method joins this directory with the provided
7
+ # filename to form the complete path. If XDG_CONFIG_HOME is not set, it
8
+ # defaults to using the HOME environment variable to construct the path
9
+ # within the standard .config directory.
10
+ #
11
+ # @param name [ String ] the name of the configuration file
12
+ #
13
+ # @return [ String ] the full path to the configuration file
2
14
  def xdg_config_filename(name)
3
15
  if xdg = ENV['XDG_CONFIG_HOME'].full?
4
16
  File.join(xdg, name)
@@ -8,6 +20,17 @@ module GemHadar::Utils
8
20
  end
9
21
 
10
22
  memoize method:
23
+ # The xdg_config method retrieves configuration data from a file following
24
+ # the XDG Base Directory specification.
25
+ #
26
+ # It checks for the existence of a configuration file using the
27
+ # xdg_config_filename method and returns its contents if found. If the file
28
+ # does not exist, it returns the provided default value instead.
29
+ #
30
+ # @param name [ String ] the name of the configuration file to retrieve
31
+ # @param default [ Object ] the default value to return if the configuration file is not found
32
+ #
33
+ # @return [ String ] the content of the configuration file or the default value
11
34
  def xdg_config(name, default)
12
35
  if File.exist?(xdg_config_filename(name))
13
36
  File.read(xdg_config_filename(name))
@@ -1,6 +1,6 @@
1
1
  class GemHadar
2
2
  # GemHadar version
3
- VERSION = '1.25.0'
3
+ VERSION = '1.26.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
data/lib/gem_hadar.rb CHANGED
@@ -51,6 +51,12 @@ class GemHadar
51
51
  block and instance_eval(&block)
52
52
  end
53
53
 
54
+ # The has_to_be_set method raises an error if a required gem configuration
55
+ # attribute is not set.
56
+ #
57
+ # @param name [ String ] the name of the required attribute
58
+ #
59
+ # @raise [ ArgumentError ] if the specified attribute has not been set
54
60
  def has_to_be_set(name)
55
61
  fail "#{self.class}: #{name} has to be set for gem"
56
62
  end
@@ -134,7 +140,7 @@ class GemHadar
134
140
  end
135
141
 
136
142
  dsl_accessor :yard_dir do
137
- 'yard'
143
+ 'doc'
138
144
  end
139
145
 
140
146
  dsl_accessor :extensions do FileList['ext/**/extconf.rb'] end
@@ -182,6 +188,18 @@ class GemHadar
182
188
  dsl_accessor :gemset do @outer_scope.name end
183
189
  end
184
190
 
191
+ # The rvm method configures RVM (Ruby Version Manager) settings for the gem
192
+ # project.
193
+ #
194
+ # This method initializes and returns an RvmConfig object that holds RVM-specific
195
+ # configuration such as the Ruby version to use and the gemset name.
196
+ # If a block is provided, it configures the RvmConfig object with the given
197
+ # settings. If no block is provided and no existing RvmConfig object exists,
198
+ # it creates a new one with default settings.
199
+ #
200
+ # @param block [ Proc ] optional block to configure RVM settings
201
+ #
202
+ # @return [ GemHadar::RvmConfig ] the RVM configuration object
185
203
  def rvm(&block)
186
204
  if block
187
205
  @rvm = RvmConfig.new(&block)
@@ -193,6 +211,12 @@ class GemHadar
193
211
 
194
212
  dsl_accessor :default_task_dependencies, [ :gemspec, :test ]
195
213
 
214
+ # The default_task method defines the default Rake task for the gem project.
215
+ #
216
+ # This method sets up a Rake task named :default that depends on the tasks
217
+ # specified in the default_task_dependencies accessor. It provides a convenient
218
+ # way to run the most common or essential tasks for the project with a single
219
+ # command.
196
220
  def default_task
197
221
  desc 'Default task'
198
222
  task :default => default_task_dependencies
@@ -200,11 +224,26 @@ class GemHadar
200
224
 
201
225
  dsl_accessor :build_task_dependencies, [ :clobber, :gemspec, :package, :'version:tag' ]
202
226
 
227
+ # The build_task method defines a Rake task that orchestrates the complete
228
+ # build process for packaging the gem.
229
+ #
230
+ # This method sets up a :build task that depends on the tasks specified in
231
+ # the build_task_dependencies accessor. It provides a convenient way to
232
+ # execute all necessary steps for building packages for a release with a
233
+ # single command.
203
234
  def build_task
204
235
  desc 'Build task (builds all packages for a release)'
205
236
  task :build => build_task_dependencies
206
237
  end
207
238
 
239
+ # The install_library method sets up a Rake task for installing the library
240
+ # or executable into site_ruby directories.
241
+ #
242
+ # This method configures an :install task that depends on the
243
+ # :prepare_install task and executes the provided block. It stores the block
244
+ # in an instance variable to be called later when the task is executed.
245
+ #
246
+ # @param block [ Proc ] the block containing the installation logic
208
247
  def install_library(&block)
209
248
  @install_library_block = -> do
210
249
  desc 'Install executable/library into site_ruby directories'
@@ -212,6 +251,15 @@ class GemHadar
212
251
  end
213
252
  end
214
253
 
254
+ # The clean method manages the CLEAN file list for Rake tasks.
255
+ #
256
+ # When called without arguments, it returns the current CLEAN file list.
257
+ # When called with arguments, it adds the specified files to the CLEAN list.
258
+ #
259
+ # @param args [ Array<String> ] optional list of files to add to the CLEAN list
260
+ #
261
+ # @return [ FileList, nil ] the CLEAN file list when no arguments provided,
262
+ # nil otherwise
215
263
  def clean(*args)
216
264
  if args.empty?
217
265
  CLEAN
@@ -220,6 +268,15 @@ class GemHadar
220
268
  end
221
269
  end
222
270
 
271
+ # The clobber method manages the CLOBBER file list for Rake tasks.
272
+ #
273
+ # When called without arguments, it returns the current CLOBBER file list.
274
+ # When called with arguments, it adds the specified files to the CLOBBER list.
275
+ #
276
+ # @param args [ Array<String> ] optional list of files to add to the CLOBBER list
277
+ #
278
+ # @return [ FileList, nil ] the CLOBBER file list when no arguments provided,
279
+ # nil otherwise
223
280
  def clobber(*args)
224
281
  if args.empty?
225
282
  CLOBBER
@@ -228,6 +285,15 @@ class GemHadar
228
285
  end
229
286
  end
230
287
 
288
+ # The ignore method manages the list of files to be ignored by the gem.
289
+ #
290
+ # When called without arguments, it returns the current set of ignored files.
291
+ # When called with arguments, it adds the specified files to the ignore list.
292
+ #
293
+ # @param args [ Array<String> ] optional list of file patterns to add to the ignore list
294
+ #
295
+ # @return [ Set<String>, nil ] the set of ignored files when no arguments provided,
296
+ # nil otherwise
231
297
  def ignore(*args)
232
298
  if args.empty?
233
299
  ignore_files
@@ -236,6 +302,17 @@ class GemHadar
236
302
  end
237
303
  end
238
304
 
305
+ # The package_ignore method manages the list of files to be ignored during
306
+ # gem packaging.
307
+ #
308
+ # When called without arguments, it returns the current set of package ignore
309
+ # files. When called with arguments, it adds the specified file patterns to
310
+ # the package ignore list.
311
+ #
312
+ # @param args [ Array<String> ] optional list of file patterns to add to the package ignore list
313
+ #
314
+ # @return [ Set<String>, nil ] the set of package ignore files when no arguments provided,
315
+ # nil otherwise
239
316
  def package_ignore(*args)
240
317
  if args.empty?
241
318
  package_ignore_files
@@ -244,14 +321,28 @@ class GemHadar
244
321
  end
245
322
  end
246
323
 
324
+ # The dependency method adds a new runtime dependency to the gem.
325
+ #
326
+ # @param args [ Array ] the arguments defining the dependency
247
327
  def dependency(*args)
248
328
  @dependencies << args
249
329
  end
250
330
 
331
+ # The development_dependency method adds a new development-time dependency to
332
+ # the gem.
333
+ #
334
+ # @param args [ Array ] the arguments defining the development dependency
251
335
  def development_dependency(*args)
252
336
  @development_dependencies << args
253
337
  end
254
338
 
339
+ # The gems_install_task method defines a Rake task for installing all gem
340
+ # dependencies specified in the Gemfile.
341
+ #
342
+ # This method sets up a :gems:install task that executes a block to install
343
+ # gems. If no block is provided, it defaults to running 'bundle install'.
344
+ #
345
+ # @param block [ Proc ] optional block containing the installation command
255
346
  def gems_install_task(&block)
256
347
  block ||= proc { sh 'bundle install' }
257
348
  desc 'Install all gems from the Gemfile'
@@ -260,6 +351,14 @@ class GemHadar
260
351
  end
261
352
  end
262
353
 
354
+ # The version_task method defines a Rake task that generates a version file
355
+ # for the gem.
356
+ #
357
+ # This method creates a task named :version that writes version information
358
+ # to a Ruby file in the lib directory. The generated file contains constants
359
+ # for the version and its components, as well as an optional epilogue
360
+ # section. The task ensures the target directory exists and uses secure file
361
+ # writing to prevent permission issues.
263
362
  def version_task
264
363
  desc m = "Writing version information for #{name}-#{version}"
265
364
  task :version do
@@ -281,6 +380,13 @@ class GemHadar
281
380
  end
282
381
  end
283
382
 
383
+ # The version_show_task method defines a Rake task that displays the current
384
+ # version of the gem.
385
+ #
386
+ # This method creates a :version:show task under the Rake namespace that
387
+ # reads the version from the generated version file in the lib directory and
388
+ # compares it with the version specified in the GemHadar configuration. It
389
+ # then outputs a message indicating whether the versions match or not.
284
390
  def version_show_task
285
391
  namespace :version do
286
392
  desc "Displaying the current version"
@@ -299,6 +405,21 @@ class GemHadar
299
405
  end
300
406
  end
301
407
 
408
+ # The version_log_diff method generates a git log output containing patch
409
+ # differences between two specified versions.
410
+ #
411
+ # This method retrieves the commit history between a starting version and an
412
+ # ending version, including detailed changes (patch format) for each commit.
413
+ # It supports comparing against the current HEAD or specific version tags,
414
+ # and automatically determines the appropriate previous version when only a
415
+ # target version is provided.
416
+ #
417
+ # @param to_version [ String ] the ending version tag or 'HEAD' to compare up to the latest commit
418
+ # @param from_version [ String, nil ] the starting version tag; if nil, it defaults based on to_version
419
+ #
420
+ # @raise [ RuntimeError ] if the specified version tags are not found in the repository
421
+ #
422
+ # @return [ String ] the git log output in patch format showing changes between the two versions
302
423
  def version_log_diff(to_version: 'HEAD', from_version: nil)
303
424
  if to_version == 'HEAD'
304
425
  if from_version.blank?
@@ -331,6 +452,15 @@ class GemHadar
331
452
  end
332
453
  end
333
454
 
455
+ # The version_diff_task method defines Rake tasks for listing and displaying
456
+ # git version differences.
457
+ #
458
+ # This method sets up two subtasks under the :version namespace:
459
+ #
460
+ # - A :list task that fetches all git tags, ensures the operation succeeds,
461
+ # and outputs the sorted list of versions.
462
+ # - A :diff task that calculates the version range, displays a colored diff
463
+ # between the versions, and shows the changes.
334
464
  def version_diff_task
335
465
  namespace :version do
336
466
  desc "List all versions in order"
@@ -349,9 +479,18 @@ class GemHadar
349
479
  end
350
480
  end
351
481
 
482
+ # The gem_hadar_update_task method defines a Rake task that updates the
483
+ # gem_hadar dependency version in the gemspec file.
484
+ #
485
+ # This method creates a :gem_hadar:update task under the Rake namespace that
486
+ # prompts the user to specify a new gem_hadar version.
487
+ # It then reads the existing gemspec file, modifies the version constraint
488
+ # for the gem_hadar dependency, and writes the updated content back to the
489
+ # file. If the specified version is already present in the gemspec, it skips
490
+ # the update and notifies the user.
352
491
  def gem_hadar_update_task
353
492
  namespace :gem_hadar do
354
- desc 'Update gem_hadar a different version'
493
+ desc 'Update gem_hadar to a different version'
355
494
  task :update do
356
495
  answer = ask?("Which gem_hadar version? ", /^((?:\d+.){2}(?:\d+))$/)
357
496
  unless answer
@@ -377,6 +516,14 @@ class GemHadar
377
516
  end
378
517
  end
379
518
 
519
+ # The gemspec_task method defines a Rake task that generates and writes a
520
+ # gemspec file for the project.
521
+ #
522
+ # This method creates a :gemspec task that depends on the :version task,
523
+ # ensuring the version is set before generating the gemspec. It constructs
524
+ # the filename based on the project name, displays a warning message
525
+ # indicating the file being written, and uses secure_write to create the
526
+ # gemspec file with content generated by the gemspec method.
380
527
  def gemspec_task
381
528
  desc 'Create a gemspec file'
382
529
  task :gemspec => :version do
@@ -386,6 +533,12 @@ class GemHadar
386
533
  end
387
534
  end
388
535
 
536
+ # The package_task method sets up a Rake task for packaging the gem.
537
+ #
538
+ # This method configures a task that creates a package directory, initializes
539
+ # a Gem::PackageTask with the current gem specification, and specifies that
540
+ # tar files should be created. It also includes the files to be packaged by
541
+ # adding gem_files to the package_files attribute of the Gem::PackageTask.
389
542
  def package_task
390
543
  clean 'pkg'
391
544
  Gem::PackageTask.new(gemspec) do |pkg|
@@ -394,24 +547,20 @@ class GemHadar
394
547
  end
395
548
  end
396
549
 
550
+ # The install_library_task method executes the installed library task block
551
+ # if it has been defined.
397
552
  def install_library_task
398
553
  @install_library_block.full?(:call)
399
554
  end
400
555
 
401
- def doc_task
402
- clean 'doc'
403
- desc "Creating documentation"
404
- task :doc do
405
- sh 'yard doc'
406
- cmd = 'yardoc'
407
- if readme
408
- cmd << " --readme '#{readme}'"
409
- end
410
- cmd << ' - ' << doc_files * ' '
411
- sh cmd
412
- end
413
- end
414
-
556
+ # The test_task method sets up a Rake task for executing the project's test
557
+ # suite.
558
+ #
559
+ # This method configures a Rake task named :test that runs the test suite
560
+ # using Rake::TestTask. It includes the test directory and required paths in
561
+ # the load path, specifies the test files to run, and enables verbose output.
562
+ # The task also conditionally depends on the :compile task if project
563
+ # extensions are present.
415
564
  def test_task
416
565
  tt = Rake::TestTask.new(:run_tests) do |t|
417
566
  t.libs << test_dir
@@ -423,6 +572,12 @@ class GemHadar
423
572
  task :test => [ (:compile if extensions.full?), tt.name ].compact
424
573
  end
425
574
 
575
+ # The spec_task method sets up a Rake task for executing RSpec tests.
576
+ #
577
+ # This method configures a :spec task that runs the project's RSpec test
578
+ # suite. It initializes an RSpec::Core::RakeTask with appropriate Ruby
579
+ # options, test pattern, and verbose output. The task also conditionally
580
+ # depends on the :compile task if project extensions are present.
426
581
  def spec_task
427
582
  defined? ::RSpec::Core::RakeTask or return
428
583
  st = RSpec::Core::RakeTask.new(:run_specs) do |t|
@@ -434,6 +589,15 @@ class GemHadar
434
589
  task :spec => [ (:compile if extensions.full?), st.name ].compact
435
590
  end
436
591
 
592
+ # The rcov_task method sets up a Rake task for executing code coverage tests
593
+ # using RCov.
594
+ #
595
+ # This method configures a :rcov task that runs the project's test suite with
596
+ # RCov to generate code coverage reports. It includes the test directory and
597
+ # required paths in the load path, specifies the test files to run, and
598
+ # enables verbose output. The task also conditionally depends on the :compile
599
+ # task if project extensions are present. If RCov is not available, it
600
+ # displays a warning message suggesting to install RCov.
437
601
  def rcov_task
438
602
  if defined?(::Rcov)
439
603
  rt = ::Rcov::RcovTask.new(:run_rcov) do |t|
@@ -455,6 +619,23 @@ class GemHadar
455
619
  end
456
620
  end
457
621
 
622
+ # The version_bump_task method defines Rake tasks for incrementing the gem's
623
+ # version number.
624
+ #
625
+ # This method sets up a hierarchical task structure under the :version
626
+ # namespace:
627
+ #
628
+ # - It creates subtasks in the :version:bump namespace for explicitly bumping
629
+ # major, minor, or build versions.
630
+ # - It also defines a :version:bump task that automatically suggests the
631
+ # appropriate version bump type by analyzing recent changes using AI. The
632
+ # suggestion is based on the git log diff between the previous version and
633
+ # the current HEAD, and it prompts the user for confirmation before applying
634
+ # the bump.
635
+ #
636
+ # The tasks utilize the version_log_diff method to gather change information,
637
+ # the ollama_generate method to get AI-powered suggestions, and the
638
+ # version_bump_to method to perform the actual version update.
458
639
  def version_bump_task
459
640
  namespace :version do
460
641
  namespace :bump do
@@ -474,7 +655,7 @@ class GemHadar
474
655
  end
475
656
  end
476
657
 
477
- desc 'Bump version with suggestion'
658
+ desc 'Bump version with AI suggestion'
478
659
  task :bump do
479
660
  log_diff = version_log_diff(from_version: nil, to_version: 'HEAD')
480
661
  system = xdg_config('version_bump_system_prompt.txt', default_version_bump_system_prompt)
@@ -499,6 +680,15 @@ class GemHadar
499
680
  end
500
681
  end
501
682
 
683
+ # The version_tag_task method defines a Rake task that creates a Git tag for
684
+ # the current version.
685
+ #
686
+ # This method sets up a :version:tag task under the Rake namespace that
687
+ # creates an annotated Git tag for the project's current version. It checks
688
+ # if a tag with the same name already exists and handles the case where the
689
+ # tag exists but is different from the current commit. If the tag already
690
+ # exists and is different, it prompts the user to confirm whether to
691
+ # overwrite it forcefully.
502
692
  def version_tag_task
503
693
  namespace :version do
504
694
  desc "Tag this commit as version #{version}"
@@ -523,10 +713,24 @@ class GemHadar
523
713
  end
524
714
  end
525
715
 
716
+ # The git_remote method retrieves the primary Git remote name configured for
717
+ # the project.
718
+ #
719
+ # It first checks the GIT_REMOTE environment variable for a custom remote
720
+ # specification. If not set, it defaults to 'origin'. When multiple remotes
721
+ # are specified in the environment variable, only the first one is returned.
526
722
  def git_remote
527
723
  ENV.fetch('GIT_REMOTE', 'origin').split(/\s+/).first
528
724
  end
529
725
 
726
+ # The master_prepare_task method defines a Rake task that sets up a remote
727
+ # Git repository for the project.
728
+ #
729
+ # This method creates a :master:prepare task under the Rake namespace that
730
+ # guides the user through creating a new bare Git repository on a remote
731
+ # server via SSH. It prompts for the remote name, directory path, and SSH
732
+ # account details to configure the repository and establish a connection back
733
+ # to the local project.
530
734
  def master_prepare_task
531
735
  namespace :master do
532
736
  desc "Prepare a remote git repository for this project"
@@ -544,6 +748,20 @@ class GemHadar
544
748
  end
545
749
  end
546
750
 
751
+ # The version_push_task method defines Rake tasks for pushing version tags to
752
+ # Git remotes.
753
+ #
754
+ # This method sets up a hierarchical task structure under the :version
755
+ # namespace:
756
+ #
757
+ # - It creates subtasks in the :version:push namespace for each configured
758
+ # Git remote, allowing individual pushes to specific remotes.
759
+ # - It also defines a top-level :version:push task that depends on all the
760
+ # individual remote push tasks, enabling a single command to push the version
761
+ # tag to all remotes.
762
+ #
763
+ # The tasks utilize the git_remotes method to determine which remotes are
764
+ # configured and generate appropriate push commands for each one.
547
765
  def version_push_task
548
766
  namespace :version do
549
767
  git_remotes.each do |gr|
@@ -560,6 +778,19 @@ class GemHadar
560
778
  end
561
779
  end
562
780
 
781
+ # The master_push_task method defines Rake tasks for pushing the master
782
+ # branch to configured Git remotes.
783
+ #
784
+ # This method sets up a hierarchical task structure under the :master namespace:
785
+ #
786
+ # - It creates subtasks in the :master:push namespace for each configured Git
787
+ # remote, allowing individual pushes to specific remotes.
788
+ # - It also defines a top-level :master:push task that depends on all the individual
789
+ # remote push tasks, enabling a single command to push the master branch to
790
+ # all remotes.
791
+ #
792
+ # The tasks utilize the git_remotes method to determine which remotes are
793
+ # configured and generate appropriate push commands for each one.
563
794
  def master_push_task
564
795
  namespace :master do
565
796
  git_remotes.each do |gr|
@@ -576,6 +807,17 @@ class GemHadar
576
807
  end
577
808
  end
578
809
 
810
+ # The gem_push_task method defines a Rake task for pushing the generated gem
811
+ # file to RubyGems.
812
+ #
813
+ # This method sets up a :gem:push task under the Rake namespace that handles
814
+ # the process of uploading the gem package to RubyGems. It checks if the
815
+ # project is in developing mode and skips the push operation if so.
816
+ # Otherwise, it verifies the existence of the gem file, prompts the user for
817
+ # confirmation before pushing, and uses the gem push command with an optional
818
+ # API key from the environment. If the gem file does not exist or the user
819
+ # declines to push, appropriate messages are displayed and the task exits
820
+ # accordingly.
579
821
  def gem_push_task
580
822
  namespace :gem do
581
823
  path = "pkg/#{name_version}.gem"
@@ -604,6 +846,15 @@ class GemHadar
604
846
  end
605
847
  end
606
848
 
849
+ # The git_remotes_task method defines a Rake task that displays all Git
850
+ # remote repositories configured for the project.
851
+ #
852
+ # This method sets up a :git_remotes task under the Rake namespace that
853
+ # retrieves and prints the list of Git remotes along with their URLs. It uses
854
+ # the git_remotes method to obtain the remote names and then fetches each
855
+ # remote's URL using the `git remote get-url` command. The output is
856
+ # formatted to show each remote name followed by its corresponding URL on
857
+ # separate lines.
607
858
  def git_remotes_task
608
859
  task :git_remotes do
609
860
  puts git_remotes.map { |r|
@@ -613,6 +864,14 @@ class GemHadar
613
864
  end
614
865
  end
615
866
 
867
+ # The create_git_release_body method generates a changelog for a GitHub
868
+ # release by analyzing the git diff between the previous version and the
869
+ # current HEAD.
870
+ #
871
+ # It retrieves the log differences, fetches or uses default system and prompt
872
+ # templates, and utilizes an AI model to produce a formatted changelog entry.
873
+ #
874
+ # @return [ String ] the generated changelog content for the release body
616
875
  def create_git_release_body
617
876
  log_diff = version_log_diff(to_version: version)
618
877
  system = xdg_config('release_system_prompt.txt', default_git_release_system_prompt)
@@ -620,26 +879,14 @@ class GemHadar
620
879
  ollama_generate(system:, prompt:)
621
880
  end
622
881
 
623
- def edit_temp_file(content)
624
- editor = ENV.fetch('EDITOR', `which vi`.chomp)
625
- unless File.exist?(editor)
626
- warn "Can't find EDITOR. => Returning."
627
- return
628
- end
629
- temp_file = Tempfile.new('changelog')
630
- temp_file.write(content)
631
- temp_file.close
632
-
633
- unless system("#{editor} #{temp_file.path}")
634
- warn "#{editor} returned #{$?.exitstatus} => Returning."
635
- return
636
- end
637
-
638
- File.read(temp_file.path)
639
- ensure
640
- temp_file&.close&.unlink
641
- end
642
-
882
+ # The github_release_task method defines a Rake task that creates a GitHub
883
+ # release for the current version.
884
+ #
885
+ # This method sets up a :github:release task that prompts the user to confirm
886
+ # publishing a release message on GitHub. It retrieves the GitHub API token
887
+ # from the environment, derives the repository owner and name from the git
888
+ # remote URL, generates a changelog using AI, and creates the release via the
889
+ # GitHub API.
643
890
  def github_release_task
644
891
  namespace :github do
645
892
  unless github_api_token = ENV['GITHUB_API_TOKEN'].full?
@@ -647,7 +894,7 @@ class GemHadar
647
894
  task :release
648
895
  return
649
896
  end
650
- desc "Create a new GitHub release for the current version with a changelog"
897
+ desc "Create a new GitHub release for the current version with a AI-generated changelog"
651
898
  task :release do
652
899
  yes = ask?(
653
900
  "Do you want to publish a release message on github? (y/n%{default}) ",
@@ -681,6 +928,14 @@ class GemHadar
681
928
 
682
929
  dsl_accessor :push_task_dependencies, %i[ modified build master:push version:push gem:push github:release ]
683
930
 
931
+ # The push_task method defines a Rake task that orchestrates the complete
932
+ # process of pushing changes and artifacts to remote repositories and package
933
+ # managers.
934
+ #
935
+ # This method sets up multiple subtasks including preparing the master
936
+ # branch, pushing version tags, pushing to gem repositories, and creating
937
+ # GitHub releases. It also includes a check for uncommitted changes before
938
+ # proceeding with the push operations.
684
939
  def push_task
685
940
  master_prepare_task
686
941
  version_push_task
@@ -695,10 +950,26 @@ class GemHadar
695
950
  exit 1
696
951
  end
697
952
  end
698
- desc "Push master and version #{version} all git remotes: #{git_remotes * ' '}"
953
+ desc "Push all changes for version #{version} into the internets."
699
954
  task :push => push_task_dependencies
700
955
  end
701
956
 
957
+ # The release_task method defines a Rake task that orchestrates the complete
958
+ # release process for the gem.
959
+ #
960
+ # This method sets up a :release task that depends on the :push task,
961
+ # ensuring all necessary steps for publishing the gem are executed in
962
+ # sequence. It provides a convenient way to perform a full release workflow
963
+ # with a single command.
964
+ def release_task
965
+ desc "Release the new version #{version} for the gem #{name}."
966
+ task :release => :push
967
+ end
968
+
969
+ # The compile_task method sets up a Rake task to compile project extensions.
970
+ #
971
+ # This method creates a :compile task that iterates through the configured
972
+ # extensions and compiles them using the system's make command.
702
973
  def compile_task
703
974
  for file in extensions
704
975
  dir = File.dirname(file)
@@ -716,6 +987,16 @@ class GemHadar
716
987
  end
717
988
  end
718
989
 
990
+ # The rvm_task method creates a .rvmrc file that configures RVM to use the
991
+ # specified Ruby version and gemset for the project.
992
+ #
993
+ # This task generates a .rvmrc file in the project root directory with commands to:
994
+ # - Use the Ruby version specified by the rvm.use accessor
995
+ # - Create the gemset specified by the rvm.gemset accessor
996
+ # - Switch to using that gemset
997
+ #
998
+ # The generated file is written using the secure_write method to ensure
999
+ # proper file permissions.
719
1000
  def rvm_task
720
1001
  desc 'Create .rvmrc file'
721
1002
  task :rvm do
@@ -729,15 +1010,55 @@ class GemHadar
729
1010
  end
730
1011
  end
731
1012
 
1013
+ def yard_doc_task
1014
+ YARD::Rake::YardocTask.new(:yard_doc) do |t|
1015
+ t.files = files.select { _1 =~ /\.rb\z/ }
1016
+
1017
+ output_dir = yard_dir
1018
+ t.options = [ "--output-dir=#{output_dir}" ]
1019
+
1020
+ # Include private & protected methods in documentation
1021
+ t.options << '--private' << '--protected'
1022
+
1023
+ # Handle readme if present
1024
+ if readme && File.exist?(readme)
1025
+ t.options << "--readme=#{readme}"
1026
+ end
1027
+
1028
+ # Add additional documentation files
1029
+ if doc_files&.any?
1030
+ t.files.concat(doc_files.flatten)
1031
+ end
1032
+
1033
+ # Add before hook for cleaning
1034
+ t.before = proc {
1035
+ clean output_dir
1036
+ puts "Generating full documentation in #{output_dir}..."
1037
+ }
1038
+ end
1039
+ end
1040
+
1041
+ # The yard_task method sets up and registers Rake tasks for generating and
1042
+ # managing YARD documentation.
1043
+ #
1044
+ # It creates multiple subtasks under the :yard namespace, including tasks for
1045
+ # creating private documentation, viewing the generated documentation,
1046
+ # cleaning up documentation files, and listing undocumented elements.
1047
+ # If YARD is not available, the method returns early without defining any tasks.
732
1048
  def yard_task
733
1049
  defined? YARD or return
1050
+ yard_doc_task
1051
+ desc 'Create yard documentation (including private)'
1052
+ task :doc => :yard_doc
734
1053
  namespace :yard do
735
1054
  my_yard_dir = Pathname.new(yard_dir)
736
1055
 
737
- desc 'Create yard documentation (including private)'
738
- task :private do
739
- sh "yardoc -o #{my_yard_dir}"
740
- end
1056
+ task :private => :yard_doc
1057
+
1058
+ task :public => :yard_doc
1059
+
1060
+ desc 'Create yard documentation'
1061
+ task :doc => :yard_doc
741
1062
 
742
1063
  desc 'View the yard documentation'
743
1064
  task :view do
@@ -775,7 +1096,6 @@ class GemHadar
775
1096
  gem_hadar_update_task
776
1097
  gemspec_task
777
1098
  gems_install_task
778
- doc_task
779
1099
  if test_dir
780
1100
  test_task
781
1101
  rcov_task
@@ -787,6 +1107,7 @@ class GemHadar
787
1107
  version_bump_task
788
1108
  version_tag_task
789
1109
  push_task
1110
+ release_task
790
1111
  write_ignore_file
791
1112
  write_gemfile
792
1113
  if extensions.full?
@@ -798,6 +1119,31 @@ class GemHadar
798
1119
  self
799
1120
  end
800
1121
 
1122
+ # The edit_temp_file method creates a temporary file with the provided
1123
+ # content, opens it in an editor for user modification, and returns the
1124
+ # updated content.
1125
+ #
1126
+ # @param content [ String ] the initial content to write to the temporary file
1127
+ def edit_temp_file(content)
1128
+ editor = ENV.fetch('EDITOR', `which vi`.chomp)
1129
+ unless File.exist?(editor)
1130
+ warn "Can't find EDITOR. => Returning."
1131
+ return
1132
+ end
1133
+ temp_file = Tempfile.new('changelog')
1134
+ temp_file.write(content)
1135
+ temp_file.close
1136
+
1137
+ unless system("#{editor} #{temp_file.path}")
1138
+ warn "#{editor} returned #{$?.exitstatus} => Returning."
1139
+ return
1140
+ end
1141
+
1142
+ File.read(temp_file.path)
1143
+ ensure
1144
+ temp_file&.close&.unlink
1145
+ end
1146
+
801
1147
  # Generates a response from an AI model using the Ollama::Client.
802
1148
  #
803
1149
  # @param [String] system The system prompt for the AI model.
@@ -941,8 +1287,12 @@ class GemHadar
941
1287
  s.rdoc_options << '--title' << "#{name.camelize} - #{summary}"
942
1288
  end
943
1289
  if readme
944
- s.rdoc_options << '--main' << readme
945
- s.extra_rdoc_files << readme
1290
+ if File.exist?(readme)
1291
+ s.rdoc_options << '--main' << readme
1292
+ s.extra_rdoc_files << readme
1293
+ else
1294
+ warn "Add a #{readme} file to document your gem!"
1295
+ end
946
1296
  end
947
1297
  doc_files.full? { |df| s.extra_rdoc_files.concat Array(df) }
948
1298
  end
@@ -1045,6 +1395,11 @@ class GemHadar
1045
1395
  end
1046
1396
  end
1047
1397
 
1398
+ # The version_untag method removes the 'v' prefix from a version tag string.
1399
+ #
1400
+ # @param version_tag [ String ] the version tag string that may start with 'v'
1401
+ #
1402
+ # @return [ String ] the version string with the 'v' prefix removed
1048
1403
  def version_untag(version_tag)
1049
1404
  version.sub(/\Av/, '')
1050
1405
  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: 1.25.0
4
+ version: 1.26.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: '1.24'
18
+ version: '1.26'
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: '1.24'
25
+ version: '1.26'
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: tins
28
28
  requirement: !ruby/object:Gem::Requirement