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/'
- UNITY_DOWNLOADS =
URL for the main releases for Windows and Macintosh
'https://unity3d.com/get-unity/download/archive'
- UNITY_LTSES =
URL for the LTS releases for Windows and Macintosh
'https://unity3d.com/unity/qa/lts-releases'
- UNITY_PATCHES =
URL for the patch releases for Windows and Macintosh
'https://unity3d.com/unity/qa/patch-releases'
- UNITY_BETAS =
URL for the beta releases list, they need to be accessed after
'https://unity3d.com/unity/beta/archive'
- UNITY_BETA_URL =
URL for a specific beta, takes into parameter a version string (%s)
'https://unity3d.com/unity/beta/unity%<version>s'
- 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'
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+)['"]}.freeze
- MAC_WIN_SHADERS =
%r{"(https?://[\w/.-]+/[0-9a-f+]{12,13}/)builtin_shaders-(\d+\.\d+\.\d+\w\d+)\.?\w+"}.freeze
- LINUX_INSTALLER =
%r{(https?://[\w/.-]+/[0-9a-f+]{12,13}/)LinuxEditorInstaller/Unity.tar.xz}.freeze
- LINUX_DOWNLOAD_DATED =
%r{"(https?://[\w/._-]+/unity-editor-installer-(\d+\.\d+\.\d+\w\d+).*\.sh)"}.freeze
- LINUX_DOWNLOAD_RECENT_PAGE =
%r{"(https?://beta\.unity3d\.com/download/[a-zA-Z0-9/.+]+/public_download\.html)"}.freeze
- LINUX_DOWNLOAD_RECENT_FILE =
%r{'(https?://beta\.unity3d\.com/download/[a-zA-Z0-9/.+]+/unity-editor-installer-(\d+\.\d+\.\d+(?:x)?\w\d+).*\.sh)'}.freeze
- UNITY_BETAVERSION_REGEX =
Captures a beta version in html page
%r{/unity/beta/unity(\d+\.\d+\.\d+\w\d+)"}.freeze
- UNITY_EXTRA_DOWNLOAD_REGEX =
%r{"(https?://[\w/.-]+\.unity3d\.com/(\w+))/[a-zA-Z/.-]+/download.html"}.freeze
- UNITY_LATEST_JSON =
For the latest releases fetched from json
%r{(https?://[\w/.-]+/[0-9a-f+]{12,13}/)}.freeze
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
189 190 191 192 193 194 195 |
# File 'lib/u3d/unity_versions.rb', line 189 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
183 184 185 186 187 |
# File 'lib/u3d/unity_versions.rb', line 183 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
177 178 179 180 181 |
# File 'lib/u3d/unity_versions.rb', line 177 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
159 160 161 162 163 164 165 |
# File 'lib/u3d/unity_versions.rb', line 159 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
167 168 169 170 171 |
# File 'lib/u3d/unity_versions.rb', line 167 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
173 174 175 |
# File 'lib/u3d/unity_versions.rb', line 173 def json_url_for(os) format(UNITY_LATEST_JSON_URL, os: os) end |
.list_available(os: nil) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/u3d/unity_versions.rb', line 144 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 |