Sha256: cfc08eb4d3183272062c8fc97ec4488e2053113669b24122d979f09ba1c9b5c9

Contents?: true

Size: 1.19 KB

Versions: 39

Compression:

Stored size: 1.19 KB

Contents

module TinyMCE
  module Rails
    class AssetInstaller
      class Compile
        delegate :target, :manifest, :logger, :logical_path, :with_asset, :to => :@installer
        
        def initialize(installer)
          @installer = installer
        end
        
        def call
          symlink_assets
        end
      
      private
        def symlink_assets
          manifest.each(/^tinymce\//) do |asset|
            manifest.asset_path(asset) do |src, dest|
              symlink_asset(src, dest)
            end
          end
        end
        
        def symlink_asset(src, dest)
          with_asset(src, dest) do |src, dest|
            create_symlink(src, dest)
            create_symlink("#{src}.gz", "#{dest}.gz") if File.exists?("#{src}.gz")
          end
        end
        
        def create_symlink(src, dest)
          target = File.basename(src)
        
          unless File.exists?(dest) && File.symlink?(dest) && File.readlink(dest) == target
            logger.info "Creating symlink #{dest}"
            FileUtils.ln_s(target, dest, :force => true)
          else
            logger.debug "Skipping symlink #{dest}, already exists"
          end
        end
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
tinymce-rails-4.6.7 lib/tinymce/rails/asset_installer/compile.rb
tinymce-rails-4.6.6 lib/tinymce/rails/asset_installer/compile.rb
tinymce-rails-4.6.5 lib/tinymce/rails/asset_installer/compile.rb
tinymce-rails-4.6.4 lib/tinymce/rails/asset_installer/compile.rb
tinymce-rails-4.6.3 lib/tinymce/rails/asset_installer/compile.rb
tinymce-rails-4.6.2 lib/tinymce/rails/asset_installer/compile.rb
tinymce-rails-4.6.1 lib/tinymce/rails/asset_installer/compile.rb
tinymce-rails-4.6.0 lib/tinymce/rails/asset_installer/compile.rb
tinymce-rails-4.5.7 lib/tinymce/rails/asset_installer/compile.rb
tinymce-rails-4.5.6 lib/tinymce/rails/asset_installer/compile.rb
tinymce-rails-4.5.5 lib/tinymce/rails/asset_installer/compile.rb
tinymce-rails-4.5.4 lib/tinymce/rails/asset_installer/compile.rb
tinymce-rails-4.5.3 lib/tinymce/rails/asset_installer/compile.rb
tinymce-rails-4.5.2 lib/tinymce/rails/asset_installer/compile.rb
tinymce-rails-4.5.1 lib/tinymce/rails/asset_installer/compile.rb
tinymce-rails-4.5.0 lib/tinymce/rails/asset_installer/compile.rb
tinymce-rails-4.4.3 lib/tinymce/rails/asset_installer/compile.rb
tinymce-rails-4.4.2 lib/tinymce/rails/asset_installer/compile.rb
tinymce-rails-4.4.1 lib/tinymce/rails/asset_installer/compile.rb
tinymce-rails-4.4.0 lib/tinymce/rails/asset_installer/compile.rb