Sha256: 282e46bf4393186d5425aceb1cce5a0c96fea743bd7a80b17fcf9c502f4988d9

Contents?: true

Size: 1.51 KB

Versions: 37

Compression:

Stored size: 1.51 KB

Contents

# frozen_string_literal: true

module CKEditor5::Rails
  module Cdn
    class CKEditorBundle < Assets::AssetsBundle
      include Cdn::UrlGenerator

      attr_reader :version, :translations, :import_name

      def initialize(version, import_name, cdn: Engine.default_preset.cdn, translations: [])
        raise ArgumentError, 'version must be semver' unless version.is_a?(Semver)
        raise ArgumentError, 'import_name must be a string' unless import_name.is_a?(String)
        raise ArgumentError, 'translations must be an array' unless translations.is_a?(Array)

        super()

        @cdn = cdn
        @version = version
        @import_name = import_name
        @translations = translations
      end

      def scripts
        @scripts ||= [
          js_exports_meta,
          *translations_js_exports_meta
        ]
      end

      def stylesheets
        @stylesheets ||= [
          create_cdn_url(import_name, version, "#{import_name}.css")
        ]
      end

      private

      def js_exports_meta
        Assets::JSExportsMeta.new(
          create_cdn_url(import_name, version, "#{import_name}.js"),
          import_name: import_name
        )
      end

      def translations_js_exports_meta
        translations.map do |lang|
          url = create_cdn_url(import_name, version, "translations/#{lang}.js")

          Assets::JSExportsMeta.new(
            url,
            import_name: "#{import_name}/translations/#{lang}.js",
            translation: true
          )
        end
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
ckeditor5-1.16.1 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.16.0 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.15.10 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.15.9 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.15.8 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.15.7 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.15.2 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.15.1 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.15.0 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.14.1 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.14.0 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.12.0 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.11.1 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.11.0 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.10.0 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.9.0 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.8.0 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.7.0 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.6.1 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.6.0 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb