Module: U3d::UnityVersions
- Defined in:
- lib/u3d/unity_versions.rb
Overview
Takes care of fectching versions and version list
Defined Under Namespace
Classes: LinuxVersions, MacVersions, VersionsFetcher, WindowsVersions
URLS: Locations to fetch information from collapse
- UNITY_LINUX_DOWNLOADS =
URL for the forum thread listing all the Linux releases
'https://forum.unity.com/threads/unity-on-linux-release-notes-and-known-issues.350256/'.freeze
- UNITY_DOWNLOADS =
URL for the main releases for Windows and Macintosh
'https://unity3d.com/get-unity/download/archive'.freeze
- UNITY_LTSES =
URL for the LTS releases for Windows and Macintosh
'https://unity3d.com/unity/qa/lts-releases'.freeze
- UNITY_PATCHES =
URL for the patch releases for Windows and Macintosh
'https://unity3d.com/unity/qa/patch-releases'.freeze
- UNITY_BETAS =
URL for the beta releases list, they need to be accessed after
'https://unity3d.com/unity/beta/archive'.freeze
- UNITY_BETA_URL =
URL for a specific beta, takes into parameter a version string (%s)
'https://unity3d.com/unity/beta/unity%<version>s'.freeze
- UNITY_LATEST_JSON_URL =
URL for latest releases listing (since Unity 2017.1.5f1), takes into parameter os (windows => win32, mac => darwin)
'https://public-cdn.cloud.unity3d.com/hub/prod/releases-%<os>s.json'.freeze
REGEX: expressions to interpret data collapse
- LINUX_DOWNLOAD =
Captures a version and its base url
%r{['"](https?:\/\/[\w/\.-]+/[0-9a-f\+]{12,13}\/)(.\/)?UnitySetup-(\d+\.\d+\.\d+\w\d+)['"]}
- MAC_WIN_SHADERS =
%r{"(https?://[\w/\.-]+/[0-9a-f\+]{12,13}/)builtin_shaders-(\d+\.\d+\.\d+\w\d+)\.?\w+"}
- LINUX_INSTALLER =
%r{(https?://[\w/\.-]+/[0-9a-f\+]{12,13}/)LinuxEditorInstaller/Unity.tar.xz}
- LINUX_DOWNLOAD_DATED =
%r{"(https?://[\w/\._-]+/unity\-editor\-installer\-(\d+\.\d+\.\d+\w\d+).*\.sh)"}
- LINUX_DOWNLOAD_RECENT_PAGE =
%r{"(https?://beta\.unity3d\.com/download/[a-zA-Z0-9/\.\+]+/public_download\.html)"}
- LINUX_DOWNLOAD_RECENT_FILE =
%r{'(https?://beta\.unity3d\.com/download/[a-zA-Z0-9/\.\+]+/unity\-editor\-installer\-(\d+\.\d+\.\d+(?:x)?\w\d+).*\.sh)'}
- UNITY_BETAVERSION_REGEX =
Captures a beta version in html page
%r{\/unity\/beta\/unity(\d+\.\d+\.\d+\w\d+)"}
- UNITY_EXTRA_DOWNLOAD_REGEX =
%r{"(https?:\/\/[\w\/.-]+\.unity3d\.com\/(\w+))\/[a-zA-Z\/.-]+\/download.html"}
- UNITY_LATEST_JSON =
For the latest releases fetched from json
%r{(https?://[\w/\.-]+/[0-9a-f\+]{12,13}/)}
REGEX: expressions to interpret data collapse
- .fetch_betas(url, pattern) ⇒ Object
- .fetch_from_json(url, pattern) ⇒ Object
- .fetch_json(url, pattern) ⇒ Object
- .fetch_version(url, pattern) ⇒ Object
- .fetch_version_paged(url, pattern) ⇒ Object
- .json_url_for(os) ⇒ Object
- .list_available(os: nil) ⇒ Object
Class Method Details
.fetch_betas(url, pattern) ⇒ Object
184 185 186 187 188 189 190 |
# File 'lib/u3d/unity_versions.rb', line 184 def fetch_betas(url, pattern) hash = {} data = Utils.get_ssl(url) results = data.scan(UNITY_BETAVERSION_REGEX).uniq results.each { |beta| hash.merge!(fetch_version(format(UNITY_BETA_URL, version: beta[0]), pattern)) } hash end |
.fetch_from_json(url, pattern) ⇒ Object
178 179 180 181 182 |
# File 'lib/u3d/unity_versions.rb', line 178 def fetch_from_json(url, pattern) fetch_json(url, pattern).map do |build| [build['version'], pattern.match(build['downloadUrl'])[1]] end.to_h end |
.fetch_json(url, pattern) ⇒ Object
172 173 174 175 176 |
# File 'lib/u3d/unity_versions.rb', line 172 def fetch_json(url, pattern) require 'json' data = Utils.get_ssl(url) JSON.parse(data).values.flatten.select { |b| pattern =~ b['downloadUrl'] } end |
.fetch_version(url, pattern) ⇒ Object
154 155 156 157 158 159 160 |
# File 'lib/u3d/unity_versions.rb', line 154 def fetch_version(url, pattern) hash = {} data = Utils.get_ssl(url) results = data.scan(pattern) results.each { |capt| hash[capt[1]] = capt[0] } return hash end |
.fetch_version_paged(url, pattern) ⇒ Object
162 163 164 165 166 |
# File 'lib/u3d/unity_versions.rb', line 162 def fetch_version_paged(url, pattern) U3d::Utils.get_ssl(url).scan(/\?page=\d+/).map do |page| fetch_version("#{url}#{page}", pattern) end.reduce({}, :merge) end |
.json_url_for(os) ⇒ Object
168 169 170 |
# File 'lib/u3d/unity_versions.rb', line 168 def json_url_for(os) format(UNITY_LATEST_JSON_URL, os: os) end |
.list_available(os: nil) ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/u3d/unity_versions.rb', line 139 def list_available(os: nil) os ||= U3dCore::Helper. case os when :linux return U3d::UnityVersions::LinuxVersions.list_available when :mac return U3d::UnityVersions::MacVersions.list_available when :win return U3d::UnityVersions::WindowsVersions.list_available else raise ArgumentError, "Operating system #{os} not supported" end end |