lib/hamlit/concerns/indentable.rb in hamlit-1.6.1 vs lib/hamlit/concerns/indentable.rb in hamlit-1.6.2

- old
+ new

@@ -17,14 +17,10 @@ def next_indent return 1 if !@indent_space && fetch_indent(next_line).length > 0 count_indent(next_line) end - def next_width - count_width(next_line) - end - def with_indented(&block) @current_indent += 1 block.call ensure @current_indent -= 1 @@ -35,15 +31,10 @@ return 0 if indent_rule == 0 line.match(/\A[ \t]+/).to_s.length / indent_rule end - def count_width(line) - return EOF unless line - line[/\A[ \t]+/].to_s.length - end - def same_indent?(line) return false unless line count_indent(line) == @current_indent end @@ -63,10 +54,19 @@ validate_indentation_consistency!(indent) next_indent != @current_indent end + def has_block? + return false unless next_line + return fetch_indent(next_line).length > 0 unless @indent_space + + next_indent > @current_indent + end + + private + # Validate the template is using consitent indentation, 2 spaces or a tab. def validate_indentation_consistency!(indent) return false if indent.empty? return false if !@indent_space || @indent_space.empty? @@ -81,40 +81,9 @@ label = indent.include?(' ') ? 'space' : 'tab' length = indent.match(/[ \t]+/).to_s.length "#{length} #{label}#{'s' if length > 1}" - end - - def has_block? - return false unless next_line - return fetch_indent(next_line).length > 0 unless @indent_space - - next_indent > @current_indent - end - - private - - def indent_label(indent) - return %Q{"#{indent}"} if indent.include?(' ') && indent.include?("\t") - - label = indent.include?(' ') ? 'space' : 'tab' - length = indent.match(/[ \t]+/).to_s.length - - "#{length} #{label}#{'s' if length > 1}" - end - - def count_width(line) - return EOF unless line - line[/\A +/].to_s.length - end - - def next_space - next_line[/\A +/].to_s - end - - def next_width - count_width(next_line) end def indent_rule (@indent_space || '').length end