gem_hadar 2.10.0 → 2.11.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/.all_images.yml +1 -1
- data/Rakefile +2 -1
- data/gem_hadar.gemspec +6 -5
- data/lib/gem_hadar/changelog_generator.rb +292 -0
- data/lib/gem_hadar/github.rb +1 -2
- data/lib/gem_hadar/ollama_support.rb +72 -0
- data/lib/gem_hadar/prompt_template.rb +46 -0
- data/lib/gem_hadar/rvm_config.rb +0 -3
- data/lib/gem_hadar/utils.rb +81 -41
- data/lib/gem_hadar/version.rb +1 -1
- data/lib/gem_hadar/version_spec.rb +144 -0
- data/lib/gem_hadar/warn.rb +0 -2
- data/lib/gem_hadar.rb +183 -120
- metadata +23 -3
data/lib/gem_hadar.rb
CHANGED
|
@@ -13,7 +13,6 @@ require 'rake/clean'
|
|
|
13
13
|
require 'rake/testtask'
|
|
14
14
|
require 'set'
|
|
15
15
|
require 'pathname'
|
|
16
|
-
require 'ollama'
|
|
17
16
|
require 'term/ansicolor'
|
|
18
17
|
require_maybe 'yard'
|
|
19
18
|
require_maybe 'simplecov'
|
|
@@ -21,8 +20,6 @@ require_maybe 'rubygems/package_task'
|
|
|
21
20
|
require_maybe 'rcov/rcovtask'
|
|
22
21
|
require_maybe 'rspec/core/rake_task'
|
|
23
22
|
|
|
24
|
-
# A brief description of the GemHadar class.
|
|
25
|
-
#
|
|
26
23
|
# The GemHadar class serves as the primary configuration and task management
|
|
27
24
|
# framework for Ruby gem projects. It provides a DSL for defining gem metadata,
|
|
28
25
|
# dependencies, and Rake tasks, while also offering integration with various
|
|
@@ -61,8 +58,11 @@ require 'gem_hadar/utils'
|
|
|
61
58
|
require 'gem_hadar/warn'
|
|
62
59
|
require 'gem_hadar/setup'
|
|
63
60
|
require 'gem_hadar/template_compiler'
|
|
61
|
+
require 'gem_hadar/ollama_support'
|
|
64
62
|
require 'gem_hadar/github'
|
|
63
|
+
require 'gem_hadar/version_spec'
|
|
65
64
|
require 'gem_hadar/prompt_template'
|
|
65
|
+
require 'gem_hadar/changelog_generator'
|
|
66
66
|
require 'gem_hadar/rvm_config'
|
|
67
67
|
|
|
68
68
|
class GemHadar
|
|
@@ -70,6 +70,7 @@ class GemHadar
|
|
|
70
70
|
include GemHadar::Utils
|
|
71
71
|
include GemHadar::PromptTemplate
|
|
72
72
|
include GemHadar::Warn
|
|
73
|
+
include GemHadar::OllamaSupport
|
|
73
74
|
|
|
74
75
|
if defined?(::RbConfig)
|
|
75
76
|
include ::RbConfig
|
|
@@ -80,12 +81,16 @@ class GemHadar
|
|
|
80
81
|
extend DSLKit::DSLAccessor
|
|
81
82
|
include Tins::SecureWrite
|
|
82
83
|
|
|
83
|
-
# The initialize method sets up
|
|
84
|
-
#
|
|
84
|
+
# The initialize method sets up a new GemHadar instance and configures it
|
|
85
|
+
# using the provided block.
|
|
85
86
|
#
|
|
86
|
-
#
|
|
87
|
+
# This method creates a new instance of the GemHadar class, initializes
|
|
88
|
+
# internal arrays for dependencies and development dependencies, and then
|
|
89
|
+
# evaluates the provided block in the context of the new instance to
|
|
90
|
+
# configure the gem settings.
|
|
87
91
|
#
|
|
88
|
-
# @
|
|
92
|
+
# @yield [gem_hadar] yields the GemHadar instance to the configuration block
|
|
93
|
+
# @yieldparam gem_hadar [GemHadar] the GemHadar instance being configured
|
|
89
94
|
def initialize(&block)
|
|
90
95
|
@dependencies = []
|
|
91
96
|
@development_dependencies = []
|
|
@@ -1070,8 +1075,8 @@ class GemHadar
|
|
|
1070
1075
|
desc 'Bump version with AI suggestion'
|
|
1071
1076
|
task :bump do
|
|
1072
1077
|
log_diff = version_log_diff(from_version: nil, to_version: 'HEAD')
|
|
1073
|
-
system = xdg_config('version_bump_system_prompt.txt', default_version_bump_system_prompt)
|
|
1074
|
-
prompt = xdg_config('version_bump_prompt.txt', default_version_bump_prompt) % { version:, log_diff: }
|
|
1078
|
+
system = xdg_config('gem_hadar', 'version_bump_system_prompt.txt', default_version_bump_system_prompt)
|
|
1079
|
+
prompt = xdg_config('gem_hadar', 'version_bump_prompt.txt', default_version_bump_prompt) % { version:, log_diff: }
|
|
1075
1080
|
response = ollama_generate(system:, prompt:)
|
|
1076
1081
|
puts response
|
|
1077
1082
|
default = nil
|
|
@@ -1287,8 +1292,8 @@ class GemHadar
|
|
|
1287
1292
|
# @return [ String ] the generated changelog content for the release body
|
|
1288
1293
|
def create_git_release_body
|
|
1289
1294
|
log_diff = version_log_diff(to_version: version)
|
|
1290
|
-
system = xdg_config('release_system_prompt.txt', default_git_release_system_prompt)
|
|
1291
|
-
prompt = xdg_config('release_prompt.txt', default_git_release_prompt) % { name:, version:, log_diff: }
|
|
1295
|
+
system = xdg_config('gem_hadar', 'release_system_prompt.txt', default_git_release_system_prompt)
|
|
1296
|
+
prompt = xdg_config('gem_hadar', 'release_prompt.txt', default_git_release_prompt) % { name:, version:, log_diff: }
|
|
1292
1297
|
ollama_generate(system:, prompt:)
|
|
1293
1298
|
end
|
|
1294
1299
|
|
|
@@ -1442,9 +1447,6 @@ class GemHadar
|
|
|
1442
1447
|
# protected methods. It configures the output directory, handles README
|
|
1443
1448
|
# files, includes additional documentation files, and sets up a pre-execution
|
|
1444
1449
|
# cleanup routine.
|
|
1445
|
-
#
|
|
1446
|
-
# @return [ void ] This method does not return a value but defines a Rake task
|
|
1447
|
-
# named :yard_doc with specific configuration options.
|
|
1448
1450
|
def yard_doc_task
|
|
1449
1451
|
YARD::Rake::YardocTask.new(:yard_doc) do |t|
|
|
1450
1452
|
t.files = doc_code_files.grep(%r(\.rb\z))
|
|
@@ -1548,7 +1550,7 @@ class GemHadar
|
|
|
1548
1550
|
# Ollama
|
|
1549
1551
|
puts "Ollama Model: #{ollama_model} (default is #{ollama_model_default})"
|
|
1550
1552
|
|
|
1551
|
-
if url =
|
|
1553
|
+
if url = (ollama.base_url rescue nil)&.to_s
|
|
1552
1554
|
puts "Ollama Base URL: #{url.inspect}"
|
|
1553
1555
|
else
|
|
1554
1556
|
puts "Ollama Base URL: Not set"
|
|
@@ -1560,8 +1562,8 @@ class GemHadar
|
|
|
1560
1562
|
puts "Ollama Model Options: Not set (using defaults)"
|
|
1561
1563
|
end
|
|
1562
1564
|
|
|
1563
|
-
# XDG config
|
|
1564
|
-
puts "XDG config
|
|
1565
|
+
# XDG config app dir
|
|
1566
|
+
puts "XDG config app dir: #{xdg_config_dir('gem_hadar').to_s.inspect}"
|
|
1565
1567
|
|
|
1566
1568
|
# General
|
|
1567
1569
|
puts "Gem Name: #{name}"
|
|
@@ -1583,14 +1585,116 @@ class GemHadar
|
|
|
1583
1585
|
arrow = ?⤵
|
|
1584
1586
|
puts bold{"version_bump_system_prompt.txt"} + "#{arrow}\n" + italic{default_version_bump_system_prompt}
|
|
1585
1587
|
puts bold{"version_bump_prompt.txt"} + "#{arrow}\n#{default_version_bump_prompt}"
|
|
1586
|
-
puts bold{"
|
|
1587
|
-
puts bold{"
|
|
1588
|
+
puts bold{"git_release_system_prompt.txt"} + "#{arrow}\n" + italic{default_git_release_system_prompt}
|
|
1589
|
+
puts bold{"git_release_prompt.txt"} + "#{arrow}\n" + italic{default_git_release_prompt}
|
|
1590
|
+
puts bold{"changelog_system_prompt.txt"} + "#{arrow}\n" + italic{default_changelog_system_prompt}
|
|
1591
|
+
puts bold{"changelog_prompt.txt"} + "#{arrow}\n" + italic{default_changelog_prompt}
|
|
1588
1592
|
|
|
1589
1593
|
puts "=== End Configuration ==="
|
|
1590
1594
|
end
|
|
1591
1595
|
end
|
|
1592
1596
|
end
|
|
1593
1597
|
|
|
1598
|
+
# The changes_task method defines namespaced Rake tasks for generating changelogs.
|
|
1599
|
+
#
|
|
1600
|
+
# This method sets up a hierarchical task structure under the :changes namespace that:
|
|
1601
|
+
# - :changes - Show help for all changes tasks
|
|
1602
|
+
# - :changes:pending - Show changes since last version tag
|
|
1603
|
+
# - :changes:current - Show changes between two latest version tags
|
|
1604
|
+
# - :changes:range - Show changes for a specific Git range
|
|
1605
|
+
# - :changes:full - Generate complete changelog from first tag
|
|
1606
|
+
# - :changes:add - Append to existing changelog file
|
|
1607
|
+
def changes_task
|
|
1608
|
+
namespace :changes do
|
|
1609
|
+
desc 'Show changes since last version tag'
|
|
1610
|
+
task :pending do
|
|
1611
|
+
unless version_tag_list.any?
|
|
1612
|
+
raise 'Need at least one version tag to work'
|
|
1613
|
+
end
|
|
1614
|
+
last_version = version_tag_list.last
|
|
1615
|
+
if last_version
|
|
1616
|
+
puts GemHadar::ChangelogGenerator.new(self).generate(last_version, 'HEAD')
|
|
1617
|
+
else
|
|
1618
|
+
raise 'Need at least one version tag to work'
|
|
1619
|
+
end
|
|
1620
|
+
end
|
|
1621
|
+
|
|
1622
|
+
desc 'Show changes between two latest version tags'
|
|
1623
|
+
task :current do
|
|
1624
|
+
unless version_tag_list.length >= 2
|
|
1625
|
+
raise 'Need at least two version tags to work'
|
|
1626
|
+
end
|
|
1627
|
+
|
|
1628
|
+
version1, version2 = version_tag_list.last(2)
|
|
1629
|
+
if version1 && version2
|
|
1630
|
+
puts GemHadar::ChangelogGenerator.new(self).generate(version1, version2)
|
|
1631
|
+
else
|
|
1632
|
+
raise 'Need at least two version tags to work'
|
|
1633
|
+
end
|
|
1634
|
+
end
|
|
1635
|
+
|
|
1636
|
+
desc 'Show changes for a specific Git range (e.g., v1.0.0..v1.2.0)'
|
|
1637
|
+
task :range do
|
|
1638
|
+
if ARGV.size == 2 and range = ARGV.pop and range =~ /\A(.+)\.\.(.+)\z/
|
|
1639
|
+
range_from, range_to = $1, $2
|
|
1640
|
+
|
|
1641
|
+
from_spec = GemHadar::VersionSpec[range_from]
|
|
1642
|
+
to_spec = GemHadar::VersionSpec[range_to]
|
|
1643
|
+
|
|
1644
|
+
unless from_spec.version? && to_spec.version?
|
|
1645
|
+
raise "Invalid version format: #{range_from} or #{range_to}"
|
|
1646
|
+
end
|
|
1647
|
+
|
|
1648
|
+
GemHadar::ChangelogGenerator.new(self).
|
|
1649
|
+
generate_range(STDOUT, from_spec, to_spec)
|
|
1650
|
+
exit
|
|
1651
|
+
else
|
|
1652
|
+
raise "Need range of the form v1.2.3..v1.2.4"
|
|
1653
|
+
end
|
|
1654
|
+
end
|
|
1655
|
+
|
|
1656
|
+
desc 'Generate complete changelog from first tag and output to file'
|
|
1657
|
+
task :full do
|
|
1658
|
+
if ARGV.size == 1
|
|
1659
|
+
GemHadar::ChangelogGenerator.new(self).generate_full(STDOUT)
|
|
1660
|
+
elsif ARGV.size == 2
|
|
1661
|
+
File.open(ARGV[1], ?w) do |file|
|
|
1662
|
+
GemHadar::ChangelogGenerator.new(self).generate_full(file)
|
|
1663
|
+
end
|
|
1664
|
+
else
|
|
1665
|
+
raise "Need a filename to write to"
|
|
1666
|
+
end
|
|
1667
|
+
end
|
|
1668
|
+
|
|
1669
|
+
desc 'Append new entries to existing changelog file'
|
|
1670
|
+
task :add do
|
|
1671
|
+
filename = ARGV[1] or raise 'Need file to add to'
|
|
1672
|
+
GemHadar::ChangelogGenerator.new(self).add_to_file(filename)
|
|
1673
|
+
end
|
|
1674
|
+
end
|
|
1675
|
+
|
|
1676
|
+
# Main changes task that shows help when called directly
|
|
1677
|
+
desc 'Generate changelogs using Git history and AI'
|
|
1678
|
+
task :changes do
|
|
1679
|
+
puts <<~EOT
|
|
1680
|
+
Changes Tasks:
|
|
1681
|
+
rake changes:pending Show changes since last version tag
|
|
1682
|
+
rake changes:current Show changes between two latest version tags
|
|
1683
|
+
rake changes:range <range> Show changes for a specific Git range (e.g., v1.0.0..v1.2.0)
|
|
1684
|
+
rake changes:full [file] Generate complete changelog from first tag
|
|
1685
|
+
rake changes:add <file> Append new entries to existing changelog file
|
|
1686
|
+
|
|
1687
|
+
Examples:
|
|
1688
|
+
rake changes:pending
|
|
1689
|
+
rake changes:current
|
|
1690
|
+
rake changes:range v1.0.0..v1.2.0
|
|
1691
|
+
rake changes:full
|
|
1692
|
+
rake changes:full CHANGES.md
|
|
1693
|
+
rake changes:add CHANGES.md
|
|
1694
|
+
EOT
|
|
1695
|
+
end
|
|
1696
|
+
end
|
|
1697
|
+
|
|
1594
1698
|
# The create_all_tasks method sets up and registers all the Rake tasks for
|
|
1595
1699
|
# the gem project.
|
|
1596
1700
|
#
|
|
@@ -1598,6 +1702,7 @@ class GemHadar
|
|
|
1598
1702
|
def create_all_tasks
|
|
1599
1703
|
default_task
|
|
1600
1704
|
config_task
|
|
1705
|
+
changes_task
|
|
1601
1706
|
build_task
|
|
1602
1707
|
rvm_task
|
|
1603
1708
|
version_task
|
|
@@ -1673,56 +1778,6 @@ class GemHadar
|
|
|
1673
1778
|
# @return [ String ] the default Ollama AI model name, which is 'llama3.1'
|
|
1674
1779
|
dsl_accessor :ollama_model_default, 'llama3.1'.freeze
|
|
1675
1780
|
|
|
1676
|
-
# The ollama_model method retrieves the name of the Ollama AI model to be
|
|
1677
|
-
# used for generating responses.
|
|
1678
|
-
#
|
|
1679
|
-
# It first checks the OLLAMA_MODEL environment variable for a custom model
|
|
1680
|
-
# specification. If the environment variable is not set, it falls back to
|
|
1681
|
-
# using the default model name, which is determined by the
|
|
1682
|
-
# ollama_model_default dsl method.
|
|
1683
|
-
#
|
|
1684
|
-
# @return [ String ] the name of the Ollama AI model to be used
|
|
1685
|
-
def ollama_model
|
|
1686
|
-
ENV.fetch('OLLAMA_MODEL', ollama_model_default)
|
|
1687
|
-
end
|
|
1688
|
-
|
|
1689
|
-
# The ollama_client method creates and returns an Ollama::Client instance
|
|
1690
|
-
# configured with a base URL derived from environment variables.
|
|
1691
|
-
#
|
|
1692
|
-
# It first checks for the OLLAMA_URL environment variable to determine the
|
|
1693
|
-
# base URL. If that is not set, it falls back to using the OLLAMA_HOST
|
|
1694
|
-
# environment variable, defaulting to 'localhost:11434' if that is also not
|
|
1695
|
-
# set. The method then constructs the full base URL and initializes an
|
|
1696
|
-
# Ollama::Client with appropriate timeouts for read and connect operations.
|
|
1697
|
-
#
|
|
1698
|
-
# @return [Ollama::Client, nil] An initialized Ollama::Client instance if a
|
|
1699
|
-
# valid base URL is present, otherwise nil.
|
|
1700
|
-
def ollama_client
|
|
1701
|
-
base_url = ENV['OLLAMA_URL']
|
|
1702
|
-
if base_url.blank?
|
|
1703
|
-
host = ENV.fetch('OLLAMA_HOST', 'localhost:11434')
|
|
1704
|
-
base_url = 'http://%s' % host
|
|
1705
|
-
end
|
|
1706
|
-
base_url.present? or return
|
|
1707
|
-
Ollama::Client.new(base_url:, read_timeout: 600, connect_timeout: 60)
|
|
1708
|
-
end
|
|
1709
|
-
|
|
1710
|
-
# Generates a response from an AI model using the Ollama::Client.
|
|
1711
|
-
#
|
|
1712
|
-
# @param [String] system The system prompt for the AI model.
|
|
1713
|
-
# @param [String] prompt The user prompt to generate a response to.
|
|
1714
|
-
# @return [String, nil] The generated response or nil if generation fails.
|
|
1715
|
-
def ollama_generate(system:, prompt:)
|
|
1716
|
-
unless ollama = ollama_client
|
|
1717
|
-
warn "Ollama is not configured. => Returning."
|
|
1718
|
-
return
|
|
1719
|
-
end
|
|
1720
|
-
model = ollama_model
|
|
1721
|
-
options = ENV['OLLAMA_MODEL_OPTIONS'].full? { |o| JSON.parse(o) } || {}
|
|
1722
|
-
options |= { "temperature" => 0, "top_p" => 1, "min_p" => 0.1 }
|
|
1723
|
-
ollama.generate(model:, system:, prompt:, options:, stream: false, think: false).response
|
|
1724
|
-
end
|
|
1725
|
-
|
|
1726
1781
|
# Increases the specified part of the version number and writes it back to
|
|
1727
1782
|
# the VERSION file.
|
|
1728
1783
|
#
|
|
@@ -1744,7 +1799,7 @@ class GemHadar
|
|
|
1744
1799
|
# - The start version (e.g., '1.2.3') from which changes are compared.
|
|
1745
1800
|
# - The end version (e.g., '1.2.4' or 'HEAD') up to which changes are compared.
|
|
1746
1801
|
def determine_version_range
|
|
1747
|
-
version_tags
|
|
1802
|
+
version_tags = versions.map { version_tag(_1) } + %w[ HEAD ]
|
|
1748
1803
|
found_version_tag = version_tags.index(version_tag(version))
|
|
1749
1804
|
found_version_tag.nil? and fail "cannot find version tag #{version_tag(version)}"
|
|
1750
1805
|
start_version, end_version = version_tags[found_version_tag, 2]
|
|
@@ -1759,6 +1814,25 @@ class GemHadar
|
|
|
1759
1814
|
end
|
|
1760
1815
|
end
|
|
1761
1816
|
|
|
1817
|
+
# The version_tag_list method retrieves and processes semantic version tags
|
|
1818
|
+
# from the Git repository.
|
|
1819
|
+
#
|
|
1820
|
+
# This method fetches all Git tags from the repository, filters them to
|
|
1821
|
+
# include only those that match semantic versioning patterns (containing
|
|
1822
|
+
# three numeric components separated by dots), removes any 'v' prefix from
|
|
1823
|
+
# the tags, and sorts the resulting version specifications in ascending order
|
|
1824
|
+
# according to semantic versioning rules.
|
|
1825
|
+
#
|
|
1826
|
+
# @return [ Array<GemHadar::VersionSpec> ] an array of VersionSpec objects
|
|
1827
|
+
# representing the semantic versions found in the repository, sorted in
|
|
1828
|
+
# ascending order
|
|
1829
|
+
def version_tag_list
|
|
1830
|
+
`git tag`.lines.grep(/^v?\d+\.\d+\.\d+$/).
|
|
1831
|
+
map { |tag| GemHadar::VersionSpec[tag.chomp] }.
|
|
1832
|
+
sort_by(&:version)
|
|
1833
|
+
end
|
|
1834
|
+
memoize method: :version_tag_list, freeze: true
|
|
1835
|
+
|
|
1762
1836
|
# The write_gemfile method creates and writes the default Gemfile content if
|
|
1763
1837
|
# it doesn't exist. If a custom Gemfile exists, it only displays a warning.
|
|
1764
1838
|
def write_gemfile
|
|
@@ -1812,7 +1886,7 @@ class GemHadar
|
|
|
1812
1886
|
def gemspec
|
|
1813
1887
|
Gem::Specification.new do |s|
|
|
1814
1888
|
s.name = name
|
|
1815
|
-
s.version = ::Gem::Version.new(version)
|
|
1889
|
+
s.version = ::Gem::Version.new(version_untag(version))
|
|
1816
1890
|
s.author = author
|
|
1817
1891
|
s.email = email
|
|
1818
1892
|
s.homepage = assert_valid_link(:homepage, homepage)
|
|
@@ -1873,29 +1947,6 @@ class GemHadar
|
|
|
1873
1947
|
remotes
|
|
1874
1948
|
end
|
|
1875
1949
|
|
|
1876
|
-
# The ask? method prompts the user with a message and reads their input It
|
|
1877
|
-
# returns a MatchData object if the input matches the provided pattern.
|
|
1878
|
-
#
|
|
1879
|
-
# @param prompt [ String ] the message to display to the user
|
|
1880
|
-
# @param pattern [ Regexp ] the regular expression to match against the input
|
|
1881
|
-
#
|
|
1882
|
-
# @return [ MatchData, nil ] the result of the pattern match or nil if no match
|
|
1883
|
-
def ask?(prompt, pattern, default: nil)
|
|
1884
|
-
if prompt.include?('%{default}')
|
|
1885
|
-
if default.present?
|
|
1886
|
-
prompt = prompt % { default: ", default is #{default.inspect}" }
|
|
1887
|
-
else
|
|
1888
|
-
prompt = prompt % { default: '' }
|
|
1889
|
-
end
|
|
1890
|
-
end
|
|
1891
|
-
STDOUT.print prompt
|
|
1892
|
-
answer = STDIN.gets.chomp
|
|
1893
|
-
default.present? && answer.blank? and answer = default
|
|
1894
|
-
if answer =~ pattern
|
|
1895
|
-
$~
|
|
1896
|
-
end
|
|
1897
|
-
end
|
|
1898
|
-
|
|
1899
1950
|
# The gem_files method returns an array of files that are included in the gem
|
|
1900
1951
|
# package.
|
|
1901
1952
|
#
|
|
@@ -1919,8 +1970,8 @@ class GemHadar
|
|
|
1919
1970
|
# order according to semantic versioning rules.
|
|
1920
1971
|
memoize method:
|
|
1921
1972
|
def versions
|
|
1922
|
-
`git tag`.lines.grep(/^v?\d+\.\d+\.\d+$/).map(&:chomp).map {
|
|
1923
|
-
|
|
1973
|
+
`git tag`.lines.grep(/^v?\d+\.\d+\.\d+$/).map(&:chomp).map { |tag|
|
|
1974
|
+
GemHadar::VersionSpec[tag, without_prefix: true]
|
|
1924
1975
|
}.sort_by(&:version)
|
|
1925
1976
|
end
|
|
1926
1977
|
|
|
@@ -1930,11 +1981,7 @@ class GemHadar
|
|
|
1930
1981
|
# @param version [String] the version string to modify
|
|
1931
1982
|
# @return [String] the modified version string with a 'v' prefix
|
|
1932
1983
|
def version_tag(version)
|
|
1933
|
-
|
|
1934
|
-
version.dup.prepend ?v
|
|
1935
|
-
else
|
|
1936
|
-
version.dup
|
|
1937
|
-
end
|
|
1984
|
+
GemHadar::VersionSpec[version].tag
|
|
1938
1985
|
end
|
|
1939
1986
|
|
|
1940
1987
|
# The version_untag method removes the 'v' prefix from a version tag string.
|
|
@@ -1943,7 +1990,7 @@ class GemHadar
|
|
|
1943
1990
|
#
|
|
1944
1991
|
# @return [ String ] the version string with the 'v' prefix removed
|
|
1945
1992
|
def version_untag(version_tag)
|
|
1946
|
-
version.
|
|
1993
|
+
GemHadar::VersionSpec[version].untag
|
|
1947
1994
|
end
|
|
1948
1995
|
|
|
1949
1996
|
# The github_remote_url method retrieves and parses the GitHub remote URL
|
|
@@ -1995,36 +2042,52 @@ class GemHadar
|
|
|
1995
2042
|
@github_workflows_variables || {}
|
|
1996
2043
|
end
|
|
1997
2044
|
|
|
2045
|
+
# The create_github_workflow_templates method compiles GitHub Actions
|
|
2046
|
+
# workflow templates from ERB files into actual YAML workflow files in the
|
|
2047
|
+
# project's .github/workflows directory
|
|
2048
|
+
#
|
|
2049
|
+
# This method iterates through the configured GitHub workflows, processes
|
|
2050
|
+
# each ERB template file using the template compilation system, and generates
|
|
2051
|
+
# the corresponding workflow files in the standard GitHub Actions directory
|
|
2052
|
+
# structure
|
|
2053
|
+
def create_github_workflow_templates
|
|
2054
|
+
src_dir = Pathname.new(__dir__).join('gem_hadar', 'github_workflows')
|
|
2055
|
+
dst_dir = Pathname.pwd.join('.github', 'workflows')
|
|
2056
|
+
templates = Set[]
|
|
2057
|
+
github_workflows.each do |workflow, variables|
|
|
2058
|
+
@github_workflows_variables = variables
|
|
2059
|
+
src = src_dir.join(workflow + '.erb')
|
|
2060
|
+
unless src.exist?
|
|
2061
|
+
warn "Workflow template #{src.to_s.inspect} doesn't exist! => Skipping."
|
|
2062
|
+
end
|
|
2063
|
+
mkdir_p dst_dir, verbose: false
|
|
2064
|
+
dst = dst_dir.join(workflow)
|
|
2065
|
+
templates << template(src, dst) {}
|
|
2066
|
+
end
|
|
2067
|
+
templates.to_a
|
|
2068
|
+
end
|
|
2069
|
+
|
|
1998
2070
|
# The github_workflows_task method sets up Rake tasks for generating GitHub
|
|
1999
2071
|
# Actions workflow files from ERB templates.
|
|
2000
2072
|
#
|
|
2001
|
-
# This method configures a hierarchical task structure under the :github
|
|
2002
|
-
#
|
|
2073
|
+
# This method configures a hierarchical task structure under the :github
|
|
2074
|
+
# namespace that:
|
|
2075
|
+
#
|
|
2076
|
+
# - Compiles configured workflow templates from ERB files into actual
|
|
2077
|
+
# workflow YAML files
|
|
2003
2078
|
# - Creates a :workflows task that depends on all compiled template files
|
|
2004
2079
|
# - Sets up a :workflows:clean task to remove generated workflow files
|
|
2005
|
-
# - Uses the github_workflows configuration to determine which workflows to
|
|
2080
|
+
# - Uses the github_workflows configuration to determine which workflows to
|
|
2081
|
+
# generate
|
|
2006
2082
|
# - Applies template variables to customize the generated workflows
|
|
2007
2083
|
def github_workflows_task
|
|
2008
2084
|
namespace :github do
|
|
2009
|
-
templates = []
|
|
2010
|
-
src_dir = Pathname.new(__dir__).join('gem_hadar', 'github_workflows')
|
|
2011
|
-
dst_dir = Pathname.pwd.join('.github', 'workflows')
|
|
2012
|
-
github_workflows.each do |workflow, variables|
|
|
2013
|
-
@github_workflows_variables = variables
|
|
2014
|
-
src = src_dir.join(workflow + '.erb')
|
|
2015
|
-
puts "Compiling #{src.to_s.inspect} to #{dst_dir.to_s.inspect} now."
|
|
2016
|
-
unless src.exist?
|
|
2017
|
-
warn "Workflow template #{src.to_s.inspect} doesn't exist! => Skipping."
|
|
2018
|
-
end
|
|
2019
|
-
mkdir_p dst_dir
|
|
2020
|
-
dst = dst_dir.join(workflow)
|
|
2021
|
-
templates << (template(src, dst) {}).to_s
|
|
2022
|
-
end
|
|
2023
2085
|
desc "Create all configured github workflow tasks"
|
|
2024
|
-
task :workflows =>
|
|
2086
|
+
task :workflows => create_github_workflow_templates
|
|
2025
2087
|
namespace :workflows do
|
|
2026
2088
|
desc "Delete all created github workflows"
|
|
2027
2089
|
task :clean do
|
|
2090
|
+
dst_dir = Pathname.pwd.join('.github', 'workflows')
|
|
2028
2091
|
github_workflows.each_key do |workflow|
|
|
2029
2092
|
rm_f dst_dir.join(workflow), verbose: true
|
|
2030
2093
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gem_hadar
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.11.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.10'
|
|
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.10'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: all_images
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -107,6 +107,20 @@ dependencies:
|
|
|
107
107
|
- - "~>"
|
|
108
108
|
- !ruby/object:Gem::Version
|
|
109
109
|
version: '1.17'
|
|
110
|
+
- !ruby/object:Gem::Dependency
|
|
111
|
+
name: infobar
|
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
|
113
|
+
requirements:
|
|
114
|
+
- - "~>"
|
|
115
|
+
- !ruby/object:Gem::Version
|
|
116
|
+
version: '0.11'
|
|
117
|
+
type: :runtime
|
|
118
|
+
prerelease: false
|
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - "~>"
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: '0.11'
|
|
110
124
|
- !ruby/object:Gem::Dependency
|
|
111
125
|
name: mize
|
|
112
126
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -242,7 +256,9 @@ extensions: []
|
|
|
242
256
|
extra_rdoc_files:
|
|
243
257
|
- README.md
|
|
244
258
|
- lib/gem_hadar.rb
|
|
259
|
+
- lib/gem_hadar/changelog_generator.rb
|
|
245
260
|
- lib/gem_hadar/github.rb
|
|
261
|
+
- lib/gem_hadar/ollama_support.rb
|
|
246
262
|
- lib/gem_hadar/prompt_template.rb
|
|
247
263
|
- lib/gem_hadar/rvm_config.rb
|
|
248
264
|
- lib/gem_hadar/setup.rb
|
|
@@ -250,6 +266,7 @@ extra_rdoc_files:
|
|
|
250
266
|
- lib/gem_hadar/template_compiler.rb
|
|
251
267
|
- lib/gem_hadar/utils.rb
|
|
252
268
|
- lib/gem_hadar/version.rb
|
|
269
|
+
- lib/gem_hadar/version_spec.rb
|
|
253
270
|
- lib/gem_hadar/warn.rb
|
|
254
271
|
files:
|
|
255
272
|
- ".all_images.yml"
|
|
@@ -261,8 +278,10 @@ files:
|
|
|
261
278
|
- bin/gem_hadar
|
|
262
279
|
- gem_hadar.gemspec
|
|
263
280
|
- lib/gem_hadar.rb
|
|
281
|
+
- lib/gem_hadar/changelog_generator.rb
|
|
264
282
|
- lib/gem_hadar/github.rb
|
|
265
283
|
- lib/gem_hadar/github_workflows/static.yml.erb
|
|
284
|
+
- lib/gem_hadar/ollama_support.rb
|
|
266
285
|
- lib/gem_hadar/prompt_template.rb
|
|
267
286
|
- lib/gem_hadar/rvm_config.rb
|
|
268
287
|
- lib/gem_hadar/setup.rb
|
|
@@ -270,6 +289,7 @@ files:
|
|
|
270
289
|
- lib/gem_hadar/template_compiler.rb
|
|
271
290
|
- lib/gem_hadar/utils.rb
|
|
272
291
|
- lib/gem_hadar/version.rb
|
|
292
|
+
- lib/gem_hadar/version_spec.rb
|
|
273
293
|
- lib/gem_hadar/warn.rb
|
|
274
294
|
- spec/gem_hadar_spec.rb
|
|
275
295
|
- spec/spec_helper.rb
|