Sha256: 5173b3faef99435f035095d3de120408cf92b207cb4fc8b39223e8ae571a52b9

Contents?: true

Size: 720 Bytes

Versions: 69

Compression:

Stored size: 720 Bytes

Contents

# -*- coding: utf-8 -*-

module RubyToBlock
  # XMLをフォーマットするクラス
  #
  # REXML::Formatters::Prettyでは行頭、行末などのスペースが1つになって
  # しまうため、このクラスではそれらを修正している
  class Formatter < REXML::Formatters::Pretty
    def initialize
      super(2, true)
      self.compact = true
    end

    def write_text(node, output)
      s = node.to_s
      s.gsub!(/\s/, ' ')
      if !node.is_a?(REXML::Text) ||
          node.is_a?(REXML::Text) && !node.parent.whitespace
        s.squeeze!(' ')
      end
      s = wrap(s, @width - @level)
      s = indent_text(s, @level, ' ', true)
      output << (' ' * @level + s)
    end
  end
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
smalruby-editor-0.2.6-x86-mingw32 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.2.6 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.2.5-x86-mingw32 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.2.5 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.2.4-x86-mingw32 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.2.4 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.2.3-x86-mingw32 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.2.3 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.2.2-x86-mingw32 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.2.2 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.2.1-x86-mingw32 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.2.1 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.2.0-x86-mingw32 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.2.0 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.1.24-x86-mingw32 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.1.24 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.1.23-x86-mingw32 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.1.23 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.1.22-x86-mingw32 app/models/concerns/ruby_to_block/formatter.rb
smalruby-editor-0.1.22 app/models/concerns/ruby_to_block/formatter.rb