Sha256: 2a2d079a4fcfe3414c57fc206c8ff62647bb505f47c04ec5149478716a3ca624

Contents?: true

Size: 490 Bytes

Versions: 3

Compression:

Stored size: 490 Bytes

Contents

module HtmlFormatter
  class RubyIndenter
    INDENT_KEYWORDS = %w[ if elsif else unless while until begin for ]
    OUTDENT_KEYWORDS = %w[ elsif else end ]
    RUBY_INDENT  = %r{
      ^ ( #{INDENT_KEYWORDS.join("|")} )\b
      | \b ( do | \{ ) ( \s* \| [^\|]+ \| )? $
    }xo
    RUBY_OUTDENT = %r{ ^ ( #{OUTDENT_KEYWORDS.join("|")} | \} ) \b }xo

    def outdent?(lines)
      lines.first =~ RUBY_OUTDENT
    end

    def indent?(lines)
      lines.last =~ RUBY_INDENT
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
htmlformatter-1.5.3 lib/htmlformatter/ruby_indenter.rb
htmlformatter-1.5.1 lib/htmlformatter/ruby_indenter.rb
htmlformatter-1.5.0 lib/htmlformatter/ruby_indenter.rb