module U3d
--- BEGIN LICENSE BLOCK ---
Copyright © 2016-present WeWantToKnow AS
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--- END LICENSE BLOCK ---
--- BEGIN LICENSE BLOCK ---
Copyright © 2016-present WeWantToKnow AS
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--- END LICENSE BLOCK ---
--- BEGIN LICENSE BLOCK ---
Copyright © 2016-present WeWantToKnow AS
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--- END LICENSE BLOCK ---
Constants
- DEFAULT_LINUX_INSTALL
- DEFAULT_MAC_INSTALL
- DEFAULT_WINDOWS_INSTALL
- DESCRIPTION
- Helper
- U3D_DO_NOT_MOVE
- UI
- UNITY_DIR
- UNITY_DIR_CHECK
- UNITY_DIR_CHECK_LINUX
- UNITY_DIR_LINUX
- UNITY_DIR_LINUX_LONG
- UNITY_DIR_LONG
- UNITY_VERSIONS_NOTE
- VERSION
Public Class Methods
# File lib/u3d.rb, line 52 def self.const_missing(const_name) deprecated = { PlaybackEngineUtils: IvyPlaybackEngineUtils, INIParser: INIModulesParser } super unless deprecated.keys.include? const_name replacement = deprecated[const_name] UI.deprecated "DEPRECATION WARNING: the class U3d::#{const_name} is deprecated. Use #{replacement} instead." replacement end
Public Instance Methods
Fetches central versions.json. Ignore it if it is too old
# File lib/u3d/cache.rb, line 118 def fetch_central_cache(os) UI.message("Fetching central 'versions.json' cache") data = JSON.parse(Utils.get_ssl(GLOBAL_CACHE_URL)) need_update = os_data_need_update?(data, os) @cache = data unless need_update !need_update rescue StandardError => e UI.verbose(e.backtrace.join("\n")) UI.error("Failed fetching central versions.json. Manual fetch for platform #{os} #{e}") false end
# File lib/u3d/cache.rb, line 102 def os_data_need_update?(data, os) data[os.id2name].nil?\ || data[os.id2name]['lastupdate'].nil?\ || (Time.now.to_i - data[os.id2name]['lastupdate'] > CACHE_LIFE)\ || (data[os.id2name]['versions'] || []).empty? end
Updates cache by retrieving versions with U3d::Downloader
# File lib/u3d/cache.rb, line 110 def overwrite_cache(file_path, os, central_cache: false) update_cache(os) unless central_cache && fetch_central_cache(os) File.delete(file_path) if File.file?(file_path) File.open(file_path, 'w') { |f| f.write(@cache.to_json) } end
# File lib/u3d/cache.rb, line 130 def update_cache(os) UI.important "Cache is out of date. Updating cache for #{os.human_name}" @cache ||= {} @cache[os.id2name] = {} @cache[os.id2name]['lastupdate'] = Time.now.to_i @cache[os.id2name]['versions'] = UnityVersions.list_available(os: os) end