Sha256: 4fb358890ae63a6d8a324e0515bb4869cecafbaf01f436e55b855d9fa144196a

Contents?: true

Size: 922 Bytes

Versions: 25

Compression:

Stored size: 922 Bytes

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").each.with_index do |tag|
    i += 1
    sha = `git rev-parse #{tag}`.force_encoding("utf-8").strip
    version = tag.delete_prefix("v")
    cls = i % 2 == 0 ? "even" : "odd"
    if version == "."
      cls += " current"
    end
    res += template.gsub("!version!", version).gsub("!path!", "../" + version).gsub("!class!", cls).gsub("!sha!", sha)
  end
  i += 1
  cls = i % 2 == 0 ? "even" : "odd"
  if version == "main"
    cls += " current"
  end
  res += template.gsub("!version!", "main").gsub("!path!", "../main").gsub("!class!", cls).gsub("!sha!", "(Latest on GitHub)")
  File.write(dir + "/version_list.html", raw.gsub("<!--replace-->", res))
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
discorb-0.9.6 template-replace/scripts/version.rb
discorb-0.9.5 template-replace/scripts/version.rb
discorb-0.9.4 template-replace/scripts/version.rb
discorb-0.9.3 template-replace/scripts/version.rb
discorb-0.9.1 template-replace/scripts/version.rb
discorb-0.9.0 template-replace/scripts/version.rb
discorb-0.8.2 template-replace/scripts/version.rb
discorb-0.8.1 template-replace/scripts/version.rb
discorb-0.8.0 template-replace/scripts/version.rb
discorb-0.7.6 template-replace/scripts/version.rb
discorb-0.7.3 template-replace/scripts/version.rb
discorb-0.7.2 template-replace/scripts/version.rb
discorb-0.7.1 template-replace/scripts/version.rb
discorb-0.7.0 template-replace/scripts/version.rb
discorb-0.6.1 template-replace/scripts/version.rb
discorb-0.6.0 template-replace/scripts/version.rb
discorb-0.5.6 template-replace/scripts/version.rb
discorb-0.5.5 template-replace/scripts/version.rb
discorb-0.5.4 template-replace/scripts/version.rb
discorb-0.5.3 template-replace/scripts/version.rb