Class: CKEditor5::Rails::VersionDetector
- Inherits:
-
Object
- Object
- CKEditor5::Rails::VersionDetector
- Includes:
- Singleton
- Defined in:
- lib/ckeditor5/rails/version_detector.rb
Constant Summary collapse
- NPM_PACKAGE =
'ckeditor5'
- CACHE_DURATION =
4 days in seconds
345_600
Instance Method Summary collapse
-
#initialize ⇒ VersionDetector
constructor
A new instance of VersionDetector.
- #latest_safe_version(current_version) ⇒ Object
Constructor Details
#initialize ⇒ VersionDetector
Returns a new instance of VersionDetector.
20 21 22 23 |
# File 'lib/ckeditor5/rails/version_detector.rb', line 20 def initialize @cache = {} @monitor = Monitor.new end |
Instance Method Details
#latest_safe_version(current_version) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ckeditor5/rails/version_detector.rb', line 25 def latest_safe_version(current_version) @monitor.synchronize do cache_key = "#{current_version}_latest" return @cache[cache_key][:version] if valid_cache_entry?(cache_key) version = find_latest_safe_version(current_version) @cache[cache_key] = { version: version, timestamp: Time.now.to_i } version end end |