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

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_DOWNLOAD =
%r{"(https?://[\w/\.-]+/[0-9a-f\+]{12,13}/)MacEditorInstaller/[a-zA-Z0-9/\.\+]+-(\d+\.\d+\.\d+\w\d+)\.?\w+"}
MAC_DOWNLOAD_2018_2 =
%r{"(https?://[\w/\.-]+/[0-9a-f\+]{12,13}/)UnityDownloadAssistant-[a-zA-Z0-9/\.\+]+-(\d+\.\d+\.\d+\w\d+)\.?\w+"}
WIN_DOWNLOAD =
%r{"(https?://[\w/\.-]+/[0-9a-f\+]{12,13}/)Windows..EditorInstaller/[a-zA-Z0-9/\.\+]+-(\d+\.\d+\.\d+\w\d+)\.?\w+"}
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"}

REGEX: expressions to interpret data collapse

Class Method Details

.fetch_betas(url, pattern) ⇒ Object



163
164
165
166
167
168
169
# File 'lib/u3d/unity_versions.rb', line 163

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_version(url, pattern) ⇒ Object



149
150
151
152
153
154
155
# File 'lib/u3d/unity_versions.rb', line 149

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



157
158
159
160
161
# File 'lib/u3d/unity_versions.rb', line 157

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

.list_available(os: nil) ⇒ Object



134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/u3d/unity_versions.rb', line 134

def list_available(os: nil)
  os ||= U3dCore::Helper.operating_system

  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