gem_hadar 1.25.0 → 1.27.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: db714afa72ba58c1676c20ec7efdfe235300f384f839ea663880b0ae976a9a0b
4
+ data.tar.gz: 6f1ebe9a6446fc600e00d0964a9f3f215cccc264454468bec4dc93e9ff8c674a
5
5
  SHA512:
6
- metadata.gz: a77a1a309790aac939d7aff2f3973c495baa92a3d36e3443747e7243aa0a6e09781a7162ddde5e36868316b85db3ab58c20bcb3f137b818dc5f458ed3b741fd1
7
- data.tar.gz: 8754d4b122caf5a5df4af137097440e84a4841f8c0b83fec7e635716997c59cbba36671e6b6b03230dbe1bceb319e131fbfb9c2734a155c8d5771692bfe31289
6
+ metadata.gz: c89a930270aa72bb13179e6bedd38c4cc5971f8924aba2f86c588925a62baf5141191d065289f6b7a75d1e05f99beb17b91db78f09c23529ab04625d3147b271
7
+ data.tar.gz: 5a1eddb1dba0410f324a519b3b445036ec8c6e53c2406968161169133d9f7fd17c1e4e558f9fa72d4b1bdbca4f532ec0e93a4ef616a0796521f2de2d86452dc2
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,437 @@ 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
- ## Usage
88
+ ## Configuration
89
+
90
+ ### Environment Variables
91
+
92
+ The following environment variables can be used to configure `gem_hadar`:
93
+
94
+ | Variable | Description | Default |
95
+ |----------|-------------|---------|
96
+ | `GEM_HOST_API_KEY` | API key for gem hosting services | Not set |
97
+ | `GITHUB_API_TOKEN` | GitHub personal access token for releases | Not set |
98
+ | `OLLAMA_MODEL` | Ollama model name for AI generation | `llama3.1` |
99
+ | `OLLAMA_HOST` | Ollama server host URL | `localhost:11434` |
100
+ | `OLLAMA_URL` | Direct Ollama API URL (takes precedence over `OLLAMA_HOST`) | Not set |
101
+ | `OLLAMA_MODEL_OPTIONS` | JSON configuration for Ollama model | Not set |
102
+ | `HOME` | User's home directory (used for config file locations) | System default |
103
+ | `XDG_CONFIG_HOME` | XDG configuration directory override | System default |
104
+ | `MAKE` | Make program to use for building extensions | `gmake` or `make` |
105
+ | `VERSION` | Override the version string for some tasks | Not set |
106
+ | `FORCE` | Force certain operations (1 to enable) | 0 |
107
+ | `GIT_REMOTE` | Git remote name(s) for operations, space separated | `origin` |
108
+ | `GITHUB_RELEASE_ENABLED` | Enable GitHub releases (yes/no) | Auto-detected |
109
+ | `EDITOR` | Editor to use for interactive tasks | `vi` |
110
+
111
+ ### Rubygems API
20
112
 
21
- Create a new directory and excecute
113
+ To publish gems to RubyGems.org, you'll need to set up an API key:
22
114
 
115
+ 1. Generate a new API key at: https://rubygems.org/profile/api\_keys/new
116
+ 2. Set the environment variable:
117
+
118
+ ```bash
119
+ export GEM_HOST_API_KEY="your_api_key_here"
23
120
  ```
24
- $ gem_hadar
121
+
122
+ **Security Note**: Never commit your API key to version control. Use a `.env`
123
+ file or your shell's configuration with appropriate loading mechanisms.
124
+
125
+ This key is required for tasks like `rake release` which push the gem package to RubyGems.org.
126
+
127
+ ### Github API
128
+
129
+ To enable GitHub release creation and other GitHub API interactions, you'll
130
+ need to set up a personal access token.
131
+
132
+ 1. Generate a new token at: https://github.com/settings/tokens/new
133
+ 2. Grant it `repo` scope for full repository access
134
+ 3. Set the environment variable:
135
+
136
+ ```bash
137
+ export GITHUB_API_TOKEN="your_token_here"
138
+ ```
139
+
140
+ **Security Note**: Never commit your token to version control. Use a `.env`
141
+ file or your shell's configuration with appropriate loading mechanisms.
142
+
143
+ This token is required for tasks like `rake github:release` which create GitHub
144
+ releases with AI-generated changelogs.
145
+
146
+ ### Local Ollama AI
147
+
148
+ The gem supports AI-powered changelog generation using Ollama. To configure
149
+ this functionality:
150
+
151
+ 1. Install and run Ollama locally: https://ollama.com/download
152
+ 2. Pull the desired model (e.g., `ollama pull deepseek-r1:32b`)
153
+ 3. Set the following environment variables:
154
+
155
+ ```bash
156
+ export OLLAMA_HOST="http://localhost:11434"
157
+ export OLLAMA_MODEL="deepseek-r1:32b"
158
+ export OLLAMA_MODEL_OPTIONS='{"num_ctx":16384,"seed":-1,"num_predict":512,"temperature":0.4,"top_p":0.95,"top_k":20,"min_p":0}'
159
+ ```
160
+
161
+ The default model is `llama3.1` and the default host is
162
+ `http://localhost:11434`. These can be overridden based on your local Ollama
163
+ setup.
164
+
165
+ The model options example configures:
166
+
167
+ - `num_ctx`: Context window size (16384 tokens)
168
+ - `temperature`: Response randomness (0.4 for balanced output)
169
+ - `num_predict`: Maximum tokens to generate (512)
170
+ - `top_p`, `top_k`, `min_p`: Sampling parameters for controlled generation
171
+
172
+ This functionality is used by the `rake github:release` and `rake version:bump`
173
+ task to generate AI-powered changelogs or suggest a version bump.
174
+
175
+ ### Custom AI Prompts
176
+
177
+ To customize the AI prompts used by `gem_hadar`, you can override the default
178
+ prompt files in your XDG configuration directory.
179
+
180
+ First, display the current default prompts using:
181
+
182
+ ```bash
183
+ $ rake gem_hadar:config
184
+ ```
185
+
186
+ This will show you the `XDG_CONFIG_HOME`, default system and user prompts for
187
+ version bumping and release generation. The output includes the exact template
188
+ variables that are available for use in your custom prompts.
189
+
190
+ Then, create the following files in your XDG configuration home directory:
191
+
192
+ - `version_bump_system_prompt.txt`
193
+ - `version_bump_prompt.txt`
194
+ - `release_system_prompt.txt`
195
+ - `release_prompt.txt`
196
+
197
+ Start with the default values shown by `rake gem_hadar:config` and modify them
198
+ to suit your needs. The prompts support standard Ruby string interpolation with
199
+ the following variables:
200
+
201
+ For version bump prompts:
202
+ - `%{version}` - Current gem version
203
+ - `%{log_diff}` - Git diff of changes
204
+
205
+ For release prompts:
206
+ - `%{name}` - Gem name
207
+ - `%{version}` - New version being released
208
+ - `%{log_diff}` - Git diff of changes
209
+
210
+ This approach ensures your custom prompts work correctly with the template
211
+ variables while maintaining consistency with the gem's expected input format.
212
+
213
+ ### Output current configuration
214
+
215
+ To debug or verify your `gem_hadar` configuration, you can use the following
216
+ rake task:
217
+
218
+ ```bash
219
+ $ rake gem_hadar:config
25
220
  ```
26
221
 
27
- Edit the created Rakefile until
222
+ This task displays all current configuration values including:
223
+ - GitHub API token (masked)
224
+ - RubyGems API key (masked)
225
+ - Ollama model settings
226
+ - Repository information (gem name, version)
227
+ - Build parameters (MAKE, EDITOR)
228
+ - Git configuration (remote)
229
+ - Other flags (FORCE, VERSION, GITHUB_RELEASE_ENABLED)
230
+ - XDG/HOME directories
231
+ - AI prompt defaults
232
+
233
+ ## Usage
234
+
235
+ ### Pre-requisites
236
+
237
+ Before using `gem_hadar`, ensure you have initialized a Git repository in your
238
+ project directory. Many of the gem's commands assume Git is available and
239
+ properly configured in the current working directory.
240
+
241
+ ### Quick Start with Generator
28
242
 
243
+ Create a new directory and execute:
244
+
245
+ ```bash
246
+ $ gem_hadar
29
247
  ```
248
+
249
+ This generates a basic gem structure with a Rakefile. Edit the generated Rakefile until:
250
+
251
+ ```bash
30
252
  $ rake gemspec
31
253
  ```
32
254
 
33
255
  and then
34
256
 
257
+ ```bash
258
+ $ rake build
259
+ ```
260
+
261
+ are performed as desired.
262
+
263
+ ### YARD Documentation
264
+
265
+ `gem_hadar` supports generating YARD documentation. To generate documentation, run:
266
+
267
+ ```bash
268
+ $ rake doc
269
+ ```
270
+
271
+ This will create documentation in the `doc` directory using YARD.
272
+
273
+ ### Rakefile Configuration Example
274
+
275
+ For more advanced control, here's a complete Rakefile configuration example:
276
+
277
+ ```ruby
278
+ # Rakefile
279
+ require 'gem_hadar'
280
+
281
+ GemHadar do
282
+ # Set developing to true if you don't have a homepage set yet
283
+ #developing true
284
+
285
+ name 'mygemname'
286
+ path_name 'mygem'
287
+ path_module 'Mygem'
288
+ author 'My name'
289
+ email 'my@mail'
290
+ homepage "https://github.com/younameit/mygem"
291
+ summary 'Precious gem'
292
+ description 'Precious detailed gem'
293
+ test_dir 'spec'
294
+ ignore 'pkg', 'Gemfile.lock', '.DS_Store'
295
+
296
+ readme 'README.md'
297
+ title "#{name.camelize} -- My library"
298
+ licenses << 'Apache-2.0'
299
+
300
+ dependency 'sinatra', '~> 3.2'
301
+ development_dependency 'rake'
302
+ development_dependency 'rspec'
303
+ end
304
+ ```
305
+
306
+ Note that `gem_hadar` is ["self hosted"](Rakefile)
307
+
308
+ ### Configuration settings in the GemHadar block
309
+
310
+ #### Core Required Attributes (Mapped to GemSpec)
311
+
312
+ - **`name`** - Required gem name (raises error if not set)
313
+ - **`version`** - Required version with fallback to `VERSION` file or ENV override
314
+ - **`authors`** - Required author names (mapped from `author`)
315
+ - **`email`** - Required author email (raises error if not set)
316
+ - **`homepage`** - Required homepage URL (raises error if not set). **Validation**: When `developing` is false, validates that the URL returns an HTTP OK status after following redirects.
317
+ - **`summary`** - Required summary description (raises error if not set)
318
+ - **`description`** - Required full description (raises error if not set)
319
+
320
+ #### Core Recommended Attributes
321
+
322
+ - **`licenses`** - Default: `Set[]`. License information for the gem
323
+ - **`required_ruby_version`** - Default: `nil`. Ruby version requirement
324
+
325
+ #### Build and Package Configuration
326
+
327
+ - **`require_paths`** - Default: `Set['lib']` (mapped to `require_paths`)
328
+ - **`test_dir`** - Default: `nil`
329
+ - **`spec_dir`** - Default: `nil`
330
+ - **`extensions`** - Default: `FileList['ext/**/extconf.rb']` (mapped to `extensions`)
331
+ - **`make`** - Default: `ENV['MAKE']` or system detection
332
+ - **`executables`** - Default: `Set[]` (mapped to `executables`)
333
+ - **`ignore_files`** - Default: `Set[]`
334
+ - **`package_ignore_files`** - Default: `Set[]`
335
+
336
+ #### Documentation and Files
337
+
338
+ - **`readme`** - Default: `nil`
339
+ - **`title`** - Default: `nil`
340
+ - **`doc_files`** - Default: `nil`
341
+ - **`yard_dir`** - Default: `nil`
342
+
343
+ #### Testing Configuration
344
+
345
+ - **`test_files`** - Default: `nil`
346
+ - **`spec_pattern`** - Default: `nil`
347
+ - **`bindir`** - Default: `nil` (mapped to `bindir`)
348
+
349
+ #### RVM Configuration (Nested)
350
+
351
+ ```ruby
352
+ rvm do
353
+ use # Default: detected ruby version from `rvm tools strings`
354
+ gemset # Default: gem name
355
+ end
356
+ ```
357
+
358
+ #### Task Dependencies
359
+
360
+ - **`default_task_dependencies`** - Default: `[:gemspec, :test]`
361
+ - **`build_task_dependencies`** - Default: `[:clobber, :gemspec, :package, :'version:tag']`
362
+ - **`push_task_dependencies`** - Default: `[:modified, :build, :master:push, :version:push, :gem:push, :github:release]`
363
+
364
+ #### Configuration Flags
365
+
366
+ - **`developing`** - Default: `false`. When set to `true`, skips URL validation including homepage link verification for faster development cycles.
367
+
368
+ ### Paths and Module Types
369
+
370
+ - **`path_name`** - Default: `name`. Returns the raw gem name value by default.
371
+ It is used for generating file paths and module names. This is particularly
372
+ useful for creating consistent directory structures and file naming
373
+ conventions. It's used internally by `GemHadar` to create the root directory
374
+ for the gem (`lib/my_gem` for name "my\_gem") and generate a `version.rb` file
375
+ in that location.
376
+
377
+ This can be changed for nested namespaces if desired.
378
+
379
+ **Example**: For gems in namespaces like `ACME` like
380
+ `ACME::BrainfuckCompiler`, you might set `path_name` to
381
+ `"acme/brainfuck_compiler"` to create the directory structure
382
+ `lib/acme/brainfuck_compiler/`.
383
+
384
+ - **`path_module`** - Default: `path_name.camelize`. Automatically converts the
385
+ gem name to CamelCase format (e.g., "my\_gem" becomes "MyGem",
386
+ "namespace/my\_gem" becomes "Namespace::MyGem") for use in Ruby module and
387
+ class declarations, ensuring consistency with Ruby naming
388
+ conventions. This value can be overridden if needed.
389
+
390
+ - **`module_type`** - Default: `:module`. Determines whether the generated code
391
+ structure for the version module should be a `:module` or `:class`. This
392
+ controls the type of Ruby construct created when generating code skeletons and
393
+ version files. The value
394
+ can be set to either:
395
+
396
+ - `:module` (default) - Generates module-based structure
397
+ - `:class` - Generates class-based structure
398
+
399
+ This is used in the generated `version.rb` file to create either:
400
+ ```ruby
401
+ module MyGem
402
+ # ... version constants
403
+ end
404
+ ```
405
+ or
406
+ ```ruby
407
+ class MyGem
408
+ # ... version constants
409
+ end
410
+ ```
411
+
412
+ These computed values serve as intelligent defaults that can be overridden
413
+ based on your specific requirements. They are automatically derived from other
414
+ DSL accessors and provide powerful convenience features that enable `GemHadar`
415
+ to generate consistent, well-structured Ruby code automatically.
416
+
417
+ ### Available Tasks
418
+
419
+ You can list all available tasks with:
420
+
421
+ ```bash
422
+ $ rake -T
35
423
  ```
424
+
425
+ #### Core Tasks
426
+
427
+ - `rake build` - Build task (builds all packages for a release)
428
+ - `rake release` - Release the new version 1.2.3 for the gem foo
429
+
430
+ #### Build Tasks
431
+
432
+ - `rake gemspec` - Create a gemspec file
433
+ - `rake package` - Build all the packages
434
+ - `rake gem` - Build the gem file foo-1.2.3.gem
435
+ - `rake clobber` - Remove any generated files
436
+ - `rake clobber_package` - Remove package products
437
+ - `rake repackage` - Force a rebuild of the package files
438
+
439
+ #### Version Management
440
+
441
+ - `rake version` - Writing version information for foo
442
+ - `rake version:show` - Displaying the current version
443
+ - `rake version:list` - List all versions in order
444
+ - `rake version:diff` - Displaying the diff from env var VERSION to the next version or HEAD
445
+ - `rake version:tag` - Tag this commit as version 1.2.3
446
+ - `rake version:bump` - Bump version with AI suggestion
447
+ - `rake version:bump:major` - Bump major version
448
+ - `rake version:bump:minor` - Bump minor version
449
+ - `rake version:bump:build` - Bump build version
450
+ - `rake version:push` - Push version 1.2.3 to all git remotes: origin
451
+ - `rake version:origin:push` - Push version 1.2.3 to git remote origin
452
+
453
+ #### Documentation
454
+
455
+ - `rake doc` - Create yard documentation (including private)
456
+ - `rake yard_doc` - Generate YARD Documentation
457
+ - `rake yard:doc` - Create yard documentation
458
+ - `rake yard:private` - Create yard documentation (including private)
459
+ - `rake yard:public` - Create yard documentation
460
+ - `rake yard:clean` - Clean the yard documentation
461
+ - `rake yard:view` - View the yard documentation
462
+ - `rake yard:list-undoc` - List all undocumented classes/modules/methods
463
+
464
+ #### Testing & Development
465
+
466
+ - `rake run_specs` - Run RSpec code examples
467
+ - `rake clean` - Remove any temporary products
468
+ - `rake gems:install` - Install all gems from the Gemfile
469
+ - `rake gem_hadar:update` - Update `gem_hadar` to a different version
470
+ - `rake rvm` - Create .rvmrc file
471
+ - `rake default` - Default task
472
+ - `rake compile` - Compile project extensions (if configured)
473
+
474
+ #### Publishing Tasks
475
+ - `rake push` - Push all changes for version 1.2.3 into the internets
476
+ - `rake github:release` - Create a new GitHub release for the current version
477
+ with AI-generated changelog
478
+
479
+ ### Update Version
480
+
481
+ Use one of the following rake tasks to bump the version:
482
+
483
+ - `rake version:bump:major` - Bump major version (e.g., 1.2.3 → 2.0.0)
484
+ - `rake version:bump:minor` - Bump minor version (e.g., 1.2.3 → 1.3.0)
485
+ - `rake version:bump:build` - Bump build version (e.g., 1.2.3 → 1.2.4)
486
+ - `rake version:bump` - Get AI-powered suggestion for appropriate bump level
487
+
488
+ Or bump your [VERSION](./VERSION) file by hand.
489
+
490
+ ### Release
491
+
492
+ ```bash
36
493
  $ rake build
37
494
  ```
38
495
 
39
- are perfomed as desired.
496
+ This command will execute a series of dependent tasks in order: cleaning
497
+ previous builds, generating the gem specification, packaging the gem, and
498
+ creating a git tag with the current version in git.
499
+
500
+ After all the files have been changed correctly and the git tags have been
501
+ moved forward to the appropriate commit you can finally enter:
502
+
503
+ ```bash
504
+ $ rake release
505
+ ```
506
+
507
+ The `rake release` command performs the final publishing steps: pushing the
508
+ master branch and version tag to all git remotes, pushing the gem package to
509
+ RubyGems.org, and creating a GitHub release with AI-generated changelog.
40
510
 
41
511
  ## Author
42
512
 
43
- Florian Frank \<mailto:flori@ping.de\>
44
- **GemHadar** was written by [Florian Frank](mailto:flori@ping.de)
513
+ **GemHadar** was written by [Florian Frank](mailto:flori@ping.de).
45
514
 
46
515
  ## License
47
516
 
48
- This software is licensed under the _MIT_ license.
517
+ This software is licensed under the [MIT](./LICENSE) license.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.25.0
1
+ 1.27.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.27.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.27.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.27".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]