Sha256: 853622845d739b383e5e051c28629ed74745dc83750910c2bf05b53802988453

Contents?: true

Size: 1.33 KB

Versions: 8

Compression:

Stored size: 1.33 KB

Contents

namespace :themes do
  namespace :cache do
    
    desc "Creates the cached (public) theme folders"
    task :create do
      themes_root = File.join(Rails.root, "themes")
      for theme in Dir.glob(File.join(themes_root, '*'))

        theme_name = theme.split( File::Separator )[-1]
        theme_root = File.join(Rails.root, "public", "themes", theme_name)

        puts "Creating #{theme_root}"
        FileUtils.mkdir_p "#{theme_root}"

        %w{ images stylesheets javascripts }.each do |d|          
          FileUtils.mkdir_p File.join(theme_root, d)
          Dir.glob(File.join(theme, d, '**', '*')) do |f|                        
            final_path = f[theme.length + 1, f.length]
            if File.stat(f).directory? then               
               FileUtils.mkdir_p File.join(theme_root, final_path) #, :verbose => true
            else               
               FileUtils.cp f, File.join(theme_root, final_path) #, :verbose => true
            end
          end
        end
      end
    end

    desc "Removes the cached (public) theme folders"
    task :remove do
      themes_cache = File.join(Rails.root, 'public', 'themes')
      puts "Removing #{themes_cache}"
      FileUtils.rm_r themes_cache, :force => true
    end

    desc "Updates the cached (public) theme folders"
    task :update => [:remove, :create]
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
theme_support-3.0.7 lib/theme_support/tasks.rb
theme_support-3.0.6 lib/theme_support/tasks.rb
theme_support-3.0.5 lib/theme_support/tasks.rb
theme_support-3.0.4 lib/theme_support/tasks.rb
theme_support-3.0.3 lib/theme_support/tasks.rb
theme_support-3.0.2 lib/theme_support/tasks.rb
theme_support-3.0.1 lib/theme_support/tasks.rb
theme_support-3.0.0 lib/theme_support/tasks.rb