Class: CKEditor5::Rails::Cdn::CKEditorBundle

Inherits:
Assets::AssetsBundle show all
Includes:
UrlGenerator
Defined in:
lib/ckeditor5/rails/cdn/ckeditor_bundle.rb

Constant Summary

Constants included from UrlGenerator

UrlGenerator::CDN_COMMERCIAL_GENERATORS, UrlGenerator::CDN_THIRD_PARTY_GENERATORS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from UrlGenerator

#create_cdn_url

Methods inherited from Assets::AssetsBundle

#<<, #empty?, #preloads, #translations_scripts

Constructor Details

#initialize(version, import_name, cdn: Engine.default_preset.cdn, translations: []) ⇒ CKEditorBundle

Returns a new instance of CKEditorBundle.

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ckeditor5/rails/cdn/ckeditor_bundle.rb', line 10

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

Instance Attribute Details

#import_nameObject (readonly)

Returns the value of attribute import_name.



8
9
10
# File 'lib/ckeditor5/rails/cdn/ckeditor_bundle.rb', line 8

def import_name
  @import_name
end

#translationsObject (readonly)

Returns the value of attribute translations.



8
9
10
# File 'lib/ckeditor5/rails/cdn/ckeditor_bundle.rb', line 8

def translations
  @translations
end

#versionObject (readonly)

Returns the value of attribute version.



8
9
10
# File 'lib/ckeditor5/rails/cdn/ckeditor_bundle.rb', line 8

def version
  @version
end

Instance Method Details

#scriptsObject



23
24
25
26
27
28
# File 'lib/ckeditor5/rails/cdn/ckeditor_bundle.rb', line 23

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

#stylesheetsObject



30
31
32
33
34
# File 'lib/ckeditor5/rails/cdn/ckeditor_bundle.rb', line 30

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