Class: Textigniter::Parsers::ScriptParser
- Inherits:
-
Object
- Object
- Textigniter::Parsers::ScriptParser
- Defined in:
- lib/textigniter/parsers/script_parser.rb
Overview
This class parses scripts. Currently it only parses coffeescript
Instance Method Summary collapse
Instance Method Details
#parse(content) ⇒ Object
37 38 39 40 41 42 |
# 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) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# 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 |