class Textigniter::Parsers::StyleParser
The StyleParser
parses css files. Currently it only parses less files.
Public Instance Methods
parse(content)
click to toggle source
# File lib/textigniter/parsers/style_parser.rb, line 37 def parse(content) # require less gem require 'less' # instantiate the parser parser = Less::Parser.new # parse the content tree = parser.parse(content) # return the output return tree.to_css end
process(build_list)
click to toggle source
# File lib/textigniter/parsers/style_parser.rb, line 4 def process(build_list) # Output message STDOUT.puts "Rendering ".yellow_on_black + "[less]".blue_on_black + " styles ".yellow_on_black + "[OK]".green_on_black # create array to store processed items in items = Array.new # process the build list build_list.each do |f| # open the file for reading file = File.open(f, 'rb') # store the contents in contents and split it at -- contents = file.read # create a hash to store info @h = Hash.new # get the directory directory = File.dirname(f).sub($twd,$owd) + '/' @h['directory'] = directory # get the file name @h['filename'] = File.basename(f, ".less") # filename for manifest @h['manifest'] = f # extension @h['extension'] = File.extname(f) # modified_at key @h['modified_at'] = File.mtime(f) # parse the content @h['output'] = parse(contents) # push processed item onto the array items.push @h end # return the items return items end