Sha256: 89698455fcaa22eed3441f1fc16c057cda9feaf16eb21c269f06fdd4f7fa3e8e

Contents?: true

Size: 1.54 KB

Versions: 31

Compression:

Stored size: 1.54 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_url_imports,
          *translations_js_url_imports
        ]
      end

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

      private

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

      def translations_js_url_imports
        translations.filter_map do |lang|
          next if lang == :en

          url = create_cdn_url(import_name, version, "translations/#{lang}.js")

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

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/ckeditor5-1.24.9/lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.24.9 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.24.8 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.24.6 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.24.5 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.24.4 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.24.3 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.24.2 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.24.1 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.24.0 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.23.5 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.23.4 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.23.3 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.23.2 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.23.1 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.23.0 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.22.0 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.21.0 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.20.1 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
ckeditor5-1.20.0 lib/ckeditor5/rails/cdn/ckeditor_bundle.rb