Sha256: 13c397a76d371f01f2f4b9f08f4f407c7dc64eb3f1e8cd0c30b088183d8c6071
Contents?: true
Size: 1.14 KB
Versions: 16
Compression:
Stored size: 1.14 KB
Contents
# frozen_string_literal: true require 'active_support' module CKEditor5::Rails::Cdn module UrlGenerator extend ActiveSupport::Concern CDN_THIRD_PARTY_GENERATORS = { jsdelivr: lambda { |bundle, version, path| base_url = "https://cdn.jsdelivr.net/npm/#{bundle}@#{version}/dist" "#{base_url}/#{path.start_with?('translations/') ? '' : 'browser/'}#{path}" }, unpkg: lambda { |bundle, version, path| base_url = "https://unpkg.com/#{bundle}@#{version}/dist" "#{base_url}/#{path.start_with?('translations/') ? '' : 'browser/'}#{path}" } }.freeze CDN_COMMERCIAL_GENERATORS = { cloud: ->(bundle, version, path) { "https://cdn.ckeditor.com/#{bundle}/#{version}/#{path}" }, ckbox: ->(bundle, version, path) { "https://cdn.ckbox.io/#{bundle}/#{version}/#{path}" } }.freeze included do attr_reader :cdn end def create_cdn_url(bundle, version, path) generator = CDN_THIRD_PARTY_GENERATORS[cdn] || CDN_COMMERCIAL_GENERATORS[cdn] raise ArgumentError, "Unknown provider: #{cdn}" unless generator generator.call(bundle, version, path) end end end
Version data entries
16 entries across 16 versions & 1 rubygems