Class: U3d::UnityVersions::VersionsFetcher
- Inherits:
-
Object
- Object
- U3d::UnityVersions::VersionsFetcher
- Defined in:
- lib/u3d/unity_versions.rb
REGEX: expressions to interpret data collapse
-
#versions ⇒ Object
Returns the value of attribute versions.
REGEX: expressions to interpret data collapse
- #fetch_all_channels ⇒ Object
- #fetch_json(os) ⇒ Object
- #fetch_some(type, url) ⇒ Object
-
#initialize(pattern:) ⇒ VersionsFetcher
constructor
A new instance of VersionsFetcher.
Constructor Details
#initialize(pattern:) ⇒ VersionsFetcher
Returns a new instance of VersionsFetcher.
265 266 267 268 |
# File 'lib/u3d/unity_versions.rb', line 265 def initialize(pattern:) @versions = {} @patterns = pattern.is_a?(Array) ? pattern : [pattern] end |
Instance Attribute Details
#versions ⇒ Object
Returns the value of attribute versions.
263 264 265 |
# File 'lib/u3d/unity_versions.rb', line 263 def versions @versions end |
Instance Method Details
#fetch_all_channels ⇒ Object
297 298 299 300 301 302 303 304 |
# File 'lib/u3d/unity_versions.rb', line 297 def fetch_all_channels fetch_some('lts', UNITY_LTSES) fetch_some('stable', UNITY_DOWNLOADS) fetch_some('patch', UNITY_PATCHES) # This does not work any longer # fetch_some('beta', UNITY_BETAS) @versions end |
#fetch_json(os) ⇒ Object
282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/u3d/unity_versions.rb', line 282 def fetch_json(os) UI. 'Loading Unity latest releases' url = UnityVersions.json_url_for(os) latest = UnityVersions.fetch_from_json(url, UNITY_LATEST_JSON) UI.success "Found #{latest.count} latest releases." @versions.merge!(latest) do |key, oldval, newval| UI.important "Unity version #{key} already fetched, replacing #{oldval} with #{newval}" if newval != oldval newval end @versions end |
#fetch_some(type, url) ⇒ Object
270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/u3d/unity_versions.rb', line 270 def fetch_some(type, url) UI. "Loading Unity #{type} releases" total = {} @patterns.each do |pattern| current = UnityVersions.fetch_version_paged(url, pattern) current = UnityVersions.fetch_version(url, pattern) if current.empty? total.merge!(current) end UI.success "Found #{total.count} #{type} releases." @versions.merge!(total) end |