Sha256: 0ddbca1688b416af906c7f94a672d145d4018258629b33dd8a4cb78ffe3edc15

Contents?: true

Size: 1.32 KB

Versions: 17

Compression:

Stored size: 1.32 KB

Contents

def build_version_sidebar(dir, version)
  raw = File.read("template-replace/resources/version_list.html")
  template = raw.match(/<!--template-->(.*)<!--endtemplate-->/m)[1]
  raw.gsub!(template, "")
  res = +""
  i = 0
  `git tag`
    .force_encoding("utf-8")
    .split("\n")
    .sort_by { |v| Gem::Version.new(v[1..]) }
    .reverse
    .each.with_index do |tag|
    i += 1
    sha = `git rev-parse #{tag}`.force_encoding("utf-8").strip
    tag_version = tag.delete_prefix("v")
    cls = i % 2 == 0 ? "even" : "odd"
    if tag_version == version
      cls += " current"
    end
    res += template
      .gsub("!version!", tag_version)
      .gsub("!path!", "/" + tag_version)
      .gsub("!class!", cls)
      .gsub("!sha!", sha)
  end
  i += 1
  cls = i % 2 == 0 ? "even" : "odd"
  if version == "main"
    cls += " current"
  end
  res.insert 0, template
               .gsub("!version!", "main")
               .gsub("!path!", "/main")
               .gsub("!class!", cls)
               .gsub("!sha!", "Latest on GitHub")
  i += 1
  cls = i % 2 == 0 ? "even" : "odd"
  res.insert 0, template
               .gsub("!version!", "Latest")
               .gsub("!path!", "")
               .gsub("!class!", cls)
               .gsub("!sha!", "Latest on RubyGems")
  File.write(dir + "/version_list.html", raw.gsub("<!--replace-->", res))
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
discorb-0.13.4 template-replace/scripts/version.rb
discorb-0.13.3 template-replace/scripts/version.rb
discorb-0.13.2 template-replace/scripts/version.rb
discorb-0.13.1 template-replace/scripts/version.rb
discorb-0.13.0 template-replace/scripts/version.rb
discorb-0.12.4 template-replace/scripts/version.rb
discorb-0.12.3 template-replace/scripts/version.rb
discorb-0.12.2 template-replace/scripts/version.rb
discorb-0.12.1 template-replace/scripts/version.rb
discorb-0.12.0 template-replace/scripts/version.rb
discorb-0.11.4 template-replace/scripts/version.rb
discorb-0.11.3 template-replace/scripts/version.rb
discorb-0.11.2 template-replace/scripts/version.rb
discorb-0.11.1 template-replace/scripts/version.rb
discorb-0.11.0 template-replace/scripts/version.rb
discorb-0.10.3 template-replace/scripts/version.rb
discorb-0.10.2 template-replace/scripts/version.rb