gem_hadar 2.0.2 → 2.0.4
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/VERSION +1 -1
- data/gem_hadar.gemspec +2 -2
- data/lib/gem_hadar/github.rb +20 -0
- data/lib/gem_hadar/prompt_template.rb +8 -0
- data/lib/gem_hadar/setup.rb +11 -0
- data/lib/gem_hadar/simplecov.rb +38 -0
- data/lib/gem_hadar/template_compiler.rb +14 -0
- data/lib/gem_hadar/utils.rb +14 -0
- data/lib/gem_hadar/version.rb +1 -1
- data/lib/gem_hadar.rb +498 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02a07af5340e02cca960b8c50bb32129d4c7203c9dc337bbe57354fe754490c2
|
4
|
+
data.tar.gz: 7adb26caabcdb62ecb45a0179384fe9ade1c0bf50718252f4b2e0c1ec962ce02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28357b3be7f6b52bc5dc268d0483685b31ccf37801f011867014ee1e4a6c96932b84a8e6706d828d7c89ee0e6034f057785e1eea3a1bd86e066d3ac0d87c0e91
|
7
|
+
data.tar.gz: 4728c3ab51a1ade4e60887e421e37395899365a5caa2adc0d031127fbd39419befe7fa63175ab34e978ce5c20c439e5cd2a9d674034b63eee203cadbea8c4ecd
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.4
|
data/gem_hadar.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: gem_hadar 2.0.
|
2
|
+
# stub: gem_hadar 2.0.4 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "gem_hadar".freeze
|
6
|
-
s.version = "2.0.
|
6
|
+
s.version = "2.0.4".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]
|
data/lib/gem_hadar/github.rb
CHANGED
@@ -4,6 +4,26 @@ require 'json'
|
|
4
4
|
module GemHadar::GitHub
|
5
5
|
end
|
6
6
|
|
7
|
+
# A client for creating GitHub releases via the GitHub API.
|
8
|
+
#
|
9
|
+
# This class provides functionality to interact with the GitHub Releases API,
|
10
|
+
# enabling the creation of new releases for a specified repository. It handles
|
11
|
+
# the HTTP request setup, including appropriate headers and authentication,
|
12
|
+
# and processes the API response to either return the created release data or
|
13
|
+
# raise an error if the creation fails.
|
14
|
+
#
|
15
|
+
# @example Creating a release
|
16
|
+
# creator = GemHadar::GitHub::ReleaseCreator.new(
|
17
|
+
# owner: 'myorg',
|
18
|
+
# repo: 'myrepo',
|
19
|
+
# token: 'ghp_mytoken'
|
20
|
+
# )
|
21
|
+
# release_data = creator.perform(
|
22
|
+
# tag_name: 'v1.0.0',
|
23
|
+
# target_commitish: 'main',
|
24
|
+
# body: 'Release notes here',
|
25
|
+
# name: 'Version 1.0.0'
|
26
|
+
# )
|
7
27
|
class GemHadar::GitHub::ReleaseCreator
|
8
28
|
class << self
|
9
29
|
attr_accessor :github_api_url
|
@@ -1,3 +1,11 @@
|
|
1
|
+
# A module that provides default prompt templates for interacting with AI models
|
2
|
+
# when generating GitHub release changelogs and semantic version bump suggestions.
|
3
|
+
#
|
4
|
+
# This module contains methods that return system prompts and template strings
|
5
|
+
# used by the GemHadar framework to instruct AI models on how to format
|
6
|
+
# responses for release notes and versioning decisions. These prompts are
|
7
|
+
# designed to produce structured, relevant output that aligns with
|
8
|
+
# development workflow requirements.
|
1
9
|
module GemHadar::PromptTemplate
|
2
10
|
# The default_git_release_system_prompt method returns the system prompt used
|
3
11
|
# for generating GitHub release changelogs.
|
data/lib/gem_hadar/setup.rb
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
# A class that handles the initialization and setup of a new gem project
|
2
|
+
# structure.
|
3
|
+
#
|
4
|
+
# This class is responsible for creating the basic directory layout and
|
5
|
+
# configuration files needed for a Ruby gem project. It ensures that essential
|
6
|
+
# components like the lib directory, VERSION file, and Rakefile are in place,
|
7
|
+
# providing a solid foundation for gem development.
|
8
|
+
#
|
9
|
+
# @example Setting up a new gem project
|
10
|
+
# setup = GemHadar::Setup.new
|
11
|
+
# setup.perform
|
1
12
|
class GemHadar::Setup
|
2
13
|
include FileUtils
|
3
14
|
|
data/lib/gem_hadar/simplecov.rb
CHANGED
@@ -6,7 +6,32 @@ require 'pathname'
|
|
6
6
|
class GemHadar
|
7
7
|
end
|
8
8
|
|
9
|
+
# A module that provides SimpleCov-related functionality for code coverage
|
10
|
+
# analysis.
|
11
|
+
#
|
12
|
+
# This module encapsulates the setup and configuration of SimpleCov for Ruby
|
13
|
+
# projects, including initialization, formatter selection, and warning message
|
14
|
+
# handling. It integrates with the GemHadar framework to provide detailed
|
15
|
+
# coverage reporting capabilities while maintaining consistent output
|
16
|
+
# formatting and error handling.
|
17
|
+
#
|
18
|
+
# @example Initializing SimpleCov with GemHadar GemHadar::SimpleCov.start
|
9
19
|
module GemHadar::SimpleCov
|
20
|
+
# A module that provides warning functionality with colored output.
|
21
|
+
#
|
22
|
+
# This module enhances the standard warn method to display warning messages
|
23
|
+
# in orange color, making them more visible in terminal outputs. It is
|
24
|
+
# designed to be included in classes that need consistent warning message
|
25
|
+
# formatting throughout the application.
|
26
|
+
#
|
27
|
+
# @example Using the warn method from this module
|
28
|
+
# class MyClass
|
29
|
+
# include GemHadar::SimpleCov::WarnModule
|
30
|
+
#
|
31
|
+
# def my_method
|
32
|
+
# warn "This is a warning message"
|
33
|
+
# end
|
34
|
+
# end
|
10
35
|
module WarnModule
|
11
36
|
# The warn method displays warning messages using orange colored output.
|
12
37
|
#
|
@@ -23,6 +48,19 @@ module GemHadar::SimpleCov
|
|
23
48
|
end
|
24
49
|
end
|
25
50
|
|
51
|
+
# A formatter class that generates detailed JSON coverage reports from
|
52
|
+
# SimpleCov results.
|
53
|
+
#
|
54
|
+
# This class is responsible for processing code coverage data produced by
|
55
|
+
# SimpleCov and transforming it into a structured JSON format that includes
|
56
|
+
# both line and branch coverage statistics for individual files, as well as
|
57
|
+
# overall project coverage metrics. It calculates various percentages and
|
58
|
+
# counts, then writes the complete coverage data to a dedicated JSON file in
|
59
|
+
# the coverage directory.
|
60
|
+
#
|
61
|
+
# @example Using the ContextFormatter to generate coverage reports
|
62
|
+
# formatter = GemHadar::SimpleCov::ContextFormatter.new
|
63
|
+
# formatter.format(simplecov_result)
|
26
64
|
class ContextFormatter
|
27
65
|
include FileUtils
|
28
66
|
|
@@ -1,5 +1,19 @@
|
|
1
1
|
require 'erb'
|
2
2
|
|
3
|
+
# A class for compiling ERB template files into their final output
|
4
|
+
# representations.
|
5
|
+
#
|
6
|
+
# The TemplateCompiler class provides functionality to process ERB templates,
|
7
|
+
# substituting placeholders with actual values from a configuration block. It
|
8
|
+
# handles the reading of template files, rendering them with the provided
|
9
|
+
# context, and writing the resulting content to specified destination files.
|
10
|
+
#
|
11
|
+
# @example Compiling a template file
|
12
|
+
# compiler = GemHadar::TemplateCompiler.new do |t|
|
13
|
+
# t.name = 'my_template'
|
14
|
+
# t.version = '1.0.0'
|
15
|
+
# end
|
16
|
+
# compiler.compile('template.erb', 'output.txt')
|
3
17
|
class GemHadar::TemplateCompiler
|
4
18
|
include Tins::BlockSelf
|
5
19
|
include Tins::MethodMissingDelegator::DelegatorModule
|
data/lib/gem_hadar/utils.rb
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
|
3
|
+
# A module that provides utility methods for handling XDG Base Directory
|
4
|
+
# specification compliance.
|
5
|
+
#
|
6
|
+
# This module offers functionality to determine the appropriate configuration
|
7
|
+
# directory based on the XDG Base Directory specification, construct paths for
|
8
|
+
# configuration files, and retrieve configuration data from those files. It
|
9
|
+
# helps ensure consistent and standardized handling of user configuration files
|
10
|
+
# across different operating systems.
|
11
|
+
#
|
12
|
+
# @example Determining the XDG configuration directory
|
13
|
+
# config_dir = GemHadar::Utils.xdg_config_home
|
14
|
+
#
|
15
|
+
# @example Retrieving configuration file contents
|
16
|
+
# config_content = GemHadar::Utils.xdg_config('myapp', 'default_value')
|
3
17
|
module GemHadar::Utils
|
4
18
|
# The xdg_config_home method determines the path to the XDG configuration
|
5
19
|
# directory.
|
data/lib/gem_hadar/version.rb
CHANGED
data/lib/gem_hadar.rb
CHANGED
@@ -22,6 +22,40 @@ require_maybe 'simplecov'
|
|
22
22
|
require_maybe 'rubygems/package_task'
|
23
23
|
require_maybe 'rcov/rcovtask'
|
24
24
|
require_maybe 'rspec/core/rake_task'
|
25
|
+
|
26
|
+
# A brief description of the GemHadar class.
|
27
|
+
#
|
28
|
+
# The GemHadar class serves as the primary configuration and task management
|
29
|
+
# framework for Ruby gem projects. It provides a DSL for defining gem metadata,
|
30
|
+
# dependencies, and Rake tasks, while also offering integration with various
|
31
|
+
# tools such as GitHub, SimpleCov, YARD, and Ollama for automating common
|
32
|
+
# development workflows.
|
33
|
+
#
|
34
|
+
# @example Configuring a gem using the GemHadar DSL
|
35
|
+
# GemHadar do
|
36
|
+
# name 'my_gem'
|
37
|
+
# version '1.0.0'
|
38
|
+
# author 'John Doe'
|
39
|
+
# email 'john@example.com'
|
40
|
+
# homepage 'https://github.com/example/my_gem'
|
41
|
+
# summary 'A brief description'
|
42
|
+
# description 'A longer description of the gem'
|
43
|
+
# test_dir 'spec'
|
44
|
+
# end
|
45
|
+
#
|
46
|
+
# @example Creating a Rake task for building and packaging the gem
|
47
|
+
# GemHadar do
|
48
|
+
# name 'my_gem'
|
49
|
+
# # ... other configuration ...
|
50
|
+
# build_task
|
51
|
+
# end
|
52
|
+
#
|
53
|
+
# @example Setting up version bumping with AI assistance
|
54
|
+
# GemHadar do
|
55
|
+
# name 'my_gem'
|
56
|
+
# # ... other configuration ...
|
57
|
+
# version_bump_task
|
58
|
+
# end
|
25
59
|
class GemHadar
|
26
60
|
end
|
27
61
|
require 'gem_hadar/version'
|
@@ -45,6 +79,12 @@ class GemHadar
|
|
45
79
|
extend DSLKit::DSLAccessor
|
46
80
|
include Tins::SecureWrite
|
47
81
|
|
82
|
+
# The initialize method sets up the GemHadar instance by initializing
|
83
|
+
# dependency arrays and evaluating a configuration block.
|
84
|
+
#
|
85
|
+
# @param block [Proc] optional configuration block to set gem properties and settings
|
86
|
+
#
|
87
|
+
# @return [GemHadar] the initialized GemHadar instance
|
48
88
|
def initialize(&block)
|
49
89
|
@dependencies = []
|
50
90
|
@development_dependencies = []
|
@@ -61,62 +101,263 @@ class GemHadar
|
|
61
101
|
fail "#{self.class}: #{name} has to be set for gem"
|
62
102
|
end
|
63
103
|
|
104
|
+
# The developing attribute accessor for configuring development mode.
|
105
|
+
#
|
106
|
+
# This method sets up a DSL accessor for the developing attribute, which
|
107
|
+
# controls whether the gem is in development mode. When set to true, certain
|
108
|
+
# behaviors such as skipping gem pushes are enabled as well as asserting the
|
109
|
+
# validity of the homepage link.
|
110
|
+
#
|
111
|
+
# @return [ Boolean ] the current value of the developing flag
|
64
112
|
dsl_accessor :developing, false
|
65
113
|
|
114
|
+
# The name attribute accessor for configuring the gem's name.
|
115
|
+
#
|
116
|
+
# This method sets up a DSL accessor for the name attribute, which specifies
|
117
|
+
# the identifier for the gem. It includes a validation step that raises an
|
118
|
+
# ArgumentError if the name has not been set, ensuring that the gem
|
119
|
+
# configuration contains a required name value.
|
120
|
+
#
|
121
|
+
# @return [ String ] the name of the gem
|
122
|
+
#
|
123
|
+
# @raise [ ArgumentError ] if the name attribute has not been set
|
66
124
|
dsl_accessor :name do
|
67
125
|
has_to_be_set :name
|
68
126
|
end
|
69
127
|
|
128
|
+
# The name_version method computes and returns the combined gem name and
|
129
|
+
# version string.
|
130
|
+
#
|
131
|
+
# This method constructs a version identifier by joining the gem's name and
|
132
|
+
# current version with a hyphen separator. It is typically used to generate
|
133
|
+
# filenames or identifiers that incorporate both the gem name and its version
|
134
|
+
# number for packaging, tagging, or display purposes.
|
135
|
+
#
|
136
|
+
# @return [ String ] the combined gem name and version in the format "name-version"
|
70
137
|
dsl_accessor :name_version do
|
71
138
|
[ name, version ] * '-'
|
72
139
|
end
|
73
140
|
|
141
|
+
# The module_type attribute accessor for configuring the type of Ruby construct to generate for version code.
|
142
|
+
#
|
143
|
+
# This method sets up a DSL accessor for the module_type attribute, which determines whether the generated code
|
144
|
+
# structure for the version module should be a :module or :class. This controls the type of Ruby construct
|
145
|
+
# created when generating code skeletons and version files. The value can be set to either:
|
146
|
+
#
|
147
|
+
# - :module (default) - Generates module-based structure
|
148
|
+
# - :class - Generates class-based structure
|
149
|
+
#
|
150
|
+
# This is used in the generated version.rb file to create either:
|
151
|
+
#
|
152
|
+
# module MyGem
|
153
|
+
# # ... version constants
|
154
|
+
# end
|
155
|
+
#
|
156
|
+
# or
|
157
|
+
#
|
158
|
+
# class MyGem
|
159
|
+
# # ... version constants
|
160
|
+
# end
|
161
|
+
#
|
162
|
+
# @return [ Symbol ] the type of Ruby construct to generate (:module or :class)
|
74
163
|
dsl_accessor :module_type, :module
|
75
164
|
|
165
|
+
# The has_to_be_set method raises an error if a required gem configuration
|
166
|
+
# attribute is not set.
|
167
|
+
#
|
168
|
+
# This method is used to validate that essential gem configuration attributes
|
169
|
+
# have been provided. When called, it will raise an ArgumentError with a
|
170
|
+
# descriptive message indicating which attribute is missing and needs to be
|
171
|
+
# configured.
|
172
|
+
#
|
173
|
+
# @param name [ String ] the name of the required attribute
|
174
|
+
#
|
175
|
+
# @raise [ ArgumentError ] if the specified attribute has not been set
|
76
176
|
dsl_accessor :author do
|
77
177
|
has_to_be_set :author
|
78
178
|
end
|
79
179
|
|
180
|
+
# The email attribute accessor for configuring the gem's author email.
|
181
|
+
#
|
182
|
+
# This method sets up a DSL accessor for the email attribute, which specifies
|
183
|
+
# the contact email address for the gem's author. It includes a
|
184
|
+
# validation step that raises an ArgumentError if the email has not been
|
185
|
+
# set, ensuring that the gem configuration contains this required
|
186
|
+
# information.
|
187
|
+
#
|
188
|
+
# @return [ String ] the author's email address
|
189
|
+
#
|
190
|
+
# @raise [ ArgumentError ] if the email attribute has not been set
|
80
191
|
dsl_accessor :email do
|
81
192
|
has_to_be_set :email
|
82
193
|
end
|
83
194
|
|
195
|
+
# The homepage attribute accessor for configuring the gem's homepage URL.
|
196
|
+
#
|
197
|
+
# This method sets up a DSL accessor for the homepage attribute, which
|
198
|
+
# specifies the URL of the gem's official repository or project page. It
|
199
|
+
# includes a validation step that raises an ArgumentError if the homepage has
|
200
|
+
# not been set, ensuring that the gem configuration contains this required
|
201
|
+
# information. When the developing flag is false, it also validates that the
|
202
|
+
# provided URL returns an HTTP OK status after following redirects.
|
203
|
+
#
|
204
|
+
# @return [ String ] the homepage URL of the gem
|
205
|
+
#
|
206
|
+
# @raise [ ArgumentError ] if the homepage attribute has not been set
|
207
|
+
# @raise [ ArgumentError ] if the homepage URL is invalid and developing mode is disabled
|
84
208
|
dsl_accessor :homepage do
|
85
209
|
has_to_be_set :homepage
|
86
210
|
end
|
87
211
|
|
212
|
+
# The summary attribute accessor for configuring the gem's summary.
|
213
|
+
#
|
214
|
+
# This method sets up a DSL accessor for the summary attribute, which
|
215
|
+
# specifies a brief description of what the gem does. It includes a
|
216
|
+
# validation step that raises an ArgumentError if the summary has not been
|
217
|
+
# set, ensuring that the gem configuration contains this required
|
218
|
+
# information.
|
219
|
+
#
|
220
|
+
# @return [ String ] the summary of the gem
|
221
|
+
#
|
222
|
+
# @raise [ ArgumentError ] if the summary attribute has not been set
|
88
223
|
dsl_accessor :summary do
|
89
224
|
has_to_be_set :summary
|
90
225
|
end
|
91
226
|
|
92
|
-
|
93
|
-
|
94
|
-
|
227
|
+
# The description attribute accessor for configuring the gem's description.
|
228
|
+
#
|
229
|
+
# This method sets up a DSL accessor for the description attribute, which
|
230
|
+
# specifies the detailed explanation of what the gem does. It includes a
|
231
|
+
# validation step that raises an ArgumentError if the description has not
|
232
|
+
# been set, ensuring that the gem configuration contains this required
|
233
|
+
# information.
|
234
|
+
#
|
235
|
+
# @return [ String ] the description of the gem
|
236
|
+
#
|
237
|
+
# @raise [ ArgumentError ] if the description attribute has not been set
|
238
|
+
dsl_accessor :description do has_to_be_set :description end
|
95
239
|
|
240
|
+
# The require_paths attribute accessor for configuring the gem's require
|
241
|
+
# paths.
|
242
|
+
#
|
243
|
+
# This method sets up a DSL accessor for the require_paths attribute, which
|
244
|
+
# specifies the directories from which the gem's code can be loaded. It
|
245
|
+
# provides a way to define the locations of the library files that will be
|
246
|
+
# made available to users of the gem when it is required in Ruby programs.
|
247
|
+
#
|
248
|
+
# @return [ Set<String> ] a set of directory paths to be included in the load
|
249
|
+
# path
|
96
250
|
dsl_accessor :require_paths do Set['lib'] end
|
97
251
|
|
252
|
+
# The require_path method manages the gem's require path configuration.
|
253
|
+
#
|
254
|
+
# This method provides functionality to set or retrieve the directory paths
|
255
|
+
# from which the gem's code can be loaded. When called with a path argument,
|
256
|
+
# it updates the require_paths attribute with that path and returns it.
|
257
|
+
# When called without arguments, it returns the first path from the current
|
258
|
+
# require_paths set.
|
259
|
+
#
|
260
|
+
# @param path [ String, nil ] the directory path to set as the require path;
|
261
|
+
# if nil, returns the current first require path
|
262
|
+
#
|
263
|
+
# @return [ String ] the specified path when setting, or the first require
|
264
|
+
# path when retrieving
|
98
265
|
def require_path(path = nil)
|
99
266
|
if path
|
100
267
|
self.require_paths = Set[path]
|
268
|
+
path
|
101
269
|
else
|
102
270
|
require_paths.first
|
103
271
|
end
|
104
272
|
end
|
105
273
|
|
274
|
+
# The readme attribute accessor for configuring the gem's README file.
|
275
|
+
#
|
276
|
+
# This method sets up a DSL accessor for the readme attribute, which specifies
|
277
|
+
# the path to the README file for the gem. It provides a way to define the
|
278
|
+
# location of the README file that will be used in documentation and packaging
|
279
|
+
# processes.
|
280
|
+
#
|
281
|
+
# @return [ String, nil ] the path to the README file or nil if not set
|
106
282
|
dsl_accessor :readme
|
107
283
|
|
284
|
+
# The title attribute accessor for configuring the gem's documentation title.
|
285
|
+
#
|
286
|
+
# This method sets up a DSL accessor for the title attribute, which specifies
|
287
|
+
# the title to be used in the generated YARD documentation. It provides a way
|
288
|
+
# to define a custom title that will be included in the documentation output,
|
289
|
+
# making it easier to identify and reference the gem's documentation.
|
290
|
+
#
|
291
|
+
# @return [ String, nil ] the documentation title or nil if not set
|
108
292
|
dsl_accessor :title
|
109
293
|
|
294
|
+
# The ignore_files attribute accessor for configuring files to be ignored by
|
295
|
+
# the gem.
|
296
|
+
#
|
297
|
+
# This method sets up a DSL accessor for the ignore_files attribute, which
|
298
|
+
# specifies a set of file patterns that should be excluded from various gem
|
299
|
+
# operations and processing tasks. It provides a way to define ignore rules
|
300
|
+
# that apply broadly across the gem's functionality, including but not
|
301
|
+
# limited to build processes, documentation generation, and version control
|
302
|
+
# integration.
|
303
|
+
#
|
304
|
+
# @return [ Set<String> ] a set of file patterns to be ignored by the gem's operations
|
110
305
|
dsl_accessor :ignore_files do Set[] end
|
111
306
|
|
112
|
-
|
113
|
-
|
307
|
+
# The bindir attribute accessor for configuring the gem's binary directory.
|
308
|
+
#
|
309
|
+
# This method sets up a DSL accessor for the bindir attribute, which specifies
|
310
|
+
# the directory where executable scripts (binaries) are installed when the gem
|
311
|
+
# is packaged and installed. It provides a way to define the location of the
|
312
|
+
# bin directory that will contain the gem's executable files.
|
313
|
+
#
|
314
|
+
# @return [ String, nil ] the path to the binary directory or nil if not set
|
114
315
|
dsl_accessor :bindir
|
115
316
|
|
317
|
+
# The executables attribute accessor for configuring the gem's executable
|
318
|
+
# files.
|
319
|
+
#
|
320
|
+
# This method sets up a DSL accessor for the executables attribute, which
|
321
|
+
# specifies the list of executable scripts that should be installed as part
|
322
|
+
# of the gem. It provides a way to define one or more executable file names
|
323
|
+
# that will be made available in the gem's bin directory when the gem is
|
324
|
+
# installed.
|
325
|
+
#
|
326
|
+
# @return [ Set<String> ] a set of executable file names to be included with
|
327
|
+
# the gem
|
116
328
|
dsl_accessor :executables do Set[] end
|
117
329
|
|
330
|
+
# The licenses attribute accessor for configuring the gem's license
|
331
|
+
# information.
|
332
|
+
#
|
333
|
+
# This method sets up a DSL accessor for the licenses attribute, which
|
334
|
+
# specifies the license(s) under which the gem is distributed. It provides a
|
335
|
+
# way to define one or more licenses that apply to the gem, defaulting to an
|
336
|
+
# empty Set if none are explicitly configured.
|
337
|
+
#
|
338
|
+
# @return [ Set<String> ] a set of license identifiers applied to the gem
|
118
339
|
dsl_accessor :licenses do Set[] end
|
119
340
|
|
341
|
+
# The test_dir attribute accessor for configuring the test directory.
|
342
|
+
#
|
343
|
+
# This method sets up a DSL accessor for the test_dir attribute, which specifies
|
344
|
+
# the directory where test files are located. It provides a way to define the
|
345
|
+
# location of the test directory that will be used by various testing tasks and
|
346
|
+
# configurations within the gem project.
|
347
|
+
#
|
348
|
+
# @return [ String, nil ] the path to the test directory or nil if not set
|
349
|
+
dsl_accessor :test_dir
|
350
|
+
|
351
|
+
# The test_files attribute accessor for configuring the list of test files to
|
352
|
+
# be included in the gem package.
|
353
|
+
#
|
354
|
+
# This method sets up a DSL accessor for the test_files attribute, which
|
355
|
+
# specifies the files that should be included when running tests for the gem.
|
356
|
+
# It provides a way to customize the test file discovery process, defaulting
|
357
|
+
# to finding all Ruby files ending in _spec.rb within the spec directory and
|
358
|
+
# its subdirectories.
|
359
|
+
#
|
360
|
+
# @return [ FileList ] a list of file paths to be included in test execution
|
120
361
|
dsl_accessor :test_files do
|
121
362
|
if test_dir
|
122
363
|
FileList[File.join(test_dir, '**/*.rb')]
|
@@ -125,8 +366,28 @@ class GemHadar
|
|
125
366
|
end
|
126
367
|
end
|
127
368
|
|
369
|
+
# The spec_dir attribute accessor for configuring the RSpec specification
|
370
|
+
# directory.
|
371
|
+
#
|
372
|
+
# This method sets up a DSL accessor for the spec_dir attribute, which
|
373
|
+
# specifies the directory where RSpec test files are located. It provides a
|
374
|
+
# way to customize the location of test specifications separate from the
|
375
|
+
# default 'spec' directory, allowing for more flexible project structures.
|
376
|
+
#
|
377
|
+
# @return [ String, nil ] the path to the RSpec specification directory or
|
378
|
+
# nil if not set
|
128
379
|
dsl_accessor :spec_dir
|
129
380
|
|
381
|
+
# The spec_pattern method configures the pattern used to locate RSpec test
|
382
|
+
# files.
|
383
|
+
#
|
384
|
+
# This method sets up a DSL accessor for the spec_pattern attribute, which
|
385
|
+
# defines the file pattern used to discover RSpec test files in the project.
|
386
|
+
# It defaults to a standard pattern that looks for files ending in _spec.rb
|
387
|
+
# within the spec directory and its subdirectories, but can be customized
|
388
|
+
# through the configuration block.
|
389
|
+
#
|
390
|
+
# @return [ String ] the file pattern used to locate RSpec test files
|
130
391
|
dsl_accessor :spec_pattern do
|
131
392
|
if spec_dir
|
132
393
|
"#{spec_dir}{,/*/**}/*_spec.rb"
|
@@ -135,32 +396,123 @@ class GemHadar
|
|
135
396
|
end
|
136
397
|
end
|
137
398
|
|
399
|
+
# The doc_files attribute accessor for configuring additional documentation
|
400
|
+
# files.
|
401
|
+
#
|
402
|
+
# This method sets up a DSL accessor for the doc_files attribute, which
|
403
|
+
# specifies additional files to be included in the YARD documentation
|
404
|
+
# generation process. It defaults to an empty FileList and provides a way to
|
405
|
+
# define extra documentation files that should be processed alongside the
|
406
|
+
# standard library source files.
|
407
|
+
#
|
408
|
+
# @return [ FileList ] a list of file paths to be included in YARD
|
409
|
+
# documentation
|
138
410
|
dsl_accessor :doc_files do
|
139
411
|
FileList[File.join('lib/**/*.rb')] + FileList[File.join('ext/**/*.c')]
|
140
412
|
end
|
141
413
|
|
414
|
+
# The yard_dir attribute accessor for configuring the output directory for
|
415
|
+
# YARD documentation.
|
416
|
+
#
|
417
|
+
# This method sets up a DSL accessor for the yard_dir attribute, which
|
418
|
+
# specifies the directory where YARD documentation will be generated. It
|
419
|
+
# defaults to 'doc' and provides a way to customize the documentation output
|
420
|
+
# location through the configuration block.
|
421
|
+
#
|
422
|
+
# @return [ String ] the path to the directory where YARD documentation will be stored
|
142
423
|
dsl_accessor :yard_dir do
|
143
424
|
'doc'
|
144
425
|
end
|
145
426
|
|
427
|
+
# The extensions attribute accessor for configuring project extensions.
|
428
|
+
#
|
429
|
+
# This method sets up a DSL accessor for the extensions attribute, which
|
430
|
+
# specifies the list of extension configuration files (typically extconf.rb)
|
431
|
+
# that should be compiled when building the gem. It defaults to finding all
|
432
|
+
# extconf.rb files within the ext directory and its subdirectories, making it
|
433
|
+
# easy to include native extensions in the gem package.
|
434
|
+
#
|
435
|
+
# @return [ FileList ] a list of file paths to extension configuration files
|
436
|
+
# to be compiled during the build process
|
146
437
|
dsl_accessor :extensions do FileList['ext/**/extconf.rb'] end
|
147
438
|
|
439
|
+
# The make method retrieves the make command to be used for building
|
440
|
+
# extensions.
|
441
|
+
#
|
442
|
+
# This method determines the appropriate make command to use when compiling
|
443
|
+
# project extensions. It first checks for the MAKE environment variable and
|
444
|
+
# returns its value if set. If the environment variable is not set, it
|
445
|
+
# attempts to detect a suitable make command by testing for the existence of
|
446
|
+
# 'gmake' and 'make' in the system PATH.
|
447
|
+
#
|
448
|
+
# @return [ String, nil ] the make command name or nil if none found
|
148
449
|
dsl_accessor :make do
|
149
450
|
ENV['MAKE'] || %w[gmake make].find { |c| system(c, '-v') }
|
150
451
|
end
|
151
452
|
|
453
|
+
# The files attribute accessor for configuring the list of files included in
|
454
|
+
# the gem package.
|
455
|
+
#
|
456
|
+
# This method sets up a DSL accessor for the files attribute, which specifies
|
457
|
+
# the complete set of files that should be included when building the gem
|
458
|
+
# package. It defaults to retrieving the file list from Git using `git
|
459
|
+
# ls-files` and provides a way to override this behavior through the
|
460
|
+
# configuration block.
|
461
|
+
#
|
462
|
+
# @return [ Array<String> ] an array of file paths to be included in the gem package
|
152
463
|
dsl_accessor :files do
|
153
464
|
`git ls-files`.split("\n")
|
154
465
|
end
|
155
466
|
|
467
|
+
# The package_ignore_files attribute accessor for configuring files to be
|
468
|
+
# ignored during gem packaging.
|
469
|
+
#
|
470
|
+
# This method sets up a DSL accessor for the package_ignore_files attribute,
|
471
|
+
# which specifies file patterns that should be excluded from the gem package
|
472
|
+
# when it is built. It defaults to an empty set and provides a way to define
|
473
|
+
# ignore rules specific to the packaging process, separate from general
|
474
|
+
# project ignore rules.
|
475
|
+
#
|
476
|
+
# @return [ Set<String> ] a set of file patterns to be ignored during gem packaging
|
156
477
|
dsl_accessor :package_ignore_files do
|
157
478
|
Set[]
|
158
479
|
end
|
159
480
|
|
481
|
+
# The path_name attribute accessor for configuring the gem's path name.
|
482
|
+
#
|
483
|
+
# This method sets up a DSL accessor for the path_name attribute, which
|
484
|
+
# determines the raw gem name value used for generating file paths and module
|
485
|
+
# names. It defaults to the value of the name attribute and is particularly
|
486
|
+
# useful for creating consistent directory structures and file naming
|
487
|
+
# conventions. This value is used internally by GemHadar to create the root
|
488
|
+
# directory for the gem and generate a version.rb file in that location.
|
489
|
+
#
|
490
|
+
# @return [ String ] the path name derived from the gem's name
|
160
491
|
dsl_accessor :path_name do name end
|
161
492
|
|
493
|
+
# The path_module attribute accessor for configuring the Ruby module name.
|
494
|
+
#
|
495
|
+
# This method sets up a DSL accessor for the path_module attribute, which
|
496
|
+
# determines the camelized version of the gem's name to be used as the Ruby
|
497
|
+
# module or class name. It automatically converts the value of path_name
|
498
|
+
# into CamelCase format, ensuring consistency with Ruby naming conventions
|
499
|
+
# for module and class declarations.
|
500
|
+
#
|
501
|
+
# @return [ String ] the camelized module name derived from path_name
|
162
502
|
dsl_accessor :path_module do path_name.camelize end
|
163
503
|
|
504
|
+
# The version attribute accessor for configuring the gem's version.
|
505
|
+
#
|
506
|
+
# This method sets up a DSL accessor for the version attribute, which
|
507
|
+
# specifies the version number of the gem. It includes logic to determine the
|
508
|
+
# version from the VERSION file or an environment variable override, and will
|
509
|
+
# raise an ArgumentError if the version has not been set and cannot be
|
510
|
+
# determined.
|
511
|
+
#
|
512
|
+
# @return [ String ] the version of the gem
|
513
|
+
#
|
514
|
+
# @raise [ ArgumentError ] if the version attribute has not been set and
|
515
|
+
# cannot be read from the VERSION file or ENV override
|
164
516
|
dsl_accessor :version do
|
165
517
|
v = ENV['VERSION'].full? and next v
|
166
518
|
File.read('VERSION').chomp
|
@@ -168,23 +520,91 @@ class GemHadar
|
|
168
520
|
has_to_be_set :version
|
169
521
|
end
|
170
522
|
|
523
|
+
# The version_epilogue attribute accessor for configuring additional content
|
524
|
+
# to be appended to the version file.
|
525
|
+
#
|
526
|
+
# This method sets up a DSL accessor for the version_epilogue attribute,
|
527
|
+
# which specifies extra content to be included at the end of the generated
|
528
|
+
# version file. This can be useful for adding custom comments, license
|
529
|
+
# information, or other supplementary data to the version module or class.
|
530
|
+
#
|
531
|
+
# @return [ String, nil ] the epilogue content or nil if not set
|
171
532
|
dsl_accessor :version_epilogue
|
172
533
|
|
534
|
+
# The post_install_message attribute accessor for configuring a message to
|
535
|
+
# display after gem installation.
|
536
|
+
#
|
537
|
+
# This method sets up a DSL accessor for the post_install_message attribute,
|
538
|
+
# which specifies a message to be displayed to users after the gem is installed.
|
539
|
+
# This can be useful for providing additional information, usage instructions,
|
540
|
+
# or important warnings to users of the gem.
|
541
|
+
#
|
542
|
+
# @return [ String, nil ] the post-installation message or nil if not set
|
173
543
|
dsl_accessor :post_install_message
|
174
544
|
|
545
|
+
# The required_ruby_version attribute accessor for configuring the minimum
|
546
|
+
# Ruby version requirement.
|
547
|
+
#
|
548
|
+
# This method sets up a DSL accessor for the required_ruby_version attribute,
|
549
|
+
# which specifies the minimum version of Ruby that the gem requires to run.
|
550
|
+
# It allows defining the Ruby version constraint that will be included in the
|
551
|
+
# gem specification.
|
552
|
+
#
|
553
|
+
# @return [ String, nil ] the required Ruby version string or nil if not set
|
175
554
|
dsl_accessor :required_ruby_version
|
176
555
|
|
556
|
+
# A class that encapsulates Ruby Version Manager (RVM) configuration settings
|
557
|
+
# for a gem project.
|
558
|
+
#
|
559
|
+
# This class is responsible for managing RVM-specific configuration such as
|
560
|
+
# the Ruby version to use and the gemset name. It provides a structured way
|
561
|
+
# to define and access these settings within the context of a GemHadar
|
562
|
+
# configuration.
|
563
|
+
#
|
564
|
+
# @example Configuring RVM settings
|
565
|
+
# GemHadar do
|
566
|
+
# rvm do
|
567
|
+
# use '3.0.0'
|
568
|
+
# gemset 'my_gem_dev'
|
569
|
+
# end
|
570
|
+
# end
|
177
571
|
class RvmConfig
|
178
572
|
extend DSLKit::DSLAccessor
|
179
573
|
include DSLKit::BlockSelf
|
180
574
|
|
575
|
+
# The initialize method sets up the RvmConfig instance by evaluating the
|
576
|
+
# provided block in the context of the object.
|
577
|
+
#
|
578
|
+
# @param block [ Proc ] the block to be evaluated for configuring the RVM settings
|
579
|
+
#
|
580
|
+
# @return [ GemHadar::RvmConfig ] the initialized RvmConfig instance
|
181
581
|
def initialize(&block)
|
182
582
|
@outer_scope = block_self(&block)
|
183
583
|
instance_eval(&block)
|
184
584
|
end
|
185
585
|
|
586
|
+
# The use method retrieves or sets the Ruby version to be used with RVM.
|
587
|
+
#
|
588
|
+
# This method serves as an accessor for the Ruby version configuration
|
589
|
+
# within the RVM (Ruby Version Manager) settings. When called without
|
590
|
+
# arguments, it returns the configured Ruby version. When called with
|
591
|
+
# an argument, it sets the Ruby version to be used.
|
592
|
+
#
|
593
|
+
# @return [ String ] the Ruby version string configured for RVM use
|
594
|
+
# @see GemHadar::RvmConfig
|
186
595
|
dsl_accessor :use do `rvm tools strings`.split(/\n/).full?(:last) || 'ruby' end
|
187
596
|
|
597
|
+
# The gemset method retrieves or sets the RVM gemset name for the project.
|
598
|
+
#
|
599
|
+
# This method serves as an accessor for the RVM (Ruby Version Manager)
|
600
|
+
# gemset configuration within the nested RvmConfig class. When called
|
601
|
+
# without arguments,
|
602
|
+
# it returns the configured gemset name, which defaults to the gem's name.
|
603
|
+
# When called with an argument, it sets the gemset name to be used with RVM.
|
604
|
+
#
|
605
|
+
# @return [ String ] the RVM gemset name configured for the project
|
606
|
+
# @see GemHadar::RvmConfig#use
|
607
|
+
# @see GemHadar::RvmConfig
|
188
608
|
dsl_accessor :gemset do @outer_scope.name end
|
189
609
|
end
|
190
610
|
|
@@ -209,6 +629,17 @@ class GemHadar
|
|
209
629
|
@rvm
|
210
630
|
end
|
211
631
|
|
632
|
+
# The default_task_dependencies method manages the list of dependencies for
|
633
|
+
# the default Rake task.
|
634
|
+
#
|
635
|
+
# This method sets up a DSL accessor for the default_task_dependencies
|
636
|
+
# attribute, which specifies the sequence of Rake tasks that must be executed
|
637
|
+
# when running the default task. These dependencies typically include
|
638
|
+
# generating the gem specification and running tests to ensure a consistent
|
639
|
+
# starting point for development workflows.
|
640
|
+
#
|
641
|
+
# @return [ Array<Symbol, String> ] an array of task names that are required
|
642
|
+
# as dependencies for the default task execution
|
212
643
|
dsl_accessor :default_task_dependencies, [ :gemspec, :test ]
|
213
644
|
|
214
645
|
# The default_task method defines the default Rake task for the gem project.
|
@@ -222,6 +653,17 @@ class GemHadar
|
|
222
653
|
task :default => default_task_dependencies
|
223
654
|
end
|
224
655
|
|
656
|
+
# The build_task_dependencies method manages the list of dependencies for the
|
657
|
+
# build task.
|
658
|
+
#
|
659
|
+
# This method sets up a DSL accessor for the build_task_dependencies
|
660
|
+
# attribute, which specifies the sequence of Rake tasks that must be executed
|
661
|
+
# when running the build task. These dependencies typically include cleaning
|
662
|
+
# previous builds, generating the gem specification, packaging the gem, and
|
663
|
+
# creating a version tag.
|
664
|
+
#
|
665
|
+
# @return [ Array<Symbol, String> ] an array of task names that are required
|
666
|
+
# as dependencies for the build task execution
|
225
667
|
dsl_accessor :build_task_dependencies, [ :clobber, :gemspec, :package, :'version:tag' ]
|
226
668
|
|
227
669
|
# The build_task method defines a Rake task that orchestrates the complete
|
@@ -926,6 +1368,16 @@ class GemHadar
|
|
926
1368
|
end
|
927
1369
|
end
|
928
1370
|
|
1371
|
+
# The push_task_dependencies method manages the list of dependencies for the push task.
|
1372
|
+
#
|
1373
|
+
# This method sets up a DSL accessor for the push_task_dependencies attribute,
|
1374
|
+
# which specifies the sequence of Rake tasks that must be executed when running
|
1375
|
+
# the push task. These dependencies typically include checks for modified files,
|
1376
|
+
# building the gem, pushing to remote repositories, and publishing to package
|
1377
|
+
# managers like RubyGems and GitHub.
|
1378
|
+
#
|
1379
|
+
# @return [ Array<Symbol, String> ] an array of task names that are required
|
1380
|
+
# as dependencies for the push task execution
|
929
1381
|
dsl_accessor :push_task_dependencies, %i[ modified build master:push version:push gem:push github:release ]
|
930
1382
|
|
931
1383
|
# The push_task method defines a Rake task that orchestrates the complete
|
@@ -1190,14 +1642,25 @@ class GemHadar
|
|
1190
1642
|
# content, opens it in an editor for user modification, and returns the
|
1191
1643
|
# updated content.
|
1192
1644
|
#
|
1193
|
-
#
|
1645
|
+
# This method first determines the editor to use from the EDITOR environment
|
1646
|
+
# variable or defaults to vi. If the editor cannot be found, it issues a
|
1647
|
+
# warning and returns nil. It then creates a temporary file, writes the
|
1648
|
+
# initial content to it, and opens the file in the editor. After the user
|
1649
|
+
# saves and closes the editor, it reads the modified content from the
|
1650
|
+
# temporary file. The temporary file is automatically cleaned up after use.
|
1651
|
+
#
|
1652
|
+
# @param content [ String ] the initial content to write to the temporary
|
1653
|
+
# file
|
1654
|
+
#
|
1655
|
+
# @return [ String, nil ] the content of the temporary file after editing, or
|
1656
|
+
# nil if the editor could not be found or failed
|
1194
1657
|
def edit_temp_file(content)
|
1195
1658
|
editor = ENV.fetch('EDITOR', `which vi`.chomp)
|
1196
1659
|
unless File.exist?(editor)
|
1197
1660
|
warn "Can't find EDITOR. => Returning."
|
1198
1661
|
return
|
1199
1662
|
end
|
1200
|
-
temp_file = Tempfile.new(
|
1663
|
+
temp_file = Tempfile.new(%w[ changelog .md ])
|
1201
1664
|
temp_file.write(content)
|
1202
1665
|
temp_file.close
|
1203
1666
|
|
@@ -1211,6 +1674,11 @@ class GemHadar
|
|
1211
1674
|
temp_file&.close&.unlink
|
1212
1675
|
end
|
1213
1676
|
|
1677
|
+
# The ollama_model_default method returns the default name of the Ollama AI
|
1678
|
+
# model to be used for generating responses when no custom model is
|
1679
|
+
# specified.
|
1680
|
+
#
|
1681
|
+
# @return [ String ] the default Ollama AI model name, which is 'llama3.1'
|
1214
1682
|
dsl_accessor :ollama_model_default, 'llama3.1'.freeze
|
1215
1683
|
|
1216
1684
|
# The ollama_model method retrieves the name of the Ollama AI model to be
|
@@ -1527,10 +1995,33 @@ class GemHadar
|
|
1527
1995
|
end
|
1528
1996
|
end
|
1529
1997
|
|
1998
|
+
# The GemHadar method serves as the primary entry point for configuring and
|
1999
|
+
# initializing a gem project using the GemHadar framework.
|
2000
|
+
#
|
2001
|
+
# This method creates a new instance of the GemHadar class, passes the provided
|
2002
|
+
# block to configure the gem settings, and then invokes the create_all_tasks
|
2003
|
+
# method to set up all the necessary Rake tasks for the project.
|
2004
|
+
#
|
2005
|
+
# @param block [ Proc ] a configuration block used to define gem properties and settings
|
2006
|
+
#
|
2007
|
+
# @return [ GemHadar ] the configured GemHadar instance after all tasks have been created
|
1530
2008
|
def GemHadar(&block)
|
1531
2009
|
GemHadar.new(&block).create_all_tasks
|
1532
2010
|
end
|
1533
2011
|
|
2012
|
+
# The template method processes an ERB template file and creates a Rake task
|
2013
|
+
# for its compilation.
|
2014
|
+
#
|
2015
|
+
# This method takes a template file path, removes its extension to determine
|
2016
|
+
# the output file name, and sets up a Rake file task that compiles the template
|
2017
|
+
# using the provided block configuration. It ensures the source file has an
|
2018
|
+
# extension and raises an error if not.
|
2019
|
+
#
|
2020
|
+
# @param pathname [ String ] the path to the template file to be processed
|
2021
|
+
#
|
2022
|
+
# @yield [ block ] the configuration block for the template compiler
|
2023
|
+
#
|
2024
|
+
# @return [ Pathname ] the Pathname object representing the destination file path
|
1534
2025
|
def template(pathname, &block)
|
1535
2026
|
template_src = Pathname.new(pathname)
|
1536
2027
|
template_dst = template_src.sub_ext('') # ignore ext, we just support erb anyway
|