Sha256: 3c3b3f70d78094e346a3cc4a86c7bb9ae97872945b33b3392140aea35774fe38

Contents?: true

Size: 1.45 KB

Versions: 79

Compression:

Stored size: 1.45 KB

Contents

require "tinymce/rails/asset_manifest"

require "tinymce/rails/asset_installer/copy"
require "tinymce/rails/asset_installer/copy_no_preserve"
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.classify)
        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

79 entries across 79 versions & 3 rubygems

Version Path
tinymce-rails-6.0.3 lib/tinymce/rails/asset_installer.rb
tinymce-rails-6.0.2 lib/tinymce/rails/asset_installer.rb
tinymce-rails-5.10.4 lib/tinymce/rails/asset_installer.rb
tinymce-rails-5.10.3 lib/tinymce/rails/asset_installer.rb
tinymce-rails-5.10.2 lib/tinymce/rails/asset_installer.rb
tinymce-rails-5.10.1 lib/tinymce/rails/asset_installer.rb
tinymce-rails-5.10.0 lib/tinymce/rails/asset_installer.rb
tinymce-rails-5.9.2 lib/tinymce/rails/asset_installer.rb
tinymce-rails-5.9.1 lib/tinymce/rails/asset_installer.rb
tinymce-rails-5.9.0 lib/tinymce/rails/asset_installer.rb
tinymce-rails-5.8.2 lib/tinymce/rails/asset_installer.rb
tinymce-rails-5.8.1 lib/tinymce/rails/asset_installer.rb
tinymce-rails-5.8.0 lib/tinymce/rails/asset_installer.rb
tinymce-rails-5.7.1 lib/tinymce/rails/asset_installer.rb
tinymce-rails-5.6.2.1 lib/tinymce/rails/asset_installer.rb
tinymce-rails-5.6.2 lib/tinymce/rails/asset_installer.rb
tinymce-rails-5.6.1 lib/tinymce/rails/asset_installer.rb
tinymce-rails-5.6.0 lib/tinymce/rails/asset_installer.rb
tinymce-rails-5.5.1 lib/tinymce/rails/asset_installer.rb
tinymce-rails-webmely-5.1.5 lib/tinymce/rails/asset_installer.rb