Skip to content

Commit

Permalink
Merge pull request #277 from lacostej/lts
Browse files Browse the repository at this point in the history
u3d/available support LTS (#276)
  • Loading branch information
lacostej authored Apr 17, 2018
2 parents 511da18 + e8fa38a commit db12c15
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions lib/u3d/unity_versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ module UnityVersions
UNITY_LINUX_DOWNLOADS = 'https://forum.unity.com/threads/unity-on-linux-release-notes-and-known-issues.350256/'.freeze
# URL for the main releases for Windows and Macintosh
UNITY_DOWNLOADS = 'https://unity3d.com/get-unity/download/archive'.freeze
# URL for the LTS releases for Windows and Macintosh
UNITY_LTSES = 'https://unity3d.com/unity/qa/lts-releases'.freeze
# URL for the patch releases for Windows and Macintosh
UNITY_PATCHES = 'https://unity3d.com/unity/qa/patch-releases'.freeze
# URL for the beta releases list, they need to be accessed after
Expand Down Expand Up @@ -220,44 +222,42 @@ def list_available_from_page(unity_forums, data)
end
end

class VersionsFetcher
attr_accessor :versions

def initialize(pattern:)
@versions = {}
@pattern = pattern
end

def fetch_some(type, url)
UI.message "Loading Unity #{type} releases"
current = UnityVersions.fetch_version(url, @pattern)
UI.success "Found #{current.count} #{type} releases."
@versions.merge!(current)
end

def fetch_all_channels
fetch_some('lts', UNITY_LTSES)
fetch_some('stable', UNITY_DOWNLOADS)
fetch_some('patch', UNITY_PATCHES)
fetch_some('beta', UNITY_BETAS)
@versions
end
end

class MacVersions
class << self
def list_available
versions = {}
UI.message 'Loading Unity releases'
current = UnityVersions.fetch_version(UNITY_DOWNLOADS, MAC_DOWNLOAD)
UI.success "Found #{current.count} releases." if current.count.nonzero?
versions = versions.merge(current)
UI.message 'Loading Unity patch releases'
current = UnityVersions.fetch_version_paged(UNITY_PATCHES, MAC_DOWNLOAD)
UI.success "Found #{current.count} patch releases." if current.count.nonzero?
versions = versions.merge(current)
UI.message 'Loading Unity beta releases'
current = UnityVersions.fetch_betas(UNITY_BETAS, MAC_DOWNLOAD)
UI.success "Found #{current.count} beta releases." if current.count.nonzero?
versions = versions.merge(current)
versions
VersionsFetcher.new(pattern: MAC_DOWNLOAD).fetch_all_channels
end
end
end

class WindowsVersions
class << self
def list_available
versions = {}
UI.message 'Loading Unity releases'
current = UnityVersions.fetch_version(UNITY_DOWNLOADS, WIN_DOWNLOAD)
UI.success "Found #{current.count} releases." if current.count.nonzero?
versions = versions.merge(current)
UI.message 'Loading Unity patch releases'
current = UnityVersions.fetch_version_paged(UNITY_PATCHES, WIN_DOWNLOAD)
UI.success "Found #{current.count} patch releases." if current.count.nonzero?
versions = versions.merge(current)
UI.message 'Loading Unity beta releases'
current = UnityVersions.fetch_betas(UNITY_BETAS, WIN_DOWNLOAD)
UI.success "Found #{current.count} beta releases." if current.count.nonzero?
versions = versions.merge(current)
versions
VersionsFetcher.new(pattern: WIN_DOWNLOAD).fetch_all_channels
end
end
end
Expand Down

0 comments on commit db12c15

Please sign in to comment.