Sha256: bd0bdf27fdc44ee590d700648283a6850f2f5cf3e1efd2c8e8d188f4f4f47c30

Contents?: true

Size: 946 Bytes

Versions: 6

Compression:

Stored size: 946 Bytes

Contents

require 'bundler/gem_tasks'
require 'less'

LESS_PATH = 'vendor/less'
CSS_PATH = 'vendor/assets/stylesheets'
EXAMPLES_PATH = 'examples'

def copy_css_to_example(file, example)
  css_file = "#{CSS_PATH}/#{file}.css"
  dest_file = "#{EXAMPLES_PATH}/#{example}/public/css/#{file}.css"
  FileUtils.cp(css_file, dest_file)
end

def copy_css_to_examples(file)
  copy_css_to_example(file, 'shop')
end

def less_to_css(file)
  less_file = "#{LESS_PATH}/#{file}.less"
  rcss_file = "#{CSS_PATH}/#{file}.css"
  mcss_file = "#{CSS_PATH}/#{file}-min.css"
  rf = File.new(rcss_file, File::CREAT|File::TRUNC|File::RDWR, 0644)
  mf = File.new(mcss_file, File::CREAT|File::TRUNC|File::RDWR, 0644)
  parser = Less::Parser.new
  tree = parser.parse(File.new(less_file).read)
  rf.write tree.to_css; rf.flush
  mf.write tree.to_css(compress: true); mf.flush
end

task :less do
  less_to_css('dima')
end

file examples: [:less] do
  copy_css_to_examples('dima')
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dima-0.0.6 Rakefile
dima-0.0.5 Rakefile
dima-0.0.4 Rakefile
dima-0.0.3 Rakefile
dima-0.0.2 Rakefile
dima-0.0.1 Rakefile