module IcomoonAsWell::FileHelper
Public Instance Methods
icomoon_dir(target_dir)
click to toggle source
# File lib/icomoon_as_well/file_helper.rb, line 33 def icomoon_dir(target_dir) unless Dir.exist?("#{target_dir}/stylesheets") FileUtils.mkpath(File.join(target_dir, "stylesheets")) end unless Dir.exist?("#{target_dir}/stylesheets/icomoon") FileUtils.mkpath(File.join(target_dir, "stylesheets", "icomoon")) end "#{target_dir}/stylesheets/icomoon" end
parse_css(file)
click to toggle source
# File lib/icomoon_as_well/file_helper.rb, line 5 def parse_css(file) icons = {} c = 0 lines = file.split("\n") while c <= lines.count line = lines[c] c += 1 if line.to_s =~ /^\.icon-(\S+):before\s*{\s*$/ icon_name = $1 value = lines[c] c += 1 icon_name.gsub!(/\s+/, '') value.gsub!(/^\s+/, '').gsub!(/content:/, '').gsub!(/["'\\\s\;]+/, '') icons[icon_name] = value end end icons end
put_files(entry, names, target_dir)
click to toggle source
# File lib/icomoon_as_well/file_helper.rb, line 23 def put_files(entry, names, target_dir) unless Dir.exist?(target_dir) FileUtils.mkpath(target_dir) end names.each do |name| filename = name.gsub(/^.+\//, '') File.open(File.join(target_dir, filename), "w"){ |file| file.write(entry[name]) } end end