Skip to content

Commit bb6d438

Browse files
authored
Merge pull request #350 from lacostej/fix/mac_v3
list/available: find Mac or Windows version based on the unity_shader package. Fixes #349
2 parents 6f3a72f + b030c1c commit bb6d438

File tree

3 files changed

+17
-27
lines changed

3 files changed

+17
-27
lines changed

lib/u3d/unity_versions.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ module UnityVersions
122122
#####################################################
123123
# Captures a version and its base url
124124
LINUX_DOWNLOAD = %r{['"](https?:\/\/[\w/\.-]+/[0-9a-f\+]{12,13}\/)(.\/)?UnitySetup-(\d+\.\d+\.\d+\w\d+)['"]}
125-
MAC_DOWNLOAD = %r{"(https?://[\w/\.-]+/[0-9a-f\+]{12,13}/)MacEditorInstaller/[a-zA-Z0-9/\.\+]+-(\d+\.\d+\.\d+\w\d+)\.?\w+"}
126-
MAC_DOWNLOAD_2018_2 = %r{"(https?://[\w/\.-]+/[0-9a-f\+]{12,13}/)UnityDownloadAssistant-(\d+\.\d+\.\d+\w\d+)\.?\w+"}
127-
WIN_DOWNLOAD = %r{"(https?://[\w/\.-]+/[0-9a-f\+]{12,13}/)Windows..EditorInstaller/[a-zA-Z0-9/\.\+]+-(\d+\.\d+\.\d+\w\d+)\.?\w+"}
125+
126+
MAC_WIN_SHADERS = %r{"(https?://[\w/\.-]+/[0-9a-f\+]{12,13}/)builtin_shaders-(\d+\.\d+\.\d+\w\d+)\.?\w+"}
127+
128128
LINUX_DOWNLOAD_DATED = %r{"(https?://[\w/\._-]+/unity\-editor\-installer\-(\d+\.\d+\.\d+\w\d+).*\.sh)"}
129129
LINUX_DOWNLOAD_RECENT_PAGE = %r{"(https?://beta\.unity3d\.com/download/[a-zA-Z0-9/\.\+]+/public_download\.html)"}
130130
LINUX_DOWNLOAD_RECENT_FILE = %r{'(https?://beta\.unity3d\.com/download/[a-zA-Z0-9/\.\+]+/unity\-editor\-installer\-(\d+\.\d+\.\d+(?:x)?\w\d+).*\.sh)'}
@@ -287,7 +287,7 @@ def fetch_all_channels
287287
class MacVersions
288288
class << self
289289
def list_available
290-
versions_fetcher = VersionsFetcher.new(pattern: [MAC_DOWNLOAD, MAC_DOWNLOAD_2018_2])
290+
versions_fetcher = VersionsFetcher.new(pattern: [MAC_WIN_SHADERS])
291291
versions_fetcher.fetch_all_channels
292292
versions_fetcher.fetch_json('darwin')
293293
end
@@ -297,7 +297,7 @@ def list_available
297297
class WindowsVersions
298298
class << self
299299
def list_available
300-
versions_fetcher = VersionsFetcher.new(pattern: WIN_DOWNLOAD)
300+
versions_fetcher = VersionsFetcher.new(pattern: MAC_WIN_SHADERS)
301301
versions_fetcher.fetch_all_channels
302302
versions_fetcher.fetch_json('win32')
303303
end

spec/support/download_archives.rb

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,14 @@
2121
## --- END LICENSE BLOCK ---
2222

2323
# Various fake download archives
24-
def windows_archive
24+
def macosx_windows_archive
2525
%(
26-
<li><a href="http://download.unity3d.com/download_unity/d3101c3b8468/Windows64EditorInstaller/UnitySetup64-1.2.3f1.exe">Éditeur 64 bits</a></li>
27-
<li><a href="http://download.unity3d.com/download_unity/d3101c3b8468/Windows64EditorInstaller/UnitySetup64-1.3.5f1.exe">Éditeur 64 bits</a></li>
28-
<li><a href="http://download.unity3d.com/download_unity/d3101c3b8468/Windows64EditorInstaller/UnitySetup64-2017.1.6f1.exe">Éditeur 64 bits</a></li>
29-
)
30-
end
31-
32-
def macosx_archive
33-
%(
34-
<li><a href="http://download.unity3d.com/download_unity/d3101c3b8468/MacEditorInstaller/Unity-1.2.3f1.pkg">Éditeur Unity</a></li>
35-
<li><a href="http://download.unity3d.com/download_unity/d3101c3b8468/MacEditorInstaller/Unity-1.3.5f1.pkg">Éditeur Unity</a></li>
36-
<li><a href="http://download.unity3d.com/download_unity/d3101c3b8468/MacEditorInstaller/Unity-2017.1.6f1.pkg">Éditeur Unity</a></li>
26+
<li><a href="https://download.unity3d.com/download_unity/builtin_shaders-4.7.2.zip">Shaders</a></li>
27+
<li><a href="https://download.unity3d.com/download_unity/builtin_shaders-4.7.2.zip">Shaders</a></li>
28+
<li><a href="https://download.unity3d.com/download_unity/6bac21139588/builtin_shaders-5.6.6f2.zip">Shaders</a></li>
29+
<li><a href="https://download.unity3d.com/download_unity/6bac21139588/builtin_shaders-5.6.6f2.zip">Shaders</a></li>
30+
<li><a href="https://netstorage.unity3d.com/unity/9e14d22a41bb/builtin_shaders-2018.3.7f1.zip"></a></li>
31+
<li><a href="https://netstorage.unity3d.com/unity/9e14d22a41bb/builtin_shaders-2018.3.7f1.zip"></a></li>
3732
)
3833
end
3934

spec/u3d/unity_versions_spec.rb

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,9 @@ def fake_linux_ini_data(size, url)
4545
end
4646

4747
describe '.fetch_version' do
48-
it 'reads versions for windows' do
49-
expect(U3d::Utils).to receive(:get_ssl) { windows_archive }
50-
expect(U3d::UnityVersions.fetch_version("foo", U3d::UnityVersions::WIN_DOWNLOAD).count).to eql 3
51-
end
52-
53-
it 'reads versions for mac' do
54-
expect(U3d::Utils).to receive(:get_ssl) { macosx_archive }
55-
expect(U3d::UnityVersions.fetch_version("foo", U3d::UnityVersions::MAC_DOWNLOAD).count).to eql 3
48+
it 'reads versions for windows and mac' do
49+
expect(U3d::Utils).to receive(:get_ssl) { macosx_windows_archive }
50+
expect(U3d::UnityVersions.fetch_version("foo", U3d::UnityVersions::MAC_WIN_SHADERS).count).to eql 2
5651
end
5752
end
5853

@@ -80,8 +75,8 @@ def fake_linux_ini_data(size, url)
8075
expect(U3d::UnityVersions.list_available(os: :win).count).to eql 0
8176
end
8277
it 'retrieves mac versions' do
83-
expect(U3d::UnityVersions).to receive(:fetch_version_paged).at_least(6).times { {} }
84-
expect(U3d::UnityVersions).to receive(:fetch_version).at_least(6).times { {} }
78+
expect(U3d::UnityVersions).to receive(:fetch_version_paged).at_least(3).times { {} }
79+
expect(U3d::UnityVersions).to receive(:fetch_version).at_least(3).times { {} }
8580
expect(U3d::UnityVersions).to receive(:fetch_from_json).at_least(:once) { {} }
8681
expect(U3d::UnityVersions.list_available(os: :mac).count).to eql 0
8782
end

0 commit comments

Comments
 (0)