Sha256: 208e4667e52864458317349fd9d5c46781b841ba6b2f51a2209a151b6bbfce17

Contents?: true

Size: 457 Bytes

Versions: 88

Compression:

Stored size: 457 Bytes

Contents

def bake_format(data, output, indent)
  indent_level = 0
  data.each_line do |l|
    l.strip!
    opening = l.count('{')
    closing = l.count('}')
    old_indent_level = indent_level
    indent_level = indent_level + opening - closing

    prefix =
      if indent_level > old_indent_level
        indent * old_indent_level
      else
        indent * indent_level
      end
    output.puts((prefix + l).rstrip)
  end
  output.close
end

Version data entries

88 entries across 88 versions & 1 rubygems

Version Path
bake-toolkit-2.55.1 lib/format/bake_format.rb
bake-toolkit-2.55.0 lib/format/bake_format.rb
bake-toolkit-2.54.3 lib/format/bake_format.rb
bake-toolkit-2.54.2 lib/format/bake_format.rb
bake-toolkit-2.54.1 lib/format/bake_format.rb
bake-toolkit-2.54.0 lib/format/bake_format.rb
bake-toolkit-2.53.0 lib/format/bake_format.rb
bake-toolkit-2.52.1 lib/format/bake_format.rb
bake-toolkit-2.52.0 lib/format/bake_format.rb
bake-toolkit-2.51.2 lib/format/bake_format.rb
bake-toolkit-2.51.1 lib/format/bake_format.rb
bake-toolkit-2.51.0 lib/format/bake_format.rb
bake-toolkit-2.50.0 lib/format/bake_format.rb
bake-toolkit-2.49.0 lib/format/bake_format.rb
bake-toolkit-2.48.3 lib/format/bake_format.rb
bake-toolkit-2.48.2 lib/format/bake_format.rb
bake-toolkit-2.48.1 lib/format/bake_format.rb
bake-toolkit-2.48.0 lib/format/bake_format.rb
bake-toolkit-2.47.1 lib/format/bake_format.rb
bake-toolkit-2.47.0 lib/format/bake_format.rb