Sha256: d7c645ea06bde231a6226de7a5de1ba43cc687193c616c44675f89789ceedf2b
Contents?: true
Size: 1.84 KB
Versions: 1
Compression:
Stored size: 1.84 KB
Contents
def process_value(val) ret = val =~ /^\$/ ? val : '#' + val ret.gsub /\s*\;$/, '' end def printfl(str) print str $stdout.flush end namespace :meta_reports do desc "export both color variables and the colors sass files" task :export_colors => [:export_color_variables, :export_colors_only] desc "export the color variables file" task :export_color_variables => :environment do FileUtils.mkdir_p "app/assets/stylesheets/lib" File.open("app/assets/stylesheets/lib/metareports_color_variables.scss", "w") do |f| printfl "\tVariables: " MetaReports::Report::COLORS.each do |klass, value| printfl "." klass = klass.to_s if value.is_a? Array count = -1 value.each_with_index do |val, i| f.puts "$#{klass}_#{i}: #{process_value(val.split.first)};" end else f.puts "$#{klass}: #{process_value(value.split.first)};" end end puts " Done" end end desc "export the colors file" task :export_colors_only => :environment do File.open("app/assets/stylesheets/lib/metareports_colors.scss", "w") do |f| f.puts "@import 'metareports_color_variables.scss';" print "\tCSS classes: " MetaReports::Report::COLORS.each do |klass, color| printfl "." #for now, colors are simply row colors #css_klass = klass.to_s.gsub(/___/,' ').gsub(/__/,'#').gsub(/_/,'.').gsub(/--/,':') if color.is_a? Array len = color.length color.each_with_index do |val, i| f.puts "tr.#{klass}:nth-child(#{len}n+#{i}) { background: $#{klass}_#{i}; }" end elsif color.to_s =~ /^\s*\$/ f.puts "tr.#{klass} { background: #{color}; }" else f.puts "tr.#{klass} { background: $#{klass}; }" end end puts " Done" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
meta_reports-0.0.5 | lib/tasks/meta_reports_tasks.rake |