Module:VersionHelpers

local p = {}

--% This function returns information about the studio build with the given hash. --@ hash (string) the version hash, for example "version-03bbbab2d5464457" --: (table) a table with information about the studio build; nil if not found function p.get_build_from_hash(hash) for _, build in pairs(require("Module:StudioVersions")) do		if build.hash == hash then return build end end end

--% This function returns an array of builds with the given minor version. --@ major (string) the major component, usually 0 --@ minor (string) the minor component --: (table) an array of tables with information about each build; the builds are sorted chronologically function p.get_builds_from_minor(major, minor) local builds = {} for _, build in ipairs(require("Module:StudioVersions")) do		local build_major, build_minor = p.parse_version_string(build.version) if build_major == major and build_minor == minor then table.insert(builds. build) end end return builds end

--% This function parses a version string. --@ version_string (string) the version string, for example "0.379.0.292444" --: (string) the major component --: (string) the minor component --: (string) the maint component --: (string) the build component function p.parse_version_string(version_string) local major, minor, maint, build = unpack(mw.text.split(version_string, ".", true)) assert(major) assert(minor) assert(maint) assert(build) return major, minor, maint, build end

--% This function returns whether a build with a minor component exists. --@ minor (string) the minor component --: (boolean) true if a build with the provided minor component exists function p.minor_component_exists(minor) local studio_builds = require("Module:StudioVersions") for _, build in pairs(studio_builds) do		local _, build_minor = p.parse_version_string(build.version) if minor == build_minor then return true end end return false end

return p