Sha256: 483bcace7c8df2b08a948b4fc6a4d37541941d0db39f6908a95804664e5ffa35

Contents?: true

Size: 1.51 KB

Versions: 18

Compression:

Stored size: 1.51 KB

Contents

# frozen_string_literal: true

module CKEditor5::Rails
  module Cdn::Concerns
    module BundleBuilder
      def create_preset_bundle(preset)
        preset => {
          cdn:,
          version:,
          translations:,
          ckbox:,
          premium:
        }

        bundle = build_base_cdn_bundle(cdn, version, translations)
        bundle << build_premium_cdn_bundle(cdn, version, translations) if premium
        bundle << build_ckbox_cdn_bundle(ckbox) if ckbox
        bundle << build_plugins_cdn_bundle(preset.plugins.items)
        bundle
      end

      private

      def build_base_cdn_bundle(cdn, version, translations)
        Cdn::CKEditorBundle.new(
          Semver.new(version),
          'ckeditor5',
          translations: translations,
          cdn: cdn
        )
      end

      def build_premium_cdn_bundle(cdn, version, translations)
        Cdn::CKEditorBundle.new(
          Semver.new(version),
          'ckeditor5-premium-features',
          translations: translations,
          cdn: cdn
        )
      end

      def build_ckbox_cdn_bundle(ckbox)
        Cdn::CKBoxBundle.new(
          Semver.new(ckbox[:version]),
          theme: ckbox[:theme] || :lark,
          cdn: ckbox[:cdn] || :ckbox
        )
      end

      def build_plugins_cdn_bundle(plugins)
        plugins.each_with_object(Assets::AssetsBundle.new(scripts: [], stylesheets: [])) do |plugin, bundle|
          bundle << plugin.preload_assets_bundle if plugin.preload_assets_bundle.present?
        end
      end
    end
  end
end

Version data entries

18 entries across 18 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/concerns/bundle_builder.rb
ckeditor5-1.24.9 lib/ckeditor5/rails/cdn/concerns/bundle_builder.rb
ckeditor5-1.24.8 lib/ckeditor5/rails/cdn/concerns/bundle_builder.rb
ckeditor5-1.24.6 lib/ckeditor5/rails/cdn/concerns/bundle_builder.rb
ckeditor5-1.24.5 lib/ckeditor5/rails/cdn/concerns/bundle_builder.rb
ckeditor5-1.24.4 lib/ckeditor5/rails/cdn/concerns/bundle_builder.rb
ckeditor5-1.24.3 lib/ckeditor5/rails/cdn/concerns/bundle_builder.rb
ckeditor5-1.24.2 lib/ckeditor5/rails/cdn/concerns/bundle_builder.rb
ckeditor5-1.24.1 lib/ckeditor5/rails/cdn/concerns/bundle_builder.rb
ckeditor5-1.24.0 lib/ckeditor5/rails/cdn/concerns/bundle_builder.rb
ckeditor5-1.23.5 lib/ckeditor5/rails/cdn/concerns/bundle_builder.rb
ckeditor5-1.23.4 lib/ckeditor5/rails/cdn/concerns/bundle_builder.rb
ckeditor5-1.23.3 lib/ckeditor5/rails/cdn/concerns/bundle_builder.rb
ckeditor5-1.23.2 lib/ckeditor5/rails/cdn/concerns/bundle_builder.rb
ckeditor5-1.23.1 lib/ckeditor5/rails/cdn/concerns/bundle_builder.rb
ckeditor5-1.23.0 lib/ckeditor5/rails/cdn/concerns/bundle_builder.rb
ckeditor5-1.22.0 lib/ckeditor5/rails/cdn/concerns/bundle_builder.rb
ckeditor5-1.21.0 lib/ckeditor5/rails/cdn/concerns/bundle_builder.rb