Sha256: c1f50ed38e3887c0285e1e36efca45cf9243b1e3a68d0fa1555b7cd9492731ec

Contents?: true

Size: 1.8 KB

Versions: 10

Compression:

Stored size: 1.8 KB

Contents

require 'fileutils'

namespace :iqvoc do
  namespace :assets do

    def Iqvoc.for_static_folders
      engine_public_dir = Iqvoc::Engine.find_root_with_flag("public").join('public')
      app_public_dir = Rails.public_path

      if File.directory?(app_public_dir)
        %w(stylesheets javascripts images fonts).each do |specific_dir|
          source_common_dir = File.join(engine_public_dir, specific_dir, "iqvoc")
          if File.exist?(source_common_dir)
            target_common_dir = File.join(app_public_dir, specific_dir, "iqvoc")
            FileUtils.mkdir_p(File.join(app_public_dir, specific_dir))

            yield(source_common_dir, target_common_dir)
          end
        end
      end
    end

    desc "Create symlinks to public stylesheets, javascripts, fonts and images folders in engine"
    task :link do
      Iqvoc.for_static_folders do |source_common_dir, target_common_dir|
        File.unlink(target_common_dir) if File.symlink?(target_common_dir) && ENV['force'] == "true"
        if !File.exists?(target_common_dir)
          puts "Linking #{source_common_dir} -> #{target_common_dir}"
          File.symlink(source_common_dir, target_common_dir)
        else
          puts "Symlink #{target_common_dir} already exists!"
        end
      end
    end

    desc "Copy public stylesheets, javascripts, fonts and images folders in engine to the public directory of this application"
    task :copy do
      Iqvoc.for_static_folders do |source_common_dir, target_common_dir|
        if !File.exists?(File.join(target_common_dir, "engine"))
          puts "Copying #{source_common_dir} -> #{target_common_dir}"
          FileUtils.cp_r(source_common_dir, target_common_dir)
        else
          puts "Directory #{File.join(target_common_dir, "vendor")} already exists!"
        end
      end
    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
iqvoc-3.2.11 lib/engine_tasks/assets.rake
iqvoc-3.2.10 lib/engine_tasks/assets.rake
iqvoc-3.2.9 lib/engine_tasks/assets.rake
iqvoc-3.2.8 lib/engine_tasks/assets.rake
iqvoc-3.2.7 lib/engine_tasks/assets.rake
iqvoc-3.3.0 lib/engine_tasks/assets.rake
iqvoc-3.2.6 lib/engine_tasks/assets.rake
iqvoc-3.2.5 lib/engine_tasks/assets.rake
iqvoc-3.2.4 lib/engine_tasks/assets.rake
iqvoc-3.2.3 lib/engine_tasks/assets.rake