class Rehab::Parser
Constants
- CONTROL
- EXPRESSION
- INCLUDE
Attributes
line[R]
out[R]
source[R]
Public Instance Methods
call(source)
click to toggle source
# File lib/rehab/parser.rb, line 8 def call(source) @lines = source.lines @out = [:multi] parse_line while next_line out end
Protected Instance Methods
file_provider()
click to toggle source
# File lib/rehab/parser.rb, line 55 def file_provider options[:file_provider] || Rehab::FileProvider end
next_line()
click to toggle source
# File lib/rehab/parser.rb, line 19 def next_line @line = @lines.shift end
parse_file_content(path)
click to toggle source
# File lib/rehab/parser.rb, line 50 def parse_file_content(path) included_content = file_provider.call(path) self.class.new.call(included_content) end
parse_include(path, control = '')
click to toggle source
# File lib/rehab/parser.rb, line 41 def parse_include(path, control = '') if control.empty? parse_file_content(path) else parse_include_with_control(path, control) end end
parse_include_with_control(path, control)
click to toggle source
# File lib/rehab/parser.rb, line 60 def parse_include_with_control(path, control) section = [:multi] section << [:code, control] section << parse_file_content(path) section << [:code, 'end'] end
parse_line()
click to toggle source
# File lib/rehab/parser.rb, line 27 def parse_line case @line when INCLUDE out << parse_include($2, $3) when CONTROL out << [:rehab, :control, $1] when EXPRESSION out << [:rehab, :interpolate, @line] else out << [:static, @line] end end