Class: Ckeditor::Rails::Asset

Inherits:
Object
  • Object
show all
Defined in:
lib/ckeditor-rails/asset.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = 'ckeditor', path = '../vendor/assets') ⇒ Asset

Returns a new instance of Asset.



7
8
9
10
# File 'lib/ckeditor-rails/asset.rb', line 7

def initialize name = 'ckeditor', path = '../vendor/assets'
  @name = name
  @root = Ckeditor::Rails.root_path.join path
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/ckeditor-rails/asset.rb', line 5

def name
  @name
end

#rootObject (readonly)

Returns the value of attribute root.



5
6
7
# File 'lib/ckeditor-rails/asset.rb', line 5

def root
  @root
end

Instance Method Details

#filesObject



47
48
49
50
51
52
53
# File 'lib/ckeditor-rails/asset.rb', line 47

def files
  files = []
  files += image_files
  files += javascript_files
  files += stylesheet_files
  files
end

#image_filesObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/ckeditor-rails/asset.rb', line 12

def image_files
  path = root.join('images', name)
  files = Dir.glob(path.join('plugins', '**', '*.{png,gif,jpg}')).reject { |file|
    invalid_plugin_file?(file)
  }
  files += Dir.glob(path.join('skins', '**', '*.{png,gif,jpg}')).reject { |file|
    invalid_skin_file?(file)
  }
  files
end

#javascript_filesObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ckeditor-rails/asset.rb', line 23

def javascript_files
  path = root.join('javascripts', name)
  files = Dir.glob(path.join('*.js'))
  files += Dir.glob(path.join('lang', '*.js')).reject { |file|
    invalid_lang_file?(file)
  }
  files += Dir.glob(path.join('plugins', '**', '*.{js,html}')).reject { |file|
    invalid_plugin_file?(file) or invalid_lang_file?(file)
  }
  files
end

#stylesheet_filesObject



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/ckeditor-rails/asset.rb', line 35

def stylesheet_files
  path = root.join('stylesheets', name)
  files = Dir.glob(path.join('*.css'))
  files += Dir.glob(path.join('plugins', '**', '*.css')).reject { |file|
    invalid_plugin_file?(file)
  }
  files += Dir.glob(path.join('skins', '**', '*.css')).reject { |file|
    invalid_skin_file?(file)
  }
  files
end