gem_hadar 2.6.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 +81 -9
- 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
@@ -1223,10 +1223,10 @@ class GemHadar
|
|
1223
1223
|
# namespace:
|
1224
1224
|
#
|
1225
1225
|
# - It creates subtasks in the :version:push namespace for each configured
|
1226
|
-
#
|
1226
|
+
# Git remote, allowing individual pushes to specific remotes.
|
1227
1227
|
# - It also defines a top-level :version:push task that depends on all the
|
1228
|
-
#
|
1229
|
-
# tag to all remotes.
|
1228
|
+
# individual remote push tasks, enabling a single command to push the
|
1229
|
+
# version tag to all remotes.
|
1230
1230
|
#
|
1231
1231
|
# The tasks utilize the git_remotes method to determine which remotes are
|
1232
1232
|
# configured and generate appropriate push commands for each one.
|
@@ -1249,7 +1249,8 @@ class GemHadar
|
|
1249
1249
|
# The master_push_task method defines Rake tasks for pushing the master
|
1250
1250
|
# branch to configured Git remotes.
|
1251
1251
|
#
|
1252
|
-
# 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:
|
1253
1254
|
#
|
1254
1255
|
# - It creates subtasks in the :master:push namespace for each configured Git
|
1255
1256
|
# remote, allowing individual pushes to specific remotes.
|
@@ -1468,7 +1469,8 @@ class GemHadar
|
|
1468
1469
|
# The rvm_task method creates a .rvmrc file that configures RVM to use the
|
1469
1470
|
# specified Ruby version and gemset for the project.
|
1470
1471
|
#
|
1471
|
-
# 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:
|
1472
1474
|
# - Use the Ruby version specified by the rvm.use accessor
|
1473
1475
|
# - Create the gemset specified by the rvm.gemset accessor
|
1474
1476
|
# - Switch to using that gemset
|
@@ -1672,6 +1674,7 @@ class GemHadar
|
|
1672
1674
|
version_tag_task
|
1673
1675
|
push_task
|
1674
1676
|
release_task
|
1677
|
+
github_workflows_task
|
1675
1678
|
write_ignore_file
|
1676
1679
|
write_gemfile
|
1677
1680
|
if extensions.full?
|
@@ -2020,6 +2023,71 @@ class GemHadar
|
|
2020
2023
|
remotes_uris.find { |uri| uri.hostname == 'github.com' }
|
2021
2024
|
end
|
2022
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
|
2023
2091
|
end
|
2024
2092
|
|
2025
2093
|
# The GemHadar method serves as the primary entry point for configuring and
|
@@ -2044,14 +2112,18 @@ end
|
|
2044
2112
|
# using the provided block configuration. It ensures the source file has an
|
2045
2113
|
# extension and raises an error if not.
|
2046
2114
|
#
|
2047
|
-
# @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
|
2048
2117
|
#
|
2049
2118
|
# @yield [ block ] the configuration block for the template compiler
|
2050
2119
|
#
|
2051
2120
|
# @return [ Pathname ] the Pathname object representing the destination file path
|
2052
|
-
def template(
|
2053
|
-
template_src = Pathname.new(
|
2054
|
-
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
|
2055
2127
|
template_src == template_dst and raise ArgumentError,
|
2056
2128
|
"pathname #{pathname.inspect} needs to have a file extension"
|
2057
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
|