Sha256: 651a5629728913fd176739af9542c668d588575c6c8cec98a2a511176f8e9390
Contents?: true
Size: 1.78 KB
Versions: 6
Compression:
Stored size: 1.78 KB
Contents
require 'rainbow' def sys cmd STDOUT.puts cmd.color(:black).background(:white) system cmd end def err msg STDOUT.puts msg.color(:yellow).background(:red) exit! end namespace :assets do task :clear_assets do p '== Clear old assets' js_path = File.join(Rails.root, 'app', 'assets', 'javascripts', 'zff') css_path = File.join(Rails.root, 'app', 'assets', 'stylesheets', 'zff') img_path = File.join(Rails.root, 'app', 'assets', 'images', 'zff') sys('rm -r ' + js_path) if File.exists?(js_path) sys('rm -r ' + css_path) if File.exists?(css_path) sys('rm -r ' + img_path) if File.exists?(img_path) end task :add_assets => :clear_assets do p '== Add assets' sys 'cp -Ruf ' << File.join(ZfbenRailsAssetsPath, 'assets') << ' ' << File.join(Rails.root, 'app') end task :clear_gem do gem_path = File.join(Rails.root, 'Gemfile') unless File.exists? gem_path err 'Gemfile is not exists' else p '== Clear old gems' file = File.open(gem_path).readlines.join('') regexp = /(\n)?# Added by zfben_rails_assets.*# End zfben_rails_assets/im File.open(gem_path, 'w'){ |f| f.write(file.gsub(regexp, '')) } if file =~ regexp end end task :add_gem => :clear_gem do p '== Add gems' gem_path = File.join(Rails.root, 'Gemfile') file = File.open(gem_path).readlines file.push "\n# Added by zfben_rails_assets\n\n" << File.open(File.join(ZfbenRailsAssetsPath, 'Gemfile')).readlines.join('') << "\n# End zfben_rails_assets" File.open(gem_path, 'w'){ |f| f.write(file.join('')) } end desc 'install zfben_rails_assets' task :install => [:add_gem, :add_assets] do p '' p '!! Please run `bundle install`' end desc 'uninstall zfben_rails_assets' task :uninstall => [:clear_gem, :clear_assets] end
Version data entries
6 entries across 6 versions & 1 rubygems