Class: Version
- Inherits:
-
Object
- Object
- Version
- Defined in:
- lib/ratatui_ruby/devtools/tasks/website/version.rb
Overview
A documentation version for multi-version websites.
Documentation websites need to serve multiple versions. Users browse docs for their installed release. Maintainers preview trunk changes. Manually tracking git tags and branches is tedious.
This class discovers versions from git tags. It extracts source files at each ref. It provides metadata for version menus.
Use it to build multi-version documentation portals.
Class Method Summary collapse
-
.all ⇒ Object
Discovers all available versions.
Instance Method Summary collapse
-
#checkout(globs:, &block) ⇒ Object
Yields a temporary directory containing this version’s source.
-
#edge? ⇒ Boolean
Returns
trueif this is the edge (trunk) version. -
#latest? ⇒ Boolean
Returns
trueif this is the latest stable release. -
#name ⇒ Object
Human-readable name for version menus.
-
#ref ⇒ Object
Git ref (branch or tag) for checkout.
-
#slug ⇒ Object
URL-safe identifier for this version.
-
#type ⇒ Object
Version type:
:edgeor:version.
Class Method Details
.all ⇒ Object
Discovers all available versions.
Returns Edge (trunk) plus the latest patch for each minor version, sorted newest first.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ratatui_ruby/devtools/tasks/website/version.rb', line 26 def self.all = `git tag`.split.grep(/^v\d/) sorted_versions = .map { |t| Tagged.new(t) } .sort_by(&:semver) .reverse # Keep only the latest patch for each minor version # e.g., if we have v0.6.0, v0.6.1, v0.6.2, only keep v0.6.2 latest_per_minor = sorted_versions .group_by { |v| v.semver.segments[0..1] } # group by [major, minor] .values .map(&:first) # take the first (highest patch) from each group [Edge.new] + latest_per_minor end |
Instance Method Details
#checkout(globs:, &block) ⇒ Object
Yields a temporary directory containing this version’s source.
Exports the git archive at the specified ref. Removes the native extension directory to avoid compilation issues.
- globs
-
File patterns (unused, for API compatibility).
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/ratatui_ruby/devtools/tasks/website/version.rb', line 68 def checkout(globs:, &block) Dir.mktmpdir do |path| # Use git archive to export the version at the specified ref # Pipe to tar to extract into the temporary directory system("git archive #{ref} | tar -x -C #{path}") # Remove the native extension directory as we don't need it for builds # and it can cause issues if not meant to be compiled in this context FileUtils.rm_rf("#{path}/ext") yield path end end |
#edge? ⇒ Boolean
Returns true if this is the edge (trunk) version.
88 89 90 |
# File 'lib/ratatui_ruby/devtools/tasks/website/version.rb', line 88 def edge? false end |
#latest? ⇒ Boolean
Returns true if this is the latest stable release.
83 84 85 |
# File 'lib/ratatui_ruby/devtools/tasks/website/version.rb', line 83 def latest? false end |
#name ⇒ Object
Human-readable name for version menus.
48 49 50 |
# File 'lib/ratatui_ruby/devtools/tasks/website/version.rb', line 48 def name raise NotImplementedError end |
#ref ⇒ Object
Git ref (branch or tag) for checkout.
58 59 60 |
# File 'lib/ratatui_ruby/devtools/tasks/website/version.rb', line 58 def ref raise NotImplementedError end |
#slug ⇒ Object
URL-safe identifier for this version.
43 44 45 |
# File 'lib/ratatui_ruby/devtools/tasks/website/version.rb', line 43 def slug raise NotImplementedError end |
#type ⇒ Object
Version type: :edge or :version.
53 54 55 |
# File 'lib/ratatui_ruby/devtools/tasks/website/version.rb', line 53 def type raise NotImplementedError end |