class Textigniter::Parsers::ScriptParser
This class parses scripts. Currently it only parses coffeescript
Public Instance Methods
parse(content)
click to toggle source
# File lib/textigniter/parsers/script_parser.rb, line 37 def parse(content) # require coffee-script gem require 'coffee-script' # return the output return CoffeeScript.compile content end
process(build_list)
click to toggle source
# File lib/textigniter/parsers/script_parser.rb, line 4 def process(build_list) # Output message STDOUT.puts "Rendering ".yellow_on_black + "[coffeescript]".blue_on_black + " scripts ".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, ".coffeescript") # extension @h['extension'] = File.extname(f) # modified_at key @h['modified_at'] = File.mtime(f) # filename for manifest @h['manifest'] = f # parse the content @h['output'] = parse(contents) # push processed item onto the array items.push @h end # return the items return items end