Class: TinyMCE::Rails::AssetInstaller

Inherits:
Object
  • Object
show all
Defined in:
lib/tinymce/rails/asset_installer.rb,
lib/tinymce/rails/asset_installer/copy.rb,
lib/tinymce/rails/asset_installer/compile.rb,
lib/tinymce/rails/asset_installer/copy_no_preserve.rb

Defined Under Namespace

Classes: Compile, Copy, CopyNoPreserve

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(assets, target, manifest_path) ⇒ AssetInstaller

Returns a new instance of AssetInstaller.



13
14
15
16
17
18
19
20
# File 'lib/tinymce/rails/asset_installer.rb', line 13

def initialize(assets, target, manifest_path)
  @assets = assets
  @target = target
  @manifest_path = manifest_path || target

  @logger       = Logger.new($stderr)
  @logger.level = Logger::INFO
end

Instance Attribute Details

#assetsObject (readonly)

Returns the value of attribute assets.



10
11
12
# File 'lib/tinymce/rails/asset_installer.rb', line 10

def assets
  @assets
end

#loggerObject

Returns the value of attribute logger.



11
12
13
# File 'lib/tinymce/rails/asset_installer.rb', line 11

def logger
  @logger
end

#strategyObject

Returns the value of attribute strategy.



10
11
12
# File 'lib/tinymce/rails/asset_installer.rb', line 10

def strategy
  @strategy
end

#targetObject (readonly)

Returns the value of attribute target.



10
11
12
# File 'lib/tinymce/rails/asset_installer.rb', line 10

def target
  @target
end

Instance Method Details

#installObject



22
23
24
# File 'lib/tinymce/rails/asset_installer.rb', line 22

def install
  (strategy || Copy).new(self).call
end

#log_levelObject



26
27
28
# File 'lib/tinymce/rails/asset_installer.rb', line 26

def log_level
  @logger.level
end

#log_level=(level) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/tinymce/rails/asset_installer.rb', line 30

def log_level=(level)
  if level.is_a?(Integer)
    @logger.level = level
  else
    @logger.level = Logger.const_get(level.to_s.upcase)
  end
end

#logical_path(file) ⇒ Object



50
51
52
# File 'lib/tinymce/rails/asset_installer.rb', line 50

def logical_path(file)
  file.relative_path_from(@assets.parent).to_s
end

#manifestObject



46
47
48
# File 'lib/tinymce/rails/asset_installer.rb', line 46

def manifest
  @manifest ||= AssetManifest.load(@manifest_path)
end

#with_asset(src, dest) ⇒ Object



54
55
56
57
58
59
60
61
# File 'lib/tinymce/rails/asset_installer.rb', line 54

def with_asset(src, dest)
  if src != dest
    src = File.join(@target, src)
    dest = File.join(@target, dest)

    yield src, dest if File.exist?(src)
  end
end