Module: U3d::HubModulesParser
- Defined in:
- lib/u3d/hub_modules_parser.rb
Constant Summary collapse
- HUB_MODULES_NAME =
'%<version>s-%<os>s-modules.json'.freeze
Class Method Summary collapse
- .download_modules(os: U3dCore::Helper.operating_system) ⇒ Object
- .load_modules(version, os: U3dCore::Helper.operating_system, offline: false) ⇒ Object
Class Method Details
.download_modules(os: U3dCore::Helper.operating_system) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/u3d/hub_modules_parser.rb', line 49 def download_modules(os: U3dCore::Helper.) url = UnityVersions.json_url_for(json_os(os)) builds = UnityVersions.fetch_json(url, UnityVersions::UNITY_LATEST_JSON) builds.each { |build| write_modules(build, os) } return builds.map { |build| build['versions'] } end |
.load_modules(version, os: U3dCore::Helper.operating_system, offline: false) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/u3d/hub_modules_parser.rb', line 33 def load_modules(version, os: U3dCore::Helper., offline: false) path = modules_path(version, os) unless File.file?(path) && File.size(path) > 0 return [] if offline # Should not raise, not all versions have hub modules versions = download_modules(os: os) unless versions.include? version UI.verbose "No modules registered for UnityHub for version #{version}" return [] end end return JSON.parse(File.read(path)) end |