Sha256: 2de77493453881d3704c5bfac733a82998cc8a283bddc82ee9ae21f15c8ba31d

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

namespace :css_sprite do  
  desc "build css sprite image once"
  task :build do
    require File.join(File.dirname(__FILE__), '../lib/css_sprite/sprite.rb')
    Sprite.new.build
  end
  
  desc "start css sprite server"
  task :start do
    automatic_script = File.join(File.dirname(__FILE__), '..', 'lib', 'automatic.rb')
    if RUBY_PLATFORM =~ /win|w32/
      exec "start \"css_sprite\" ruby.exe #{automatic_script}"
      puts "css_sprite server started sucessfully."
    else
      file_path = "#{Rails.root}/tmp/pids/css_sprite.pid"
      if File.exists?(file_path)
        puts "css_sprite server is started. I haven't done anything."
      else
        pid = fork do
          exec "ruby #{automatic_script}"
        end
      
        sleep(1)
        File.open("#{Rails.root}/tmp/pids/css_sprite.pid", "w") { |f| f << pid }
        puts "css_sprite server started sucessfully."
      end
    end
  end
  
  desc "stop css sprite server"
  task :stop do
    if RUBY_PLATFORM =~ /win|w32/
      exec "taskkill /im ruby.exe /fi \"Windowtitle eq css_sprite\""
      puts "css_sprite server shutdown sucessfully."
    else
      file_path = "#{Rails.root}/tmp/pids/css_sprite.pid"
      if File.exists?(file_path)
        fork do
          File.open(file_path, "r") do |f|
           pid = f.readline
           Process.kill('TERM', pid.to_i)
          end
        end

        Process.wait
        File.unlink(file_path)
        puts "css_sprite server shutdown sucessfully."
      else
        puts "css_sprite server is not running. I haven't done anything."
      end
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
css_sprite-1.3.1 tasks/css_sprite_tasks.rake