Sha256: 689edf2938dec702b427356dc3db9f1dfcf20c87c34e802e334a9ff1bc7e440a

Contents?: true

Size: 1.3 KB

Versions: 30

Compression:

Stored size: 1.3 KB

Contents

module TinyMCE
  module Rails
    class AssetInstaller
      class Copy
        delegate :assets, :target, :manifest, :logger, :logical_path, :with_asset, :to => :@installer
        
        def initialize(installer)
          @installer = installer
        end
        
        def call
          cleanup_assets
          copy_assets
          append_to_manifest
        
          manifest.write
        end
      
      private
        def cleanup_assets
          manifest.each(/^tinymce\//) do |asset|
            manifest.remove_digest(asset) do |src, dest|
              move_asset(src, dest)
            end
          end
        end
        
        def copy_assets
          logger.info "Copying assets to #{File.join(target, "tinymce")}"
          FileUtils.cp_r(assets, target, :preserve => true)
        end
        
        def append_to_manifest
          asset_files.each do |file|
            manifest.append(logical_path(file), file)
          end
        end
        
        def move_asset(src, dest)
          with_asset(src, dest) do |src, dest|
            logger.info "Removing digest from #{src}"
            FileUtils.mv(src, dest, :force => true)
          end
        end
      
        def asset_files
          Pathname.glob("#{assets}/**/*").select(&:file?)
        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/copy.rb
tinymce-rails-4.5.5 lib/tinymce/rails/asset_installer/copy.rb
tinymce-rails-4.5.4 lib/tinymce/rails/asset_installer/copy.rb
tinymce-rails-4.5.3 lib/tinymce/rails/asset_installer/copy.rb
tinymce-rails-4.5.2 lib/tinymce/rails/asset_installer/copy.rb
tinymce-rails-4.5.1 lib/tinymce/rails/asset_installer/copy.rb
tinymce-rails-4.5.0 lib/tinymce/rails/asset_installer/copy.rb
tinymce-rails-4.4.3 lib/tinymce/rails/asset_installer/copy.rb
tinymce-rails-4.4.2 lib/tinymce/rails/asset_installer/copy.rb
tinymce-rails-4.4.1 lib/tinymce/rails/asset_installer/copy.rb
tinymce-rails-4.4.0 lib/tinymce/rails/asset_installer/copy.rb
tinymce-rails-3.5.11.1 lib/tinymce/rails/asset_installer/copy.rb
tinymce-rails-4.3.13 lib/tinymce/rails/asset_installer/copy.rb
tinymce-rails-4.3.12 lib/tinymce/rails/asset_installer/copy.rb
tinymce-rails-4.3.8 lib/tinymce/rails/asset_installer/copy.rb
tinymce-rails-4.3.7 lib/tinymce/rails/asset_installer/copy.rb
tinymce-rails-4.3.3 lib/tinymce/rails/asset_installer/copy.rb
tinymce-rails-4.3.2 lib/tinymce/rails/asset_installer/copy.rb
tinymce-rails-4.3.1 lib/tinymce/rails/asset_installer/copy.rb
tinymce-rails-4.3.0 lib/tinymce/rails/asset_installer/copy.rb