Sha256: 3f33d0c73d4a684f8377eb3e58724090b939da0cc3d05936a732739f94c26caf
Contents?: true
Size: 1.64 KB
Versions: 1
Compression:
Stored size: 1.64 KB
Contents
require 'bundler/gem_tasks' require 'rake/testtask' Rake::TestTask.new do |t| t.libs << 'test' t.pattern = 'test/**/*_test.rb' t.verbose = true end task :default => :test desc "Converts LESS stylesheets to SCSS" task :less_to_scss do Dir.glob('vendor/assets/stylesheets/less/*.less') do |less_file| tree = []; level = 0 input_file = File.new(less_file, "r") scss_file = File.basename(less_file, ".less") output_file = File.new("vendor/assets/stylesheets/scss/#{scss_file}.scss", "w") while(line = input_file.gets) # IDs if line.match(/^\s*#(\w+) {/) tree.push(line.match(/^\s*#(\w+) {/)[1]) end # Less extensions line.gsub!(/\.less/, '') # Level if line.match(/{/) level += 1 end if line.match(/}/) level -= 1 tree = tree.first(level) end # Variables line.gsub!(/@(\w+)/) do |s| ['@media', '@import', '@keyframes'].include?(s) ? s : s.gsub(/@(\w+)/, '$\1') end # Includes line.gsub!(/(#(\w+) > )*\.(\S+\(.*\)\s*;)/) do |s| s.gsub(/ > (#|\.)/, '-').gsub(/(#|\.)(.*;)/, '@include \2') end line.gsub!(/(#(\w+) > )+\.(\S+(\(.*\))?\s*;)/) do |s| s.gsub(/ > (#|\.)/, '-').gsub(/(#|\.)(.*;)/, '@include \2') end # Mixins line.gsub!(/\s*\.(\S+\(.*\)\s*{)/) do |s| "@mixin #{[tree, s.match(/\.(\S+\(.*\)\s*{)/)[1]].flatten.join('-')}" end # Functions line.gsub!(/spin\(/, 'adjust-hue(') # spin to adjust-hue line.gsub!(/[:\( ]e\(([^\)]*)\)/, ' #{\1}') output_file.puts line end input_file.close output_file.close end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bootstrap-generators-2.0.1 | Rakefile |