u3d 1.1.5 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -124,6 +124,7 @@ module U3d
124
124
  LINUX_DOWNLOAD = %r{['"](https?:\/\/[\w/\.-]+/[0-9a-f\+]{12,13}\/)(.\/)?UnitySetup-(\d+\.\d+\.\d+\w\d+)['"]}
125
125
 
126
126
  MAC_WIN_SHADERS = %r{"(https?://[\w/\.-]+/[0-9a-f\+]{12,13}/)builtin_shaders-(\d+\.\d+\.\d+\w\d+)\.?\w+"}
127
+ LINUX_INSTALLER = %r{(https?://[\w/\.-]+/[0-9a-f\+]{12,13}/)LinuxEditorInstaller/Unity.tar.xz}
127
128
 
128
129
  LINUX_DOWNLOAD_DATED = %r{"(https?://[\w/\._-]+/unity\-editor\-installer\-(\d+\.\d+\.\d+\w\d+).*\.sh)"}
129
130
  LINUX_DOWNLOAD_RECENT_PAGE = %r{"(https?://beta\.unity3d\.com/download/[a-zA-Z0-9/\.\+]+/public_download\.html)"}
@@ -164,10 +165,18 @@ module U3d
164
165
  end.reduce({}, :merge)
165
166
  end
166
167
 
167
- def fetch_from_json(url, pattern)
168
+ def json_url_for(os)
169
+ format(UNITY_LATEST_JSON_URL, os: os)
170
+ end
171
+
172
+ def fetch_json(url, pattern)
168
173
  require 'json'
169
174
  data = Utils.get_ssl(url)
170
- JSON.parse(data).values.flatten.select { |b| pattern =~ b['downloadUrl'] }.map do |build|
175
+ JSON.parse(data).values.flatten.select { |b| pattern =~ b['downloadUrl'] }
176
+ end
177
+
178
+ def fetch_from_json(url, pattern)
179
+ fetch_json(url, pattern).map do |build|
171
180
  [build['version'], pattern.match(build['downloadUrl'])[1]]
172
181
  end.to_h
173
182
  end
@@ -182,6 +191,8 @@ module U3d
182
191
  end
183
192
 
184
193
  class LinuxVersions
194
+ JSON_OS = 'linux'.freeze
195
+
185
196
  @unity_forums = U3d::UnityForums.new
186
197
  class << self
187
198
  attr_accessor :unity_forums
@@ -191,6 +202,10 @@ module U3d
191
202
  versions = @unity_forums.pagination_urls(UNITY_LINUX_DOWNLOADS).map do |page_url|
192
203
  list_available_from_page(@unity_forums, unity_forums.page_content(page_url))
193
204
  end.reduce({}, :merge)
205
+
206
+ versions_fetcher = VersionsFetcher.new(pattern: LINUX_INSTALLER)
207
+ versions.merge!(versions_fetcher.fetch_json('linux'))
208
+
194
209
  if versions.count.zero?
195
210
  UI.important 'Found no releases'
196
211
  else
@@ -261,7 +276,7 @@ module U3d
261
276
 
262
277
  def fetch_json(os)
263
278
  UI.message 'Loading Unity latest releases'
264
- url = format(UNITY_LATEST_JSON_URL, os: os)
279
+ url = UnityVersions.json_url_for(os)
265
280
  latest = UnityVersions.fetch_from_json(url, UNITY_LATEST_JSON)
266
281
 
267
282
  UI.success "Found #{latest.count} latest releases."
@@ -285,21 +300,25 @@ module U3d
285
300
  end
286
301
 
287
302
  class MacVersions
303
+ JSON_OS = 'darwin'.freeze
304
+
288
305
  class << self
289
306
  def list_available
290
307
  versions_fetcher = VersionsFetcher.new(pattern: [MAC_WIN_SHADERS])
291
308
  versions_fetcher.fetch_all_channels
292
- versions_fetcher.fetch_json('darwin')
309
+ versions_fetcher.fetch_json(JSON_OS)
293
310
  end
294
311
  end
295
312
  end
296
313
 
297
314
  class WindowsVersions
315
+ JSON_OS = 'win32'.freeze
316
+
298
317
  class << self
299
318
  def list_available
300
319
  versions_fetcher = VersionsFetcher.new(pattern: MAC_WIN_SHADERS)
301
320
  versions_fetcher.fetch_all_channels
302
- versions_fetcher.fetch_json('win32')
321
+ versions_fetcher.fetch_json(JSON_OS)
303
322
  end
304
323
  end
305
324
  end
@@ -151,6 +151,28 @@ module U3d
151
151
  FileUtils.mkpath(dir) unless File.directory?(dir)
152
152
  end
153
153
 
154
+ def get_write_access(dir)
155
+ if U3dCore::Helper.operating_system == :win
156
+ yield
157
+ else
158
+ stat_command = if U3dCore::Helper.operating_system == :linux
159
+ "stat -c \"%U,%a\" #{dir}"
160
+ elsif U3dCore::Helper.operating_system == :mac
161
+ "stat -f \"%Su,%A\" #{dir}"
162
+ end
163
+ owner, access = U3dCore::CommandExecutor.execute(command: stat_command, admin: false).strip.split(',')
164
+ current_user = U3dCore::CommandExecutor.execute(command: 'whoami', admin: false)
165
+ U3dCore::CommandExecutor.execute(command: "chown #{current_user}: #{dir}", admin: true)
166
+ U3dCore::CommandExecutor.execute(command: "chmod u+w #{dir}", admin: true)
167
+ begin
168
+ yield
169
+ ensure
170
+ U3dCore::CommandExecutor.execute(command: "chown #{owner}: #{dir}", admin: true)
171
+ U3dCore::CommandExecutor.execute(command: "chmod #{access} #{dir}", admin: true)
172
+ end
173
+ end
174
+ end
175
+
154
176
  # if total is nil (unknown, falls back to print_progress_nosize)
155
177
  def print_progress(current, total, started_at)
156
178
  if total.nil?
@@ -191,6 +213,7 @@ module U3d
191
213
  result = getdir.call(0, CSIDL_LOCAL_APPDATA, 0, 0, windir)
192
214
  raise "Unable to get Local Appdata directory, returned with value #{result}" unless result.zero?
193
215
  windir.rstrip!
216
+ windir = windir.encode("UTF-8", Encoding.find('filesystem'))
194
217
  windir = File.expand_path(windir.rstrip)
195
218
 
196
219
  return windir if Dir.exist? windir
@@ -21,7 +21,7 @@
21
21
  ## --- END LICENSE BLOCK ---
22
22
 
23
23
  module U3d
24
- VERSION = '1.1.5'.freeze
24
+ VERSION = '1.2.0'.freeze
25
25
  DESCRIPTION = 'Provides numerous tools for installing, managing and running the Unity game engine from command line.'.freeze
26
26
  UNITY_VERSIONS_NOTE = "Unity uses the following version formatting: 0.0.0x0. The \'x\' can takes different values:\n"\
27
27
  "\t. 'f' are the main release candidates for Unity\n"\
@@ -25,13 +25,18 @@ module U3dCore
25
25
  # Shell is the terminal output of things
26
26
  # For documentation for each of the methods open `interface.rb`
27
27
  class Shell < Interface
28
+ # test_log_buffer: by default, don't show any logs when running tests
29
+ def initialize(test_log_buffer: nil)
30
+ @test_log_buffer = test_log_buffer
31
+ end
32
+
28
33
  def log
29
34
  return @log if @log
30
35
 
31
36
  $stdout.sync = true
32
37
 
33
38
  @log ||= if Helper.test?
34
- Logger.new(nil) # don't show any logs when running tests
39
+ Logger.new(@test_log_buffer)
35
40
  else
36
41
  Logger.new(EPipeIgnorerLogDevice.new($stdout))
37
42
  end
@@ -27,6 +27,8 @@ module U3dCore
27
27
  def current
28
28
  @current ||= Shell.new
29
29
  end
30
+
31
+ attr_writer :current
30
32
  end
31
33
 
32
34
  # rubocop:disable Style/MethodMissing
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_dependency 'filesize', '>= 0.1.1' # File sizes prettifier
30
30
  spec.add_dependency 'inifile', '>= 3.0.0', '< 4.0.0' # Parses INI files
31
31
  spec.add_dependency 'plist', '>= 3.1.0', '< 4.0.0' # Generate the Xcode config plist file
32
+ spec.add_dependency 'rubyzip', '>= 2.0.0', '< 3.0.0' # Installation of .zip files
32
33
  spec.add_dependency 'security', '= 0.1.3' # macOS Keychain manager, a dead project, no updates expected
33
34
  # Development only
34
35
  spec.add_development_dependency "bundler", "~> 1.13"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: u3d
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jerome Lacoste
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-03-06 00:00:00.000000000 Z
12
+ date: 2019-11-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colored
@@ -119,6 +119,26 @@ dependencies:
119
119
  - - "<"
120
120
  - !ruby/object:Gem::Version
121
121
  version: 4.0.0
122
+ - !ruby/object:Gem::Dependency
123
+ name: rubyzip
124
+ requirement: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: 2.0.0
129
+ - - "<"
130
+ - !ruby/object:Gem::Version
131
+ version: 3.0.0
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: 2.0.0
139
+ - - "<"
140
+ - !ruby/object:Gem::Version
141
+ version: 3.0.0
122
142
  - !ruby/object:Gem::Dependency
123
143
  name: security
124
144
  requirement: !ruby/object:Gem::Requirement
@@ -384,11 +404,13 @@ files:
384
404
  - lib/u3d/download_validator.rb
385
405
  - lib/u3d/downloader.rb
386
406
  - lib/u3d/failure_reporter.rb
387
- - lib/u3d/iniparser.rb
407
+ - lib/u3d/hub_modules_parser.rb
408
+ - lib/u3d/ini_modules_parser.rb
388
409
  - lib/u3d/installation.rb
389
410
  - lib/u3d/installer.rb
390
411
  - lib/u3d/log_analyzer.rb
391
412
  - lib/u3d/unity_license.rb
413
+ - lib/u3d/unity_module.rb
392
414
  - lib/u3d/unity_project.rb
393
415
  - lib/u3d/unity_runner.rb
394
416
  - lib/u3d/unity_version_definition.rb
@@ -433,8 +455,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
433
455
  - !ruby/object:Gem::Version
434
456
  version: '0'
435
457
  requirements: []
436
- rubyforge_project:
437
- rubygems_version: 2.7.6
458
+ rubygems_version: 3.0.1
438
459
  signing_key:
439
460
  specification_version: 4
440
461
  summary: U3d