Sha256: f26fa37b7b55e5e5bab03d037d02f7dcac76605b0851303312d77e057dadddd5

Contents?: true

Size: 1.45 KB

Versions: 30

Compression:

Stored size: 1.45 KB

Contents

require "tinymce/rails/asset_manifest"

require "tinymce/rails/asset_installer/copy"
require "tinymce/rails/asset_installer/compile"

module TinyMCE
  module Rails
    class AssetInstaller
      attr_reader :assets, :target, :strategy
      attr_accessor :logger
      
      def initialize(assets, target, manifest_path)
        @assets = assets
        @target = target
        @manifest_path = manifest_path || target
        
        @logger       = Logger.new($stderr)
        @logger.level = Logger::INFO
      end
      
      def install
        (strategy || Copy).new(self).call
      end
      
      def log_level
        @logger.level
      end

      def log_level=(level)
        if level.is_a?(Integer)
          @logger.level = level
        else
          @logger.level = Logger.const_get(level.to_s.upcase)
        end
      end
      
      def strategy=(strategy)
        if strategy.is_a?(Class)
          @strategy = strategy
        else
          @strategy = self.class.const_get(strategy.to_s.titlecase)
        end
      end
      
      def manifest
        @manifest ||= AssetManifest.load(@manifest_path)
      end
    
      def logical_path(file)
        file.relative_path_from(@assets.parent).to_s
      end
      
      def with_asset(src, dest)
        if src != dest
          src = File.join(@target, src)
          dest = File.join(@target, dest)
          
          yield src, dest if File.exists?(src)
        end
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
tinymce-rails-4.5.6 lib/tinymce/rails/asset_installer.rb
tinymce-rails-4.5.5 lib/tinymce/rails/asset_installer.rb
tinymce-rails-4.5.4 lib/tinymce/rails/asset_installer.rb
tinymce-rails-4.5.3 lib/tinymce/rails/asset_installer.rb
tinymce-rails-4.5.2 lib/tinymce/rails/asset_installer.rb
tinymce-rails-4.5.1 lib/tinymce/rails/asset_installer.rb
tinymce-rails-4.5.0 lib/tinymce/rails/asset_installer.rb
tinymce-rails-4.4.3 lib/tinymce/rails/asset_installer.rb
tinymce-rails-4.4.2 lib/tinymce/rails/asset_installer.rb
tinymce-rails-4.4.1 lib/tinymce/rails/asset_installer.rb
tinymce-rails-4.4.0 lib/tinymce/rails/asset_installer.rb
tinymce-rails-3.5.11.1 lib/tinymce/rails/asset_installer.rb
tinymce-rails-4.3.13 lib/tinymce/rails/asset_installer.rb
tinymce-rails-4.3.12 lib/tinymce/rails/asset_installer.rb
tinymce-rails-4.3.8 lib/tinymce/rails/asset_installer.rb
tinymce-rails-4.3.7 lib/tinymce/rails/asset_installer.rb
tinymce-rails-4.3.3 lib/tinymce/rails/asset_installer.rb
tinymce-rails-4.3.2 lib/tinymce/rails/asset_installer.rb
tinymce-rails-4.3.1 lib/tinymce/rails/asset_installer.rb
tinymce-rails-4.3.0 lib/tinymce/rails/asset_installer.rb