gem_hadar 2.5.0 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/static.yml +51 -0
- data/README.md +4 -0
- data/Rakefile +4 -0
- data/gem_hadar.gemspec +4 -4
- data/lib/gem_hadar/github.rb +30 -0
- data/lib/gem_hadar/github_workflows/static.yml.erb +51 -0
- data/lib/gem_hadar/template_compiler.rb +1 -1
- data/lib/gem_hadar/version.rb +1 -1
- data/lib/gem_hadar.rb +129 -28
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06ac4c24e96c6dd512c2134b60e0934f9e78e17e882d47a86b2e7645b56350f1
|
4
|
+
data.tar.gz: c2925c0239ce6e55f86f279514b5233bc0f1d634567fbe04768da6db578f9d29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 551be5a778cb8414180d6c97fba6b6d3616b7dba1d46a5921a053f435f14362bf326935627bf4191d4eca9d5439a0cf206ff00ecf69fcbf1218c37f2466ef91e
|
7
|
+
data.tar.gz: faacd697e4b04ec02a173269beaeefa9b3dfd5ee56f5ffeb96326e01c6c1d5595f4d73ae4e34ea261c4148656e20023af1c9f397331011dc615ded0189cb803c
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# Simple workflow for deploying static content to GitHub Pages
|
2
|
+
name: Deploy static content to Pages
|
3
|
+
|
4
|
+
on:
|
5
|
+
# Runs on pushes targeting the default branch
|
6
|
+
push:
|
7
|
+
branches: [ "master" ]
|
8
|
+
|
9
|
+
# Allows you to run this workflow manually from the Actions tab
|
10
|
+
workflow_dispatch:
|
11
|
+
|
12
|
+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
13
|
+
permissions:
|
14
|
+
contents: read
|
15
|
+
pages: write
|
16
|
+
id-token: write
|
17
|
+
|
18
|
+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
19
|
+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
20
|
+
concurrency:
|
21
|
+
group: "pages"
|
22
|
+
cancel-in-progress: false
|
23
|
+
|
24
|
+
jobs:
|
25
|
+
# Single deploy job since we're just deploying
|
26
|
+
deploy:
|
27
|
+
environment:
|
28
|
+
name: github-pages
|
29
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
30
|
+
runs-on: ubuntu-latest
|
31
|
+
steps:
|
32
|
+
- name: Checkout
|
33
|
+
uses: actions/checkout@v4
|
34
|
+
- name: Setup Pages
|
35
|
+
uses: actions/configure-pages@v5
|
36
|
+
- name: Setup Ruby
|
37
|
+
uses: ruby/setup-ruby@v1
|
38
|
+
with:
|
39
|
+
ruby-version: '3.4'
|
40
|
+
- name: Generate Documentation
|
41
|
+
run: |
|
42
|
+
gem install gem_hadar
|
43
|
+
bundle install
|
44
|
+
rake doc
|
45
|
+
- name: Upload artifact
|
46
|
+
uses: actions/upload-pages-artifact@v3
|
47
|
+
with:
|
48
|
+
path: 'doc'
|
49
|
+
- name: Deploy to GitHub Pages
|
50
|
+
id: deployment
|
51
|
+
uses: actions/deploy-pages@v4
|
data/README.md
CHANGED
@@ -28,6 +28,10 @@ using rake tasks. It is a comprehensive Ruby gem automation tool that provides:
|
|
28
28
|
- **Gemfile and .gitignore automation** - Automatic creation and management of
|
29
29
|
essential project files with 📦dependency management
|
30
30
|
|
31
|
+
## Documentation
|
32
|
+
|
33
|
+
Complete API documentation is available at: [GitHub.io](https://flori.github.io/gem_hadar/)
|
34
|
+
|
31
35
|
## Workflow Diagrams
|
32
36
|
|
33
37
|
### Gem Build Process
|
data/Rakefile
CHANGED
data/gem_hadar.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: gem_hadar 2.
|
2
|
+
# stub: gem_hadar 2.7.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "gem_hadar".freeze
|
6
|
-
s.version = "2.
|
6
|
+
s.version = "2.7.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]
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.email = "flori@ping.de".freeze
|
14
14
|
s.executables = ["gem_hadar".freeze]
|
15
15
|
s.extra_rdoc_files = ["README.md".freeze, "lib/gem_hadar.rb".freeze, "lib/gem_hadar/github.rb".freeze, "lib/gem_hadar/prompt_template.rb".freeze, "lib/gem_hadar/setup.rb".freeze, "lib/gem_hadar/simplecov.rb".freeze, "lib/gem_hadar/template_compiler.rb".freeze, "lib/gem_hadar/utils.rb".freeze, "lib/gem_hadar/version.rb".freeze, "lib/gem_hadar/warn.rb".freeze]
|
16
|
-
s.files = ["Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "bin/gem_hadar".freeze, "gem_hadar.gemspec".freeze, "lib/gem_hadar.rb".freeze, "lib/gem_hadar/github.rb".freeze, "lib/gem_hadar/prompt_template.rb".freeze, "lib/gem_hadar/setup.rb".freeze, "lib/gem_hadar/simplecov.rb".freeze, "lib/gem_hadar/template_compiler.rb".freeze, "lib/gem_hadar/utils.rb".freeze, "lib/gem_hadar/version.rb".freeze, "lib/gem_hadar/warn.rb".freeze, "spec/gem_hadar_spec.rb".freeze, "spec/spec_helper.rb".freeze]
|
16
|
+
s.files = [".github/workflows/static.yml".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "bin/gem_hadar".freeze, "gem_hadar.gemspec".freeze, "lib/gem_hadar.rb".freeze, "lib/gem_hadar/github.rb".freeze, "lib/gem_hadar/github_workflows/static.yml.erb".freeze, "lib/gem_hadar/prompt_template.rb".freeze, "lib/gem_hadar/setup.rb".freeze, "lib/gem_hadar/simplecov.rb".freeze, "lib/gem_hadar/template_compiler.rb".freeze, "lib/gem_hadar/utils.rb".freeze, "lib/gem_hadar/version.rb".freeze, "lib/gem_hadar/warn.rb".freeze, "spec/gem_hadar_spec.rb".freeze, "spec/spec_helper.rb".freeze]
|
17
17
|
s.homepage = "https://github.com/flori/gem_hadar".freeze
|
18
18
|
s.licenses = ["MIT".freeze]
|
19
19
|
s.rdoc_options = ["--title".freeze, "GemHadar - Library for the development of Ruby Gems".freeze, "--main".freeze, "README.md".freeze]
|
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
|
24
24
|
s.specification_version = 4
|
25
25
|
|
26
|
-
s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 2.
|
26
|
+
s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 2.7".freeze])
|
27
27
|
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.13".freeze])
|
28
28
|
s.add_runtime_dependency(%q<tins>.freeze, ["~> 1".freeze])
|
29
29
|
s.add_runtime_dependency(%q<term-ansicolor>.freeze, ["~> 1.0".freeze])
|
data/lib/gem_hadar/github.rb
CHANGED
@@ -30,6 +30,17 @@ class GemHadar::GitHub::ReleaseCreator
|
|
30
30
|
end
|
31
31
|
self.github_api_url = 'https://api.github.com'
|
32
32
|
|
33
|
+
# The initialize method sets up the ReleaseCreator instance with required
|
34
|
+
# GitHub API configuration.
|
35
|
+
#
|
36
|
+
# This method stores the owner, repository, and authentication token needed
|
37
|
+
# to interact with the GitHub Releases API. It also accepts an optional API
|
38
|
+
# version parameter to specify which version of the GitHub API to use.
|
39
|
+
#
|
40
|
+
# @param owner [ String ] the GitHub username or organization name
|
41
|
+
# @param repo [ String ] the repository name
|
42
|
+
# @param token [ String ] the personal access token for authentication
|
43
|
+
# @param api_version [ String ] the GitHub API version to use (defaults to '2022-11-28')
|
33
44
|
def initialize(owner:, repo:, token:, api_version: '2022-11-28')
|
34
45
|
@owner = owner
|
35
46
|
@repo = repo
|
@@ -37,6 +48,25 @@ class GemHadar::GitHub::ReleaseCreator
|
|
37
48
|
@api_version = api_version
|
38
49
|
end
|
39
50
|
|
51
|
+
# The perform method creates a new GitHub release using the GitHub API.
|
52
|
+
#
|
53
|
+
# This method sends a POST request to the GitHub Releases API to create a new
|
54
|
+
# release for the specified repository. It constructs the appropriate HTTP
|
55
|
+
# headers including authentication and content type, prepares the release
|
56
|
+
# data with the provided parameters, and handles the API response by parsing
|
57
|
+
# successful responses or raising an error for failed requests.
|
58
|
+
#
|
59
|
+
# @param tag_name [ String ] the name of the tag to associate with the release
|
60
|
+
# @param target_commitish [ String ] the commit SHA or branch name to use for the release
|
61
|
+
# @param body [ String ] the release notes or description content
|
62
|
+
# @param name [ String ] the name of the release (defaults to tag_name)
|
63
|
+
# @param draft [ Boolean ] whether to create a draft release (defaults to false)
|
64
|
+
# @param prerelease [ Boolean ] whether to mark the release as a pre-release (defaults to false)
|
65
|
+
#
|
66
|
+
# @return [ JSON::GenericObject ] the parsed response data from the GitHub API containing
|
67
|
+
# details about the created release
|
68
|
+
#
|
69
|
+
# @raise [ RuntimeError ] if the GitHub API request fails with a non-success status code
|
40
70
|
def perform(tag_name:, target_commitish:, body:, name: tag_name, draft: false, prerelease: false)
|
41
71
|
uri = URI("#{self.class.github_api_url}/repos/#@owner/#@repo/releases")
|
42
72
|
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# Simple workflow for deploying static content to GitHub Pages
|
2
|
+
name: Deploy static content to Pages
|
3
|
+
|
4
|
+
on:
|
5
|
+
# Runs on pushes targeting the default branch
|
6
|
+
push:
|
7
|
+
branches: <%= github_workflows_variables.fetch(:branches, '[ "master" ]') %>
|
8
|
+
|
9
|
+
# Allows you to run this workflow manually from the Actions tab
|
10
|
+
workflow_dispatch:
|
11
|
+
|
12
|
+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
13
|
+
permissions:
|
14
|
+
contents: read
|
15
|
+
pages: write
|
16
|
+
id-token: write
|
17
|
+
|
18
|
+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
19
|
+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
20
|
+
concurrency:
|
21
|
+
group: "pages"
|
22
|
+
cancel-in-progress: false
|
23
|
+
|
24
|
+
jobs:
|
25
|
+
# Single deploy job since we're just deploying
|
26
|
+
deploy:
|
27
|
+
environment:
|
28
|
+
name: github-pages
|
29
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
30
|
+
runs-on: ubuntu-latest
|
31
|
+
steps:
|
32
|
+
- name: Checkout
|
33
|
+
uses: actions/checkout@v4
|
34
|
+
- name: Setup Pages
|
35
|
+
uses: actions/configure-pages@v5
|
36
|
+
- name: Setup Ruby
|
37
|
+
uses: ruby/setup-ruby@v1
|
38
|
+
with:
|
39
|
+
ruby-version: '3.4'
|
40
|
+
- name: Generate Documentation
|
41
|
+
run: |
|
42
|
+
gem install gem_hadar
|
43
|
+
bundle install
|
44
|
+
rake doc
|
45
|
+
- name: Upload artifact
|
46
|
+
uses: actions/upload-pages-artifact@v3
|
47
|
+
with:
|
48
|
+
path: 'doc'
|
49
|
+
- name: Deploy to GitHub Pages
|
50
|
+
id: deployment
|
51
|
+
uses: actions/deploy-pages@v4
|
@@ -41,7 +41,7 @@ class GemHadar::TemplateCompiler
|
|
41
41
|
def compile(src, dst)
|
42
42
|
template = File.read(src)
|
43
43
|
File.open(dst, 'w') do |output|
|
44
|
-
erb = ERB.new(template,
|
44
|
+
erb = ERB.new(template, trim_mode: ?-)
|
45
45
|
erb.filename = src.to_s
|
46
46
|
output.write erb.result binding
|
47
47
|
end
|
data/lib/gem_hadar/version.rb
CHANGED
data/lib/gem_hadar.rb
CHANGED
@@ -140,11 +140,14 @@ class GemHadar
|
|
140
140
|
[ name, version ] * '-'
|
141
141
|
end
|
142
142
|
|
143
|
-
# The module_type attribute accessor for configuring the type of Ruby
|
143
|
+
# The module_type attribute accessor for configuring the type of Ruby
|
144
|
+
# construct to generate for version code.
|
144
145
|
#
|
145
|
-
# This method sets up a DSL accessor for the module_type attribute, which
|
146
|
-
#
|
147
|
-
#
|
146
|
+
# This method sets up a DSL accessor for the module_type attribute, which
|
147
|
+
# determines whether the generated code structure for the version module
|
148
|
+
# should be a :module or :class. This controls the type of Ruby construct
|
149
|
+
# created when generating code skeletons and version files. The value can be
|
150
|
+
# set to either:
|
148
151
|
#
|
149
152
|
# - :module (default) - Generates module-based structure
|
150
153
|
# - :class - Generates class-based structure
|
@@ -342,10 +345,10 @@ class GemHadar
|
|
342
345
|
|
343
346
|
# The test_dir attribute accessor for configuring the test directory.
|
344
347
|
#
|
345
|
-
# This method sets up a DSL accessor for the test_dir attribute, which
|
346
|
-
# the directory where test files are located. It provides a way to
|
347
|
-
# location of the test directory that will be used by various
|
348
|
-
# configurations within the gem project.
|
348
|
+
# This method sets up a DSL accessor for the test_dir attribute, which
|
349
|
+
# specifies the directory where test files are located. It provides a way to
|
350
|
+
# define the location of the test directory that will be used by various
|
351
|
+
# testing tasks and configurations within the gem project.
|
349
352
|
#
|
350
353
|
# @return [ String, nil ] the path to the test directory or nil if not set
|
351
354
|
dsl_accessor :test_dir
|
@@ -552,9 +555,9 @@ class GemHadar
|
|
552
555
|
# display after gem installation.
|
553
556
|
#
|
554
557
|
# This method sets up a DSL accessor for the post_install_message attribute,
|
555
|
-
# which specifies a message to be displayed to users after the gem is
|
556
|
-
# This can be useful for providing additional information, usage
|
557
|
-
# or important warnings to users of the gem.
|
558
|
+
# which specifies a message to be displayed to users after the gem is
|
559
|
+
# installed. This can be useful for providing additional information, usage
|
560
|
+
# instructions, or important warnings to users of the gem.
|
558
561
|
#
|
559
562
|
# @return [ String, nil ] the post-installation message or nil if not set
|
560
563
|
dsl_accessor :post_install_message
|
@@ -776,7 +779,13 @@ class GemHadar
|
|
776
779
|
if args.empty?
|
777
780
|
package_ignore_files
|
778
781
|
else
|
779
|
-
args.each
|
782
|
+
args.each do |arg|
|
783
|
+
if File.directory?(arg)
|
784
|
+
package_ignore_files.merge FileList['%s/**/*' % arg]
|
785
|
+
else
|
786
|
+
package_ignore_files << arg
|
787
|
+
end
|
788
|
+
end
|
780
789
|
end
|
781
790
|
end
|
782
791
|
|
@@ -1214,10 +1223,10 @@ class GemHadar
|
|
1214
1223
|
# namespace:
|
1215
1224
|
#
|
1216
1225
|
# - It creates subtasks in the :version:push namespace for each configured
|
1217
|
-
#
|
1226
|
+
# Git remote, allowing individual pushes to specific remotes.
|
1218
1227
|
# - It also defines a top-level :version:push task that depends on all the
|
1219
|
-
#
|
1220
|
-
# tag to all remotes.
|
1228
|
+
# individual remote push tasks, enabling a single command to push the
|
1229
|
+
# version tag to all remotes.
|
1221
1230
|
#
|
1222
1231
|
# The tasks utilize the git_remotes method to determine which remotes are
|
1223
1232
|
# configured and generate appropriate push commands for each one.
|
@@ -1240,13 +1249,14 @@ class GemHadar
|
|
1240
1249
|
# The master_push_task method defines Rake tasks for pushing the master
|
1241
1250
|
# branch to configured Git remotes.
|
1242
1251
|
#
|
1243
|
-
# This method sets up a hierarchical task structure under the :master
|
1252
|
+
# This method sets up a hierarchical task structure under the :master
|
1253
|
+
# namespace:
|
1244
1254
|
#
|
1245
1255
|
# - It creates subtasks in the :master:push namespace for each configured Git
|
1246
1256
|
# remote, allowing individual pushes to specific remotes.
|
1247
|
-
# - It also defines a top-level :master:push task that depends on all the
|
1248
|
-
# remote push tasks, enabling a single command to push the master
|
1249
|
-
# all remotes.
|
1257
|
+
# - It also defines a top-level :master:push task that depends on all the
|
1258
|
+
# individual remote push tasks, enabling a single command to push the master
|
1259
|
+
# branch to all remotes.
|
1250
1260
|
#
|
1251
1261
|
# The tasks utilize the git_remotes method to determine which remotes are
|
1252
1262
|
# configured and generate appropriate push commands for each one.
|
@@ -1459,7 +1469,8 @@ class GemHadar
|
|
1459
1469
|
# The rvm_task method creates a .rvmrc file that configures RVM to use the
|
1460
1470
|
# specified Ruby version and gemset for the project.
|
1461
1471
|
#
|
1462
|
-
# This task generates a .rvmrc file in the project root directory with
|
1472
|
+
# This task generates a .rvmrc file in the project root directory with
|
1473
|
+
# commands to:
|
1463
1474
|
# - Use the Ruby version specified by the rvm.use accessor
|
1464
1475
|
# - Create the gemset specified by the rvm.gemset accessor
|
1465
1476
|
# - Switch to using that gemset
|
@@ -1479,9 +1490,20 @@ class GemHadar
|
|
1479
1490
|
end
|
1480
1491
|
end
|
1481
1492
|
|
1493
|
+
# The yard_doc_task method configures and sets up a YARD documentation
|
1494
|
+
# generation task.
|
1495
|
+
#
|
1496
|
+
# This method initializes a YARD::Rake::YardocTask that processes Ruby source
|
1497
|
+
# files and generates comprehensive documentation including private and
|
1498
|
+
# protected methods. It configures the output directory, handles README
|
1499
|
+
# files, includes additional documentation files, and sets up a pre-execution
|
1500
|
+
# cleanup routine.
|
1501
|
+
#
|
1502
|
+
# @return [ void ] This method does not return a value but defines a Rake task
|
1503
|
+
# named :yard_doc with specific configuration options.
|
1482
1504
|
def yard_doc_task
|
1483
1505
|
YARD::Rake::YardocTask.new(:yard_doc) do |t|
|
1484
|
-
t.files = doc_code_files.
|
1506
|
+
t.files = doc_code_files.grep(%r(\.rb\z))
|
1485
1507
|
|
1486
1508
|
output_dir = yard_dir
|
1487
1509
|
t.options = [ "--output-dir=#{output_dir}" ]
|
@@ -1512,8 +1534,8 @@ class GemHadar
|
|
1512
1534
|
#
|
1513
1535
|
# It creates multiple subtasks under the :yard namespace, including tasks for
|
1514
1536
|
# creating private documentation, viewing the generated documentation,
|
1515
|
-
# cleaning up documentation files, and listing undocumented elements.
|
1516
|
-
#
|
1537
|
+
# cleaning up documentation files, and listing undocumented elements. If YARD
|
1538
|
+
# is not available, the method returns early without defining any tasks.
|
1517
1539
|
def yard_task
|
1518
1540
|
defined? YARD or return
|
1519
1541
|
yard_doc_task
|
@@ -1551,6 +1573,14 @@ class GemHadar
|
|
1551
1573
|
task :yard => %i[ yard:private yard:view ]
|
1552
1574
|
end
|
1553
1575
|
|
1576
|
+
# The config_task method creates a Rake task that displays the current
|
1577
|
+
# GemHadar configuration.
|
1578
|
+
#
|
1579
|
+
# This method sets up a :gem_hadar:config task under the Rake namespace that
|
1580
|
+
# outputs detailed information about the gem's configuration, including
|
1581
|
+
# environment variables, API keys, Ollama settings, XDG configuration
|
1582
|
+
# directory, general gem properties, build and development parameters, Git
|
1583
|
+
# remotes, and AI prompt defaults.
|
1554
1584
|
def config_task
|
1555
1585
|
namespace :gem_hadar do
|
1556
1586
|
desc "Display current gem_hadar configuration"
|
@@ -1644,6 +1674,7 @@ class GemHadar
|
|
1644
1674
|
version_tag_task
|
1645
1675
|
push_task
|
1646
1676
|
release_task
|
1677
|
+
github_workflows_task
|
1647
1678
|
write_ignore_file
|
1648
1679
|
write_gemfile
|
1649
1680
|
if extensions.full?
|
@@ -1720,7 +1751,8 @@ class GemHadar
|
|
1720
1751
|
# set. The method then constructs the full base URL and initializes an
|
1721
1752
|
# Ollama::Client with appropriate timeouts for read and connect operations.
|
1722
1753
|
#
|
1723
|
-
# @return [Ollama::Client, nil] An initialized Ollama::Client instance if a
|
1754
|
+
# @return [Ollama::Client, nil] An initialized Ollama::Client instance if a
|
1755
|
+
# valid base URL is present, otherwise nil.
|
1724
1756
|
def ollama_client
|
1725
1757
|
base_url = ENV['OLLAMA_URL']
|
1726
1758
|
if base_url.blank?
|
@@ -1991,6 +2023,71 @@ class GemHadar
|
|
1991
2023
|
remotes_uris.find { |uri| uri.hostname == 'github.com' }
|
1992
2024
|
end
|
1993
2025
|
end
|
2026
|
+
|
2027
|
+
# The github_workflows attribute accessor for configuring GitHub Actions
|
2028
|
+
# workflows.
|
2029
|
+
#
|
2030
|
+
# This method sets up a DSL accessor for the github_workflows attribute,
|
2031
|
+
# which specifies the configuration for generating GitHub Actions workflow
|
2032
|
+
# files from ERB templates. It provides a way to define which workflows to
|
2033
|
+
# generate and the variables to use when rendering the templates.
|
2034
|
+
#
|
2035
|
+
# @return [ Hash ] a hash mapping workflow names to their configuration
|
2036
|
+
# variables
|
2037
|
+
dsl_accessor :github_workflows do
|
2038
|
+
{}
|
2039
|
+
end
|
2040
|
+
|
2041
|
+
# The github_workflows_variables method retrieves the cached variables used
|
2042
|
+
# for GitHub Actions workflow template compilation.
|
2043
|
+
#
|
2044
|
+
# This method returns the stored hash of variables that were previously set
|
2045
|
+
# during the configuration of GitHub workflows. If no variables have been
|
2046
|
+
# set, it returns an empty hash as a default value.
|
2047
|
+
#
|
2048
|
+
# @return [ Hash ] the hash of variables used for GitHub workflow template
|
2049
|
+
# rendering or an empty hash if none are set
|
2050
|
+
def github_workflows_variables
|
2051
|
+
@github_workflows_variables || {}
|
2052
|
+
end
|
2053
|
+
|
2054
|
+
# The github_workflows_task method sets up Rake tasks for generating GitHub
|
2055
|
+
# Actions workflow files from ERB templates.
|
2056
|
+
#
|
2057
|
+
# This method configures a hierarchical task structure under the :github namespace that:
|
2058
|
+
# - Compiles configured workflow templates from ERB files into actual workflow YAML files
|
2059
|
+
# - Creates a :workflows task that depends on all compiled template files
|
2060
|
+
# - Sets up a :workflows:clean task to remove generated workflow files
|
2061
|
+
# - Uses the github_workflows configuration to determine which workflows to generate
|
2062
|
+
# - Applies template variables to customize the generated workflows
|
2063
|
+
def github_workflows_task
|
2064
|
+
namespace :github do
|
2065
|
+
templates = []
|
2066
|
+
src_dir = Pathname.new(__dir__).join('gem_hadar', 'github_workflows')
|
2067
|
+
dst_dir = Pathname.pwd.join('.github', 'workflows')
|
2068
|
+
github_workflows.each do |workflow, variables|
|
2069
|
+
@github_workflows_variables = variables
|
2070
|
+
src = src_dir.join(workflow + '.erb')
|
2071
|
+
puts "Compiling #{src.to_s.inspect} to #{dst_dir.to_s.inspect} now."
|
2072
|
+
unless src.exist?
|
2073
|
+
warn "Workflow template #{src.to_s.inspect} doesn't exist! => Skipping."
|
2074
|
+
end
|
2075
|
+
mkdir_p dst_dir
|
2076
|
+
dst = dst_dir.join(workflow)
|
2077
|
+
templates << (template(src, dst) {}).to_s
|
2078
|
+
end
|
2079
|
+
desc "Create all configured github workflow tasks"
|
2080
|
+
task :workflows => templates
|
2081
|
+
namespace :workflows do
|
2082
|
+
desc "Delete all created github workflows"
|
2083
|
+
task :clean do
|
2084
|
+
github_workflows.each_key do |workflow|
|
2085
|
+
rm_f dst_dir.join(workflow), verbose: true
|
2086
|
+
end
|
2087
|
+
end
|
2088
|
+
end
|
2089
|
+
end
|
2090
|
+
end
|
1994
2091
|
end
|
1995
2092
|
|
1996
2093
|
# The GemHadar method serves as the primary entry point for configuring and
|
@@ -2015,14 +2112,18 @@ end
|
|
2015
2112
|
# using the provided block configuration. It ensures the source file has an
|
2016
2113
|
# extension and raises an error if not.
|
2017
2114
|
#
|
2018
|
-
# @param
|
2115
|
+
# @param src [ String ] the path to the template file to be processed
|
2116
|
+
# @param dst [ String ] the path to file that will be the product
|
2019
2117
|
#
|
2020
2118
|
# @yield [ block ] the configuration block for the template compiler
|
2021
2119
|
#
|
2022
2120
|
# @return [ Pathname ] the Pathname object representing the destination file path
|
2023
|
-
def template(
|
2024
|
-
template_src = Pathname.new(
|
2025
|
-
template_dst =
|
2121
|
+
def template(src, dst = nil, &block)
|
2122
|
+
template_src = Pathname.new(src)
|
2123
|
+
template_dst = dst ? Pathname.new(dst) : template_src
|
2124
|
+
if template_dst.extname == '.erb'
|
2125
|
+
template_dst = template_dst.sub_ext('erb')
|
2126
|
+
end
|
2026
2127
|
template_src == template_dst and raise ArgumentError,
|
2027
2128
|
"pathname #{pathname.inspect} needs to have a file extension"
|
2028
2129
|
file template_dst.to_s => template_src.to_s do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem_hadar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
@@ -15,14 +15,14 @@ dependencies:
|
|
15
15
|
requirements:
|
16
16
|
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: '2.
|
18
|
+
version: '2.7'
|
19
19
|
type: :development
|
20
20
|
prerelease: false
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
22
22
|
requirements:
|
23
23
|
- - "~>"
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version: '2.
|
25
|
+
version: '2.7'
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rspec
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,6 +139,7 @@ extra_rdoc_files:
|
|
139
139
|
- lib/gem_hadar/version.rb
|
140
140
|
- lib/gem_hadar/warn.rb
|
141
141
|
files:
|
142
|
+
- ".github/workflows/static.yml"
|
142
143
|
- Gemfile
|
143
144
|
- LICENSE
|
144
145
|
- README.md
|
@@ -147,6 +148,7 @@ files:
|
|
147
148
|
- gem_hadar.gemspec
|
148
149
|
- lib/gem_hadar.rb
|
149
150
|
- lib/gem_hadar/github.rb
|
151
|
+
- lib/gem_hadar/github_workflows/static.yml.erb
|
150
152
|
- lib/gem_hadar/prompt_template.rb
|
151
153
|
- lib/gem_hadar/setup.rb
|
152
154
|
- lib/gem_hadar/simplecov.rb
|